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 s<tt|||||| ||| d |_||_| |_d|_dS)N) rrr!r r"r&r$r%r()super__init__rfactoryr#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])r3FTz%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_requirementsrr5r#r'r6osenvironrr RLResolverresolve requirementsr,r Zget_installation_errorrrmappingvaluesZget_install_requirementZget_dist_to_uninstallZshould_reinstallr&r8Z is_editableZeditableZ source_linkis_fileZis_wheelloggerinfor7Z is_yankedformatZ yanked_reasonZwarningZadd_named_requirementZall_requirementsrZ prepare_linked_requirements_more)r-r2r3Z collectedZproviderZreporterZresolverZ try_to_avoid_resolution_too_deepresulteerrorreq_set candidateireqZinstalled_distr9msgZreqsr0r0r1r>Fs~         zResolver.resolve)rIr4cCsL|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. r)expected_node_count)weightsT)keyreversecSsg|] \}}|qSr0r0).0_rKr0r0r1 z3Resolver.get_installation_order..) r,graphget_topological_weightslenr@sortedr?items functoolspartial_req_set_item_sorter)r-rIrUrNZ sorted_itemsr0r0r1get_installation_orders zResolver.get_installation_order)N)__name__ __module__ __qualname__Z_allowed_strategiesrrrrrboolstrrintr*rrrr>r] __classcell__r0r0r.r1r #s*! _r zDirectedGraph[Optional[str]])rUrMr4cs4tittddfdd dS)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)noder4csZ|vr dS||D] }|q ||d}t|t|<dS)Nr)addZ iter_childrenremovegetmaxrW)rechildZlast_known_parent_countrUpathvisitrNr0r1rms    z&get_topological_weights..visit)setrrb)rUrMr0rkr1rVs rV)itemrNr4cCst|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 )rorNr7r0r0r1r\s r\)5rZZloggingr;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.resolversrZRLResultrbZ getLoggerr^rCrcrVr\r0r0r0r1s<$            ! /