\hPddlZddlZddlZddlmZddlmZmZmZejdddgZ Gdd e Z Gd d e Z Gd d e ZGddeZGdde ZGddeZGddeZejddZGddeZdZejddZdZGddeZy) N)AbstractResolver) DirectedGraphIteratorMappingbuild_iter_viewRequirementInformation requirementparentceZdZdZy)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__c/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.pyr r srr c$eZdZfdZdZxZS)RequirementsConflictedc:tt| |||_yN)superr__init__ criterion)selfr __class__s rrzRequirementsConflicted.__init__s $d4Y?"rcdjdjd|jjDS)NzRequirements conflict: {}, c32K|]}t|ywrrepr.0rs r z1RequirementsConflicted.__str__..I!d1gI)formatjoinriter_requirementrs r__str__zRequirementsConflicted.__str__s4*11 IIIt~~'F'F'HI I  rr rrrr, __classcell__rs@rrrs # rrc$eZdZfdZdZxZS)InconsistentCandidatecJtt| ||||_||_yr)rr1r candidater)rr3rrs rrzInconsistentCandidate.__init__!s# #T3IyI""rcdj|jdjd|jj DS)Nz+Provided candidate {!r} does not satisfy {}rc32K|]}t|ywrr r"s rr%z0InconsistentCandidate.__str__..)r&r')r(r3r)rr*r+s rr,zInconsistentCandidate.__str__&s;<CC NN IIIt~~'F'F'HI I  rr-r/s@rr1r1 s #  rr1c(eZdZdZdZdZdZdZy) 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. c.||_||_||_yr candidates informationincompatibilities)rr:r;r<s rrzCriterion.__init__As$&!2rchdjd|jD}dj|S)Nrc3FK|]\}}dj||yw)z({!r}, via={!r})N)r()r#reqr s rr%z%Criterion.__repr__..Gs)! V  % %c6 2! s!z Criterion({}))r)r;r()r requirementss r__repr__zCriterion.__repr__Fs6yy! #//!  %%l33rc(d|jDS)Nc34K|]}|jywrr r#is rr%z-Criterion.iter_requirement..Ns8! 8r;r+s rr*zCriterion.iter_requirementMs8t'7'788rc(d|jDS)Nc34K|]}|jywrr rEs rr%z(Criterion.iter_parent..Qs3Q3rGrHr+s r iter_parentzCriterion.iter_parentPs3$"2"233rN)r rrrrrAr*rLrrrr7r7-s&3 494rr7c eZdZy)ResolutionErrorN)r rrrrrrNrNTsrrNceZdZfdZxZS)ResolutionImpossiblec:tt| |||_yr)rrPrcauses)rrRrs rrzResolutionImpossible.__init__Ys "D26: rr rrrr.r/s@rrPrPXs rrPceZdZfdZxZS)ResolutionTooDeepc:tt| |||_yr)rrUr round_count)rrWrs rrzResolutionTooDeep.__init__`s / <&rrSr/s@rrUrU_s ''rrUStatez!mapping criteria backtrack_causesc\eZdZdZdZedZdZdZdZ dZ dZ d Z d Z d Zd Zy ) 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. c.||_||_g|_yr)_p_r_states)rproviderreporters rrzResolution.__init__ps rcR |jdS#t$r tdwxYw)Nstate)r^ IndexErrorAttributeErrorr+s rrczResolution.stateus0 *<<# # * ) ) *s&c|jd}t|jj|jj|j dd}|jj |y)zPush a new state into history. This new state will be used to hold resolution results of the next coming round. rbNmappingcriteriabacktrack_causes)r^rXrhcopyrirjappend)rbasercs r_push_new_statezResolution._push_new_state|s^ ||BLL%%']]'')!2215  E"rc p|jj|||jj|}|j |}|rt |j }ng}|jj|t|tjd||git|tjd||i}|r1t |j}|jt||n t||g}tt!|||}|j"s t%||||<y)N)r r )requirement_or_candidater*r< identifierr@r<r9)r]adding_requirementr\identifygetlistr< find_matchesroperator methodcaller attrgetterr;rlrr7rr:r) rrir r rrrr<matchesr;s r_add_to_criteriazResolution._add_to_criterias/ ""{6"JWW%%{%K LL,  $Y%@%@ A  " ''&&!(%%&89k]+ .##$78./'   y445K   5k6J K1+vFGK&w/#/ ##(3 3(rc "|sy|jD]t\}}t|j|jDcgc]7}|j'|j j |j|vr|9c}|j||<vycc}w)aWRemove information from parents of criteria. Concretely, removes all values from each criterion's ``information`` field that have one of ``parents`` as provider of the requirement. :param criteria: The criteria to update. :param parents: Identifiers for which to remove information from all criteria. N)itemsr7r:r;r r\rtr<)rriparentskeyrr;s r!_remove_information_from_criteriaz,Resolution._remove_information_from_criterias &nn. NC%$$(1'<'<##**277++K,>,>?wN  ++ HSM s.s-  GG # #[ # I '*)rcrhKeyErrorallr*)rrrrs` @r_is_current_pin_satisfyingz%Resolution._is_current_pin_satisfyingsU **,,T2K //1     sA A  A c|jjj}|jj |D]}|j ||||S)Nr3rK)rcrirkr\get_dependenciesr|)rr3rir s r_get_updated_criteriaz Resolution._get_updated_criteriasW::&&++-7733i3H KK  ! !(K ! J Krcjj|}g}|jD] j}tfd|jD}|s t|j jjjj|jjj|djj|<gcS|S#t$rL}j j |j|j|jYd}~d}~wwxYw)Nc3XK|]!}jj|#ywrr)r#r$r3rs rr%z7Resolution._attempt_to_pin_criterion..s-''A'Krr)rcrir:rrr]rejecting_candidaterrlrr*r1pinningupdaterhpop)rrrrRrie satisfiedr3s` @r_attempt_to_pin_criterionz$Resolution._attempt_to_pin_criterionsJJ''- "-- I 55i@"335I+IyAA GGOOiO 0 JJ   & &x 0 JJ   " "4 .'0DJJ  t $I7 > 9* ++AKKC akk* sC77 E AEE ctjd|Dd|D}|Dchc]}jj|}}t j dk\r/j d=d}|s j j }|jj\}}jj|D chc]} jj| } } | j| }|sjjD cgc]\} } | t!| j"fc} } j%gffd} j'| }|ryt j dk\r/ycc}w#ttf$r t|wxYwcc} wcc} } w)a2Perform backjumping. 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. Identify Z. The incompatibility is not always caused by the latest state. For example, given three requirements A, B and C, with dependencies A1, B1 and C1, where A1 and B1 are incompatible: the last state might be related to C, so we want to discard the previous state. 2. Discard Z. 3. Discard Y but remember its incompatibility information gathered previously, and the failure we're dealing with right now. 4. Push a new state Y' based on X, and apply the incompatibility information from Y to Y'. 5a. If this causes Y' to conflict, we need to backtrack again. Make Y' the new Z and go back to step 2. 5b. If the incompatibilities apply cleanly, end backtracking. c3NK|]}|j|jywrrKr#cs rr%z'Resolution._backjump...s >!)=QXX >s%%c34K|]}|jywrrDrs rr%z'Resolution._backjump../s +qQ]] +rGrbFc BD]\}}|s jj|}jj |t jjt jdt jjt jd||i}t|}|sy|j|jt|t|j|jj|< y#t$rYwxYw)Nr*r<rqFr9T)rcrirr\rwrrxryrzrextendr<r7rvr;)kr<rr{r:incompatibilities_from_brokenrs r_patch_criteriaz-Resolution._backjump.._patch_criteriaQs,I(A(, !$(JJ$7$7$: #gg22#$%4 JJ//$112DE&+: JJ//$//0CD 12+ 3 G"1!9J%$%,,Y-H-HI-6#-$()>)>$?*;.DJJ''*/8/$! !sD DDT) itertoolschainr\rtlenr^rrhpopitemrdrrPr isdisjointrir~rvr<rlrn)rrRincompatible_reqsr$incompatible_depsincompatible_state broken_staterr3dcurrent_dependenciesrvrsuccessrs` @r _backjumpzResolution._backjumps>&OO >v > +F + ;LLQTWW--a0LL$,,1$ R "' (7#'<<#3#3#5L&2&:&:&B&B&DOD) "WW55i@(GG$$Q'($(*>)H)H%*&")")11779-AqD,,-.- ) * 0 0$ 1D E >  "%'GG$,,1$RUM#H-7.v667(-s"F:7F"F;$!GF8c L|jr td|jjt t j igg|_|D]+} |j|jj|d-|jt|D]2}|jj!||jjj#Dcgc]\}}|j%||s|}}}|s4|jj'|j|jcSt)|jjj+t)|z } t-||j.} |j1| } | r| D cgc]} | jD]} | }} } |jj3||j5|}||jj6dd|st|jj6|jjj#Dchc]\}}|| vr|j%||s|}}}|j9|jj||j|jj;||j5t=|#t$r$}t|jjd}~wwxYwcc}}wcc} } wcc}}w) Nzalready resolvedrgrK)index)rc)r)rR)rrc)r^ RuntimeErrorr]startingrX collections OrderedDictr|rcrirrPrr;rnrangestarting_roundr~rendingsetkeysminrrresolving_conflictsrrjr ending_roundrU)rr@ max_roundsr$r round_indexrrunsatisfied_namessatisfied_namesrfailure_causesrrFrRrnewly_unsatisfied_namess rresolvezResolution.resolve}s <<12 2  #//1!#    DA D%%djj&9&91T%J D  ,1 FK GG " " " 5'+jj&9&9&?&?&A!"C66sIF! !%TZZ0zz!"$**"5"5":":"<=!AO (d.B.BCD!;;DAN%3KQ]]K!K!KK++6+:..017 ++A..tzz/J/JKK +/***=*=*C*C*E+&Yo- ;;CK+'+ 66JJ'')@$$& GG {$** Ec1 Ff ++w* D*1;;+B+BCC D!*L+s*(K$*L)L"L $ L-L  LN)r rrrrpropertyrcrnr|rrrrrrrrrrrZrZisR  ** #%)N2    #Jm^L,rrZc||vry||vry||jD]I} |t|}||vr|j|yt ||||s8|j|yy#t$rYXwxYw)NTF)rLidradd_has_route_to_root)rirall_keys connectedppkeys rrrs i ( c] & & (  BqE?D 9  MM#  hh B MM#      sA++ A76A7Resultzmapping graph criteriac|j}|jDcic]\}}t||}}}d|td<t}|j ddh}|j jD]~\}}t |j |||s||vr|j ||jD]8} |t| } | |vr|j | |j| |:t|jDcic] \}}||vs ||c}}||j Scc}}w#t$rYwxYwcc}}w)N)rhgraphri) rhr~rrrrirrLrconnectr) rcrhrrrrrrrrrs r _build_resultrsEmmG%,]]_5TQ1q5H5HRX OE IIdOI....0 %Y!%..#xK  e  IIcN&&( %A 15  $ MM$ $ % % ")--/D$!QQ)^AD +6  Es#D?E E %E  EEceZdZdZeZddZy)Resolverz3The thing that performs the actual resolution work.c~t|j|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)rZr_r`rr)rr@r resolutionrcs rrzResolver.resolves88  t}}= ""rs'DD///}h7   .   -  $4$4N ' ?''  w(KL`,`,F &   *B C<#$#$r