a ljl%@s~ddlZddlZddlZddlmZmZmZmZmZm Z m Z ddl m Z ddl mZmZddl mZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZm Z dd l!m"Z"ddl#m$Z$m%Z%ddl&m'Z'm(Z(ddl)m*Z*erddl+m,Z-e-e(e'e.fZ,e/e0Z1GdddeZde2eee.e2fdddZ3e e.efeee.e2fe e2e.fdddZ4dS)N) TYPE_CHECKINGDictListOptionalSetTuplecastcanonicalize_name) BaseReporterResolutionImpossible)Resolver) DirectedGraph) WheelCache) PackageFinder)RequirementPreparer)InstallRequirement)RequirementSet) BaseResolverInstallRequirementProvider) PipProvider)PipDebuggingReporter PipReporter) Candidate Requirement)Factory)ResultcszeZdZhdZd eeeeee e e e e e ee e dfd fdd Z eee eddd Zeeed d d ZZS)r >zto-satisfy-onlyzonly-if-neededZeagerN.) preparerfinder wheel_cachemake_install_req use_user_siteignore_dependenciesignore_installedignore_requires_pythonforce_reinstallupgrade_strategypy_version_infoc sJt| |jvsJt|||||| ||| d |_||_| |_d|_dS)N) rrr!r r"r&r$r%r()super__init___allowed_strategiesrfactoryr#r'_result) selfrrr r!r"r#r$r%r&r'r( __class__P/usr/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.pyr*&s   zResolver.__init__) root_reqscheck_supported_wheelsreturnc Cs|j|}t|j|j|j|j|jd}dtjvr:t }nt }t ||}zd}|j |j |d}|_Wn@ty} z(|jtd| |j} | | WYd} ~ n d} ~ 00t|d} |jD]} | } | durq|j| }|durd| _nr|jjrd| _n`|j| jkrd| _nJ| js(|jr0d| _n2| jr| jjr| jjrXt d | j!qd| _nq| j}|r|j"rd j#| j!| j||j$pd d }t%|| &| q| j'}|jj()|| S) N)r, constraintsr#r'user_requestedZPIP_RESOLVER_DEBUGi)Z max_roundsz,ResolutionImpossible[Requirement, Candidate])r4FTz%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 )nameversionlinkreason)*r,Zcollect_root_requirementsrr6r#r'r7osenvironrr RLResolverresolve requirementsr-r Zget_installation_errorrrmappingvaluesZget_install_requirementZget_dist_to_uninstallZshould_reinstallr&r9Z is_editableZeditableZ source_linkis_fileZis_wheelloggerinfor8Z is_yankedformatZ yanked_reasonZwarningZadd_named_requirementZall_requirementsrZ prepare_linked_requirements_more)r.r3r4Z collectedZproviderZreporterZresolverZ try_to_avoid_resolution_too_deepresulteerrorreq_set candidateireqZinstalled_distr:msgZreqsr1r1r2r?Fs~         zResolver.resolve)rJr5cCs^|jdusJd|jj}t|t|jjdd}t|jtj t |ddd}dd |DS) aGet 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. Nzmust call resolve() firstr)expected_node_count)weightsT)keyreversecSsg|] \}}|qSr1r1).0_rLr1r1r2 z3Resolver.get_installation_order..) r-graphget_topological_weightslenrAsortedr@items functoolspartial_req_set_item_sorter)r.rJrVrOZ sorted_itemsr1r1r2get_installation_orders zResolver.get_installation_order)N)__name__ __module__ __qualname__r+rrrrrboolstrrintr*rrrr?r^ __classcell__r1r1r/r2r #s*! _r zDirectedGraph[Optional[str]])rVrNr5csTtittddfdd dddks@Jt|ksPJS)aAssign 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)noder5csZ|vr dS||D] }|q ||d}t|t|<dS)Nr)addZ iter_childrenremovegetmaxrX)rfchildZlast_known_parent_countrVpathvisitrOr1r2rns    z&get_topological_weights..visitr)setrrcrX)rVrNr1rlr2rWsrW)itemrOr5cCst|d}|||fS)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. rr )rprOr8r1r1r2r]s r])5r[Zloggingr<typingrrrrrrrZpip._vendor.packaging.utilsr Zpip._vendor.resolvelibr r r r>Zpip._vendor.resolvelib.structsrZpip._internal.cacherZ"pip._internal.index.package_finderrZ pip._internal.operations.preparerZpip._internal.req.req_installrZpip._internal.req.req_setrZpip._internal.resolution.baserrZ,pip._internal.resolution.resolvelib.providerrZ,pip._internal.resolution.resolvelib.reporterrrbaserrr,rZ pip._vendor.resolvelib.resolversrZRLResultrcZ getLoggerr_rDrdrWr]r1r1r1r2s<$            ! /