3
gl%                 @   s~  d dl Z d dlZd dlZd dlmZmZmZmZmZm	Z	m
Z
 d dlmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZm Z  d dl!m"Z" d dl#m$Z$m%Z% ddl&m'Z'm(Z( ddl)m*Z* erd dl+m,Z- e-e(e'e.f Z,ej/e0Z1G dd deZde2eee. e2f dddZ3e	e.ef eee. e2f e	e2e.f dddZ4dS )    N)TYPE_CHECKINGDictListOptionalSetTuplecast)canonicalize_name)BaseReporterResolutionImpossible)Resolver)DirectedGraph)
WheelCache)PackageFinder)RequirementPreparer)InstallRequirement)RequirementSet)BaseResolverInstallRequirementProvider)PipProvider)PipDebuggingReporterPipReporter   )	CandidateRequirement)Factory)Resultc                   s|   e Zd ZdddhZdeeee ee	e	e	e	e	e
eeedf  d fddZee e	ed	d
dZeee dddZ  ZS )r   eagerzonly-if-neededzto-satisfy-onlyN.)preparerfinderwheel_cachemake_install_requse_user_siteignore_dependenciesignore_installedignore_requires_pythonforce_reinstallupgrade_strategypy_version_infoc                sJ   t  j  |
| jkstt||||||	|||d	| _|| _|
| _d | _d S )N)	r   r   r!   r    r"   r&   r$   r%   r(   )	super__init___allowed_strategiesAssertionErrorr   factoryr#   r'   _result)selfr   r   r    r!   r"   r#   r$   r%   r&   r'   r(   )	__class__ j/var/www/tester-filtro-web/env/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/resolver.pyr*   &   s    

zResolver.__init__)	root_reqscheck_supported_wheelsreturnc             C   s  | j j|}t| j |j| j| j|jd}dtjkr:t	 }nt
 }t||}yd}|j|j|d }| _W n> tk
r }	 z"| j jtd|	|j}
|
|	W Y d d }	~	X nX t|d}x|jj D ]}|j }|d krq| j j|}|d krd|_nr| j jrd|_n`|j|jkrd|_nJ|js(|jr0d|_n2|jr|jjr|jjrXtj d	|j! qd|_nq|j}|r|j"rd
j#|j!|j||j$pdd}tj%| |j&| qW |j'}| j j(j)| |S )N)r-   constraintsr#   r'   user_requestedZPIP_RESOLVER_DEBUGi )Z
max_roundsz,ResolutionImpossible[Requirement, Candidate])r4   FTz%s is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.zThe candidate selected for download or install is a yanked version: {name!r} candidate (version {version} at {link})
Reason for being yanked: {reason}z<none given>)nameversionlinkreason)*r-   Zcollect_root_requirementsr   r6   r#   r'   r7   osenvironr   r   
RLResolverresolverequirementsr.   r   Zget_installation_errorr   r   mappingvaluesZget_install_requirementZget_dist_to_uninstallshould_reinstallr&   r9   is_editableeditableZsource_linkis_fileis_wheelloggerinfor8   	is_yankedformatyanked_reasonwarningadd_named_requirementall_requirementsr    prepare_linked_requirements_more)r/   r3   r4   Z	collectedZproviderZreporterresolverZ try_to_avoid_resolution_too_deepresulteerrorreq_set	candidateireqinstalled_distr:   msgreqsr1   r1   r2   r?   F   sp    





zResolver.resolve)rU   r5   c             C   s^   | j dk	std| j j}t|t| j jd d}t|jj t	j
t|ddd}dd	 |D S )
a  Get order for installation of requirements in RequirementSet.

        The returned list contains a requirement before another that depends on
        it. This helps ensure that the environment is kept consistent as they
        get installed one-by-one.

        The current implementation creates a topological ordering of the
        dependency graph, while breaking any cycles in the graph at arbitrary
        points. We make no guarantees about where the cycle would be broken,
        other than they would be broken.
        Nzmust call resolve() firstr   )expected_node_count)weightsT)keyreversec             S   s   g | ]\}}|qS r1   r1   ).0_rW   r1   r1   r2   
<listcomp>   s    z3Resolver.get_installation_order.<locals>.<listcomp>)r.   r,   graphget_topological_weightslenrA   sortedr@   items	functoolspartial_req_set_item_sorter)r/   rU   rb   r\   Zsorted_itemsr1   r1   r2   get_installation_order   s    zResolver.get_installation_order)N)__name__
__module____qualname__r+   r   r   r   r   r   boolstrr   intr*   r   r   r   r?   rj   __classcell__r1   r1   )r0   r2   r   #   s   
8]r   zDirectedGraph[Optional[str]])rb   r[   r5   c                sT   t  i tt dd fddd d dks@tt|ksPtS )a  Assign weights to each node based on how "deep" they are.

    This implementation may change at any point in the future without prior
    notice.

    We take the length for the longest path to any node from root, ignoring any
    paths that contain a single node twice (i.e. cycles). This is done through
    a depth-first search through the graph, while keeping track of the path to
    the node.

    Cycles in the graph result would result in node being revisited while also
    being it's own path. In this case, take no action. This helps ensure we
    don't get stuck in a cycle.

    When assigning weight, the longer path (i.e. larger length) is preferred.
    N)noder5   c                s^   | krd S j |  x j| D ]}| q"W j|  j| d}t|t| < d S )Nr   )addZiter_childrenremovegetmaxrd   )rr   childZlast_known_parent_count)rb   pathvisitr\   r1   r2   ry      s    

z&get_topological_weights.<locals>.visitr   )setr   ro   r,   rd   )rb   r[   r1   )rb   rx   ry   r\   r2   rc      s    rc   )itemr\   r5   c             C   s   t | d }|| |fS )a)  Key function used to sort install requirements for installation.

    Based on the "weight" mapping calculated in ``get_installation_order()``.
    The canonical package name is returned as the second member as a tie-
    breaker to ensure the result is predictable, which is useful in tests.
    r   )r	   )r{   r\   r8   r1   r1   r2   ri      s    
ri   )5rg   loggingr<   typingr   r   r   r   r   r   r   pip._vendor.packaging.utilsr	   Zpip._vendor.resolvelibr
   r   r   r>   Zpip._vendor.resolvelib.structsr   pip._internal.cacher   "pip._internal.index.package_finderr    pip._internal.operations.preparer   Zpip._internal.req.req_installr   Zpip._internal.req.req_setr   pip._internal.resolution.baser   r   Z,pip._internal.resolution.resolvelib.providerr   Z,pip._internal.resolution.resolvelib.reporterr   r   baser   r   r-   r   Z pip._vendor.resolvelib.resolversr   ZRLResultro   	getLoggerrk   rH   rp   rc   ri   r1   r1   r1   r2   <module>   s8   $
 !-
