ReDddlZddlZddlmZddlmZmZmZejdddgZ Gdd e Z Gd d e Z Gd d e Z GddeZGdde ZGddeZGddeZejddZGddeZdZejddZdZGddeZdS) N)AbstractResolver) DirectedGraphIteratorMappingbuild_iter_viewRequirementInformation requirementparentceZdZdZdS)ResolverExceptionzA base class for all exceptions raised by this module. Exceptions derived by this class should all be handled in this module. Any bubbling pass the resolver should be treated as a bug. N)__name__ __module__ __qualname____doc__/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.pyr r srr c$eZdZfdZdZxZS)RequirementsConflictedcftt||||_dSN)superr__init__ criterion)selfr __class__s rrzRequirementsConflicted.__init__s- $d++44Y???"rcddd|jDS)NzRequirements conflict: {}, c34K|]}t|VdSrrepr.0rs r z1RequirementsConflicted.__str__..(II!d1ggIIIIIIr)formatjoinriter_requirementrs r__str__zRequirementsConflicted.__str__sF*11 IIIIt~'F'F'H'HIII I I   rr rrrr+ __classcell__rs@rrrsG#####       rrc$eZdZfdZdZxZS)InconsistentCandidatecvtt|||||_||_dSr)rr0r candidater)rr2rrs rrzInconsistentCandidate.__init__!s6 #T**33IyIII""rcd|jdd|jDS)Nz+Provided candidate {!r} does not satisfy {}rc34K|]}t|VdSrr r"s rr%z0InconsistentCandidate.__str__..)r&r)r'r2r(rr)r*s rr+zInconsistentCandidate.__str__&sK<CC N IIIIt~'F'F'H'HIII I I   rr,r.s@rr0r0 sG#####        rr0c*eZdZdZdZdZdZdZdS) CriterionaQRepresentation of possible resolution results of a package. This holds three attributes: * `information` is a collection of `RequirementInformation` pairs. Each pair is a requirement contributing to this criterion, and the candidate that provides the requirement. * `incompatibilities` is a collection of all known not-to-work candidates to exclude from consideration. * `candidates` is a collection containing all possible candidates deducted from the union of contributing requirements and known incompatibilities. It should never be empty, except when the criterion is an attribute of a raised `RequirementsConflicted` (in which case it is always empty). .. note:: This class is intended to be externally immutable. **Do not** mutate any of its attribute containers. c0||_||_||_dSr candidates informationincompatibilities)rr9r:r;s rrzCriterion.__init__As$&!2rctdd|jD}d|S)Nrc3HK|]\}}d||VdS)z({!r}, via={!r})N)r')r#reqr s rr%z%Criterion.__repr__..GsJ! ! V  % %c6 2 2! ! ! ! ! ! rz Criterion({}))r(r:r')r requirementss r__repr__zCriterion.__repr__FsJyy! ! #/! ! !   %%l333rc$d|jDS)Nc3$K|] }|jV dSr)r r#is rr%z-Criterion.iter_requirement..Ns$88! 888888rr:r*s rr)zCriterion.iter_requirementMs88t'78888rc$d|jDS)Nc3$K|] }|jV dSrr rCs rr%z(Criterion.iter_parent..Qs$33Q333333rrEr*s r iter_parentzCriterion.iter_parentPs33$"23333rN)r rrrrr@r)rIrrrr6r6-sZ&333 44499944444rr6ceZdZdS)ResolutionErrorN)r rrrrrrKrKTsDrrKceZdZfdZxZS)ResolutionImpossiblecftt||||_dSr)rrMrcauses)rrOrs rrzResolutionImpossible.__init__Ys- "D))226::: rr rrrr-r.s@rrMrMXs8rrMceZdZfdZxZS)ResolutionTooDeepcftt||||_dSr)rrRr round_count)rrTrs rrzResolutionTooDeep.__init__`s0 &&// <<<&rrPr.s@rrRrR_s8'''''''''rrRStatez!mapping criteria backtrack_causesc^eZdZdZdZedZdZdZdZ dZ dZ d Z d Z d Zd S) ResolutionzStateful resolution object. This is designed as a one-off object that holds information to kick start the resolution process, and holds the results afterwards. c0||_||_g|_dSr)_p_r_states)rproviderreporters rrzResolution.__init__ps rcX |jdS#t$rtdwxYw)Nstate)r[ IndexErrorAttributeErrorr*s rr`zResolution.stateus= *<# # * * * )) ) *s )c|jd}t|j|j|jdd}|j|dS)zPush a new state into history. This new state will be used to hold resolution results of the next coming round. r_Nmappingcriteriabacktrack_causes)r[rUrecopyrfrgappend)rbaser`s r_push_new_statezResolution._push_new_state|ss |BL%%'']''))!21115    E"""""rc |j|||j|}||}|rt |j}ng}|j|t|tj d||git|tj d||i}|r8t |j }| t||nt||g}tt!|||}|jst%||||<dS)N)r r )requirement_or_candidater)r; identifierr?r;r8)rZadding_requirementrYidentifygetlistr; find_matchesroperator methodcaller attrgetterr:rirr6rr9r) rrfr r rorr;matchesr:s r_add_to_criteriazResolution._add_to_criteriasy ""{6"JJJW%%{%KK LL,,  # $Y%@ A A   " '&&!(%&899k]+ .#$788./'     Hy455K   5k6JJ K K K K1+vFFGK&w//#/   # 4(33 3(rc |j||jjt |jjt jdt |jjt jd|jjS)Nr9r:)ro resolutionsr9r:rg) rYget_preferencer`rerrfrurwrg)rnames r_get_preferencezResolution._get_preferences~w%% *& ##L11( ##M22"Z8&   rc jj|n#t$rYdSwxYwtfd|DS)NFc3PK|] }j|V!dS)r r2NrYis_satisfied_by)r#r$ current_pinrs rr%z8Resolution._is_current_pin_satisfying..sL   G # #[ # I I      r)r`reKeyErrorallr))rr}rrs` @r_is_current_pin_satisfyingz%Resolution._is_current_pin_satisfyings *,T2KK   55      //11      s  %%c|jj}|j|D]}|||||S)Nr2rH)r`rfrhrYget_dependenciesry)rr2rfr s r_get_updated_criteriaz Resolution._get_updated_criterias_:&++--733i3HH K KK  ! !(K ! J J J Jrc.jj|}g}|jD] }n1#t$r$}||jYd}~Bd}~wwxYwtfd|D}|st|j jj |jj |djj |<gcS|S)Nc3PK|] }j|V!dSrr)r#r$r2rs rr%z7Resolution._attempt_to_pin_criterion..sL''A'KKrr)r`rfr9rrrirrr)r0rZpinningupdaterepop)rr}rrOrfe satisfiedr2s` @r_attempt_to_pin_criterionz$Resolution._attempt_to_pin_criterionsPJ'- "-  I 55i@@)    ak*** "3355I B+IyAAA GOOiO 0 0 0 J  & &x 0 0 0 J  " "4 . . .'0DJ t $III s7 A%A  A%ctjdkrӉjd=j}|j\}}d|jD||gfj |fd} |}|rdStjdkdS)aPerform backtracking. When we enter here, the stack is like this:: [ state Z ] [ state Y ] [ state X ] .... earlier states are irrelevant. 1. No pins worked for Z, so it does not have a pin. 2. We want to reset state Y to unpinned, and pin another candidate. 3. State X holds what state Y was before the pin, but does not have the incompatibility information gathered in state Y. Each iteration of the loop will: 1. Discard Z. 2. Discard Y but remember its incompatibility information gathered previously, and the failure we're dealing with right now. 3. Push a new state Y' based on X, and apply the incompatibility information from Y to Y'. 4a. If this causes Y' to conflict, we need to backtrack again. Make Y' the new Z and go back to step 2. 4b. If the incompatibilities apply cleanly, end backtracking. r_c@g|]\}}|t|jfSr)rsr;r#kvs r z)Resolution._backtrack..s<---AqD,--.---rrc D]\}}|s jj|}n#t$rY)wxYwj|t jjt jdt jjt jd||i}t|}|sdS| |j t|t|j|jj|<dS)Nr)r;rnFr8T)r`rfrrYrtrrurvrwrextendr;r6rsr:)rr;rrxr9incompatibilities_from_brokenrs r_patch_criteriaz.Resolution._backtrack.._patch_criteria!s<,I(A(,! !$(J$7$: #!!! !"g22#$%4 J/$12DEE&&+: J/$/0CDD 12++ 3  G"1!9!9J%%$uu%,,Y-HIII-6#-$()>$?$?*;...DJ'** ts ! ..TF) lenr[rrepopitemrfitemsrirZ backtrackingrk)r broken_stater}r2rsuccessrs` @r _backtrackzResolution._backtracks$4$,1$$ R  <++--L*2::<  " " "%o''G to$,1$$zurcjrtdjt t jigg_|D]P} jj |d&#t$r}t|j j d}~wwxYwt|D] }j|fdjj D}|s)jjjcSt'|j}|}|rK} d|Djjdd<| stjjnj|j "t3|) Nzalready resolvedrdrH)indexcFg|]\}}|||Sr)r)r#keyrrs rrz&Resolution.resolve..isC!!!"C66sIFF!!!!r)r`)rc&g|]}|jD]}|SrrE)r#crDs rrz&Resolution.resolve..|s;222q}2223A2222r)rr`)r[ RuntimeErrorrZstartingrU collections OrderedDictryr`rfrrMrr:rkrangestarting_roundrendingminr~rrrg ending_roundrR) rr? max_roundsr$r round_indexunsatisfied_namesr}failure_causesrs ` rresolvezResolution.resolveMsW < 3122 2  #/11!#      D DA D%%dj&91T%JJJJ) D D D*1;+BCCC D  ,,! F! FK G " " " 5 5 5!!!!&*j&9&?&?&A&A!!! % "TZ000z!!!(d.BCCCD!;;DAAN '//++22-222 +AAA. L.tz/JKKKL$$&&& G {$* E E E E +++s"B B* B%%B*N)r rrrrpropertyr`rkryr~rrrrrrrrrWrWis  **X* # # #%)%)%)N        """HWWWr<,<,<,<,<,rrWc2||vrdS||vrdS||D]o} |t|}n#t$rY%wxYw||vr||dSt ||||r||dSpdS)NTF)rIidradd_has_route_to_root)rfrall_keys connectedppkeys rrrs it (u c] & & ( (   BqEE?DD    H  9   MM#   44 hh B B  MM#   44  5sA A  A Resultzmapping graph criteriac|j}d|D}d|td<t}|ddh|jD]\}}t |j||s||vr|||D]X} |t|}n#t$rY%wxYw||vr||| ||Ytfd|D||jS)Nc4i|]\}}t||Sr)rrs r z!_build_result..s$555TQ1q555rc$i|] \}}|v || Srr)r#rrrs rrz!_build_result..s$DDD$!QQ)^^A^^^r)regraphrf) rerrrrrfrrIrconnectr) r`rerrrrrrrs @r _build_resultrsqmG55W]]__555HHRXX OOE IIdOOOI...00 % %Y!%.#xKK   e   IIcNNN&&(( % %A 1    5   $ MM$ $ $ $ $ % DDDD'--//DDD   sC C('C(ceZdZdZeZddZdS)Resolverz3The thing that performs the actual resolution work.dct|j|j}|||}t |S)aTake a collection of constraints, spit out the resolution result. The return value is a representation to the final resolution result. It is a tuple subclass with three public members: * `mapping`: A dict of resolved candidates. Each key is an identifier of a requirement (as returned by the provider's `identify` method), and the value is the resolved candidate. * `graph`: A `DirectedGraph` instance representing the dependency tree. The vertices are keys of `mapping`, and each edge represents *why* a particular package is included. A special vertex `None` is included to represent parents of user-supplied requirements. * `criteria`: A dict of "criteria" that hold detailed information on how edges in the graph are derived. Each key is an identifier of a requirement, and the value is a `Criterion` instance. The following exceptions may be raised if a resolution cannot be found: * `ResolutionImpossible`: A resolution cannot be found for the given combination of requirements. The `causes` attribute of the exception is a list of (requirement, parent), giving the requirements that could not be satisfied. * `ResolutionTooDeep`: The dependency tree is too deeply nested and the resolver gave up. This is usually caused by a circular dependency, but you can try to resolve this by increasing the `max_rounds` argument. )r)rWr\r]rr)rr?r resolutionr`s rrzResolver.resolves=8  t}== ""rsI''''''DDDDDDDDDD0/}h7       .         -    $4$4$4$4$4$4$4$4N     '   ?''''''''  w(KLL`,`,`,`,`,`,`,`,F &  *B C C<#$#$#$#$#$#$#$#$#$#$r