hPddlZddlZddlZddlmZddlmZmZmZej dddgZ Gdd e Z Gd d e Z Gd d e ZGddeZGdde ZGddeZGddeZej ddZGddeZdZej ddZdZGddeZdS) 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/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/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 dSrr r#is rr%z-Criterion.iter_requirement..Ns$88! 888888rr:r*s rr)zCriterion.iter_requirementMs88t'78888rc$d|jDS)Nc3$K|] }|jV dSrr rDs rr%z(Criterion.iter_parent..Qs$33Q333333rrFr*s r iter_parentzCriterion.iter_parentPs33$"23333rN)r rrrrr@r)rJrrrr6r6-sZ&333 44499944444rr6ceZdZdS)ResolutionErrorN)r rrrrrrLrLTsDrrLceZdZfdZxZS)ResolutionImpossiblecftt||||_dSr)rrNrcauses)rrPrs rrzResolutionImpossible.__init__Ys- "D))226::: rr rrrr-r.s@rrNrNXs8rrNceZdZfdZxZS)ResolutionTooDeepcftt||||_dSr)rrSr round_count)rrUrs rrzResolutionTooDeep.__init__`s0 &&// <<<&rrQr.s@rrSrS_s8'''''''''rrSStatez!mapping criteria backtrack_causescdeZdZdZdZedZdZdZdZ dZ dZ d Z d Z d Zd 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 rrazResolution.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\rVrfcopyrgrhappend)rbaseras 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)r[adding_requirementrZidentifygetlistr; find_matchesroperator methodcaller attrgetterr:rjrr6rr9r) rrgr r rprr;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(rcsdS|D]5\}}t|jfd|jD|j||<6dS)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. Ncdg|],}|j!j|jv*|-Sr)r rZrr)r#r:parentsrs r z@Resolution._remove_information_from_criteria..sM##*27++K,>??wNN  ONNr)itemsr6r9r:r;)rrgr}keyrs` ` r!_remove_information_from_criteriaz,Resolution._remove_information_from_criterias  F&nn..  NC%$'0'<+  HSMM  rc |j||jjt |jjt jdt |jjt jd|jjS)Nr9r:)rp resolutionsr9r:rh) rZget_preferencerarfrrgrvrxrh)rnames r_get_preferencezResolution._get_preferences~w%% *& ##L11( ##M22"Z8&   rc jj|n#t$rYdSwxYwtfd|DS)NFc3PK|] }j|V!dS)r r2NrZis_satisfied_by)r#r$ current_pinrs rr%z8Resolution._is_current_pin_satisfying..sL   G # #[ # I I      r)rarfKeyErrorallr))rrrrs` @r_is_current_pin_satisfyingz%Resolution._is_current_pin_satisfyings *,T2KK   55      //11      s  %%c|jj}|j|D]}|||||S)Nr2rI)rargrirZget_dependenciesrz)rr2rgr s r_get_updated_criteriaz Resolution._get_updated_criterias_:&++--733i3HH K KK  ! !(K ! J J J Jrcpjj|}g}|jD] }nQ#t$rD}j|j||jYd}~cd}~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)rargr9rrr[rejecting_candidaterrjrr)r0pinningupdaterfpop)rrrrPrge satisfiedr2s` @r_attempt_to_pin_criterionz$Resolution._attempt_to_pin_criterionsjJ'- "-  I 55i@@)   ++AKCCC ak*** "3355I B+IyAAA GOOiO 0 0 0 J  & &x 0 0 0 J  " "4 . . .'0DJ t $III s8 B:BBc tjd|Dd|D}fd|D}tjdkr!jd=d}|s j}|j\}}n$#ttf$rt|wxYwfdj |D}| | }|d|j D ||gf fd } | } | rd Stjdk!dS) 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. c32K|]}|j |jVdSrrIr#cs rr%z'Resolution._backjump...s+ > >!)=QX)=)=)=)= > >rc3$K|] }|jV dSrrCrs rr%z'Resolution._backjump../s$ + +qQ] + + + + + +rcDh|]}j|SrrZrr)r#r$rs r z'Resolution._backjump..1s)LLLQTW--a00LLLrr`FcDh|]}j|Srr)r#drs rrz'Resolution._backjump..?s9(((G$$Q''(((rc@g|]\}}|t|jfSr)rtr;r#kvs rr~z(Resolution._backjump..Gs<---AqD,--.---rc D]\}}|s jj|}n#t$rY)wxYwj|t jjt jdt jjt jd||i}t|}|sdS| |j t|t|j|jj|<dS)Nr)r;roFr8T)rargrrZrurrvrwrxrextendr;r6rtr:)rr;rryr9incompatibilities_from_brokenrs r_patch_criteriaz-Resolution._backjump.._patch_criteriaQs<,I(A(,! !$(J$7$: #!!! !"g22#$%4 J/$12DEE&&+: J/$/0CDD 12++ 3  G"1!9!9J%%$uu%,,Y-HIII-6#-$()>$?$?*;...DJ'** ts ! ..T) itertoolschainlenr\rrfpopitemrbrrNrZr isdisjointrgrrjrl) rrPincompatible_reqsincompatible_depsincompatible_state broken_staterr2current_dependenciesrsuccessrs ` @r _backjumpzResolution._backjumps>&O > >v > > > + +F + + +  MLLL:KLLL$,1$$ R "' ( 7#'<#3#3#5#5L&2&:&B&B&D&DOD))"H-777.v6667((((!W55i@@((($*>)H)H%**&") --(17799--- ) * 0 0$ 1D E E E      >  " " "%o''G tG$,1$$Rus 5B!B7cL jrtdjt t jigg_|D]P} jj |d&#t$r}t|j j d}~wwxYwt|D]}j|fdjj D}|s)jjjcSt'jj t'|z t+|j}|}|rid|D} j| | } | jjdd<| stjjn_ fd jj D} jj | j|j t;|) Nzalready resolvedrerI)indexcFg|]\}}|||Srr)r#rrrs rr~z&Resolution.resolve..sC!!!"C66sIFF!!!!r)ra)rc&g|]}|jD]}|SrrF)r#rrEs rr~z&Resolution.resolve..s'KKKQ]KK!KKKKr)rPcNh|]!\}}|v |||"Srr)r#rrsatisfied_namesrs rrz%Resolution.resolve..sJ+++&Yo-- ;;CKK.---r)rra)r\ RuntimeErrorr[startingrV collections OrderedDictrzrargrrNrr:rlrangestarting_roundrendingsetkeysminrrresolving_conflictsrrhr ending_roundrS) rr? max_roundsr$r round_indexunsatisfied_namesrfailure_causesrPrnewly_unsatisfied_namesrs ` @rresolvezResolution.resolve}s < 3122 2  #/11!#      D DA D%%dj&91T%JJJJ) D D D*1;+BCCC D  ,,1 F1 FK G " " " 5 5 5!!!!&*j&9&?&?&A&A!!! % "TZ000z!!!"$*"5":":"<"<==!AAO (d.BCCCD!;;DAAN 'KK^KKK++6+:::..0017 +AAA.L.tz/JKKKL +++++*.**=*C*C*E*E+++' 66J')@$$&&& G {$* E E E E +++s "B B+ B&&B+N)r rrrrpropertyrarlrzrrrrrrrrrrrXrXis  **X* # # #%)%)%)N2        ###Jmmm^L,L,L,L,L,rrXc2||vrdS||vrdS||D]o} |t|}n#t$rY%wxYw||vr||dSt ||||r||dSpdS)NTF)rJidradd_has_route_to_root)rgrall_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)rfgraphrg) rfrrrrrgrrJrconnectr) rarfrrrrrrrs @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)rXr]r^rr)rr?r resolutionras rrzResolver.resolves=8  t}== ""rsS''''''DDDDDDDDDD//}h7       .         -    $4$4$4$4$4$4$4$4N     '   ?''''''''  w(KLL`,`,`,`,`,`,`,`,F &  *B C C<#$#$#$#$#$#$#$#$#$#$r