kghP6ddlmZddlZddlZddlZddlmZmZmZm Z m Z ddl m Z m Z mZmZmZmZmZmZmZddlmZmZddlmZdd lmZmZmZmZmZerdd l m!Z!m"Z"dd l#m$Z$ddZ%Gddeee e fZ&Gddeee e fZ'd dZ(dS)!) annotationsN) TYPE_CHECKING CollectionGenericIterableMapping) CTKTRT DirectedGraph IterableViewIteratorMappingRequirementInformationStatebuild_iter_view)AbstractResolverResult) Criterion)InconsistentCandidateRequirementsConflictedResolutionImpossibleResolutionTooDeepResolverException)AbstractProvider Preference) BaseReporterstateState[RT, CT, KT]returnResult[RT, CT, KT]c|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||S)id.0kvs /builddir/build/BUILD/imunify360-venv-2.6.0/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers/resolution.py z!_build_result..$s$%K%K%K41abeeQ%K%K%Kc$i|] \}}|v || Sr%r%)r(r)r* connecteds r+r,z!_build_result..:s$DDD$!QQ)^^A^^^r-)mappinggraphcriteria) r0itemsr&r addr2_has_route_to_root iter_parentKeyErrorconnectr) rr0all_keysr1key criterionppkeyr/s @r+ _build_resultr>"sqmG%K%K7==??%K%K%KHHRXX&3ooE IIdOOO!%I...00 % %Y!%.#xKK   e   IIcNNN&&(( % %A 1    5   $ MM$ $ $ $ $ % DDDD'--//DDD   sC C('C(ceZdZdZd1dZed2d Zd3d Zd4dZd5dZ d6dZ d7dZ d8d Z d9d"Z d:d%Zd;d(Zd 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. providerAbstractProvider[RT, CT, KT]reporterBaseReporter[RT, CT, KT]r!Nonec0||_||_g|_dSN)_p_r_states)selfrArCs r+__init__zResolution.__init__Gs 02 r-r cb |jdS#t$r}td|d}~wwxYw)Nr)rJ IndexErrorAttributeError)rKes r+rzResolution.statePsC 1<# # 1 1 1 ))q 0 1s  .).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. rNNr0r2backtrack_causes)rJrr0copyr2rTappend)rKbasers r+_push_new_statezResolution._push_new_stateWss |BL%%'']''))!21115    E"""""r-r2dict[KT, Criterion[RT, CT]] requirementr parent CT | Nonec |j|||j|}||}|rt |j}ng}|j|t|tj d||git|tj d||i}|r8t |j }| t||nt||g}tt!|||}|jst%||||<dS)N)rZr[)requirement_or_candidateiter_requirementincompatibilities identifier requirementsr` candidates informationr`)rIadding_requirementrHidentifygetlistr` find_matchesroperator methodcaller attrgetterrfrVrrrrer) rKr2rZr[rbr;r`matchesrfs r+_add_to_criteriazResolution._add_to_criteriaes{ ""{6"JJJW%%{%KK LL,,  # $Y%@ A A   " '&&!(%&899k]+ .#$788./'     Hy455K   5k6JJ K K K K1+vFFGK&w//#/   # 4(33 3(r-parentsCollection[KT]csdS|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*|-SrG)r[rHrh)r(rfrqrKs r+ z@Resolution._remove_information_from_criteria..sM##*27++K,>??wNN  ONNr-)r3rrerfr`)rKr2rqr:r;s` ` r+!_remove_information_from_criteriaz,Resolution._remove_information_from_criterias  F&nn..  NC%$'0'<+  HSMM  r-namer rc |j||jjt |jjt jdt |jjt jd|jjS)Nrerf)rb resolutionsrerfrT) rHget_preferencerr0rr2rlrnrT)rKrws r+_get_preferencezResolution._get_preferences~w%% *& ##L11( ##M22"Z8&   r-r;Criterion[RT, CT]boolc jj|n#t$rYdSwxYwtfd|DS)NFc3PK|] }j|V!dS)rZ candidateNrHis_satisfied_by)r(r current_pinrKs r+ z8Resolution._is_current_pin_satisfying..sL   G # #[ # I I      r-)rr0r7allr_)rKrwr;rs` @r+_is_current_pin_satisfyingz%Resolution._is_current_pin_satisfyings *,T2KK   55      //11      s  %%rr c|jj}|j|D]}|||||S)Nrr[)rr2rUrHget_dependenciesrp)rKrr2rZs r+_get_updated_criteriaz Resolution._get_updated_criterias_:&++--733i3HH K KK  ! !(K ! J J J Jr-list[Criterion[RT, CT]]cpjj|}g}|jD] }nQ#t$rD}j|j||jYd}~cd}~wwxYwtfd| D}|st|j jj |jj|djj|<gcS|S)Nc3PK|] }j|V!dSrr)r(rrrKs r+rz7Resolution._attempt_to_pin_criterion..sL''A'KKr-r)rr2rerrrIrejecting_candidater;rVrr_rpinningupdater0pop)rKrwr;causesr2rQ satisfiedrs` @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:BBincompatibilities_from_brokenlist[tuple[KT, list[CT]]]c |D]\}}|s |jj|}n#t$rY)wxYw|j|t |jjt jdt |jjt jd||i}t|}|sdS| |j t|t|j||jj|<dS)Nr_r`raFrdT)rr2r7rHrkrrlrmrnrextendr`rrjrf)rKrr)r`r;rores r+_patch_criteriazResolution._patch_criterias> %B   A $   J/2     g**,J')*<==#2J''(;<<)*## +  G,;7+C+CJ uu  $ $Y%@ A A A%.% !677"3&&&DJ  " " ts   --r$list[RequirementInformation[RT, CT]]ctjd|Dd|D}fd|D}tjdkr7jd=j} j}|j\}}n%#ttf$rt|dwxYw||vrnEfdj |D}| |sn |jsnd |jD}|||gf|} | rdStjdk7d S) 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 |jVdSrGrr(cs r+rz'Resolution._backjump..5s+ > >!)=QX)=)=)=)= > >r-c3$K|] }|jV dSrG)rZrs r+rz'Resolution._backjump..6s$ + +qQ] + + + + + +r-cDh|]}j|Sr%rHrh)r(rrKs r+ z'Resolution._backjump..8s)LLLQTW--a00LLLr-rNTNcDh|]}j|Sr%r)r(drKs r+rz'Resolution._backjump..Ns6(((,-DG$$Q''(((r-c@g|]\}}|t|jfSr%)rjr`r's r+ruz(Resolution._backjump..Zs9---371aD,--.---r-F) itertoolschainlenrJrrr0popitemrOr7rrHr isdisjointr2r3rVrXr) rKrincompatible_reqsincompatible_deps broken_staterwrcurrent_dependenciesrsuccesss ` r+ _backjumpzResolution._backjumps>09 > >v > > > + +F + + +0 0 MLLL:KLLL$,1$$ R  :L A#'<#3#3#5#5L&2&:&B&B&D&DOD))"H-AAA.v66D@A 000((((151I1I)1T1T((($,667HII $+3 6--;G;P;V;V;X;X--- ) * 0 0$ 1D E E E  " " "**+HIIG t[$,1$$fus #5B"B;criteroncXtd|DS)z5Extract causes from list of criterion and deduplicatecBi|]}|jD]}t||Sr%)rfr&)r(ris r+r,z.Resolution._extract_causes..rs/GGG!GGARUUAGGGGr-)rjvalues)rKrs r+_extract_causeszResolution._extract_causesns-GGxGGGNNPPQQQr-rc Iterable[RT] max_roundsintc jrtdjt t jigg_|D]Q} jj |d&#t$r}t|j j |d}~wwxYwt|D]}j|fdjj D}|s)jjjcSt'jj t'|z t+|dkrt-j|jjt5jj t7jdt5jj t7jd jj }n|}|std t+|dkrt=|j }n|d } |} | rr!| } j"| #| } | jjdd<| stjjn_ fdjj D} $jj | j%|jtM|)Nzalready resolvedrSr)indexcFg|]\}}|||Sr%r)r(r:r;rKs r+ruz&Resolution.resolve..sC!!!"C66sIFF!!!!r-)rrrerf) identifiersryrerfrTz-narrow_requirement_selection returned 0 names)r:r)rcNh|]!\}}|v |||"Sr%r)r(r:r;satisfied_namesrKs r+rz%Resolution.resolve..sJ+++&Yo-- ;;CKK.---r-)rr)'rJ RuntimeErrorrIstartingr collections OrderedDictrprr2rrr;rfrXrangestarting_roundr3endingsetkeysrrjrHnarrow_requirement_selectionr0rrlrnrTminr{rrresolving_conflictsrrv ending_roundr)rKrcrrrQ round_indexunsatisfied_namesnarrowed_unstatisfied_namesrwfailure_criterionrrnewly_unsatisfied_namesrs` @r+resolvezResolution.resolvets < 3122 2  #/11!#      K KA K%%dj&91T%JJJJ) K K K*1;+BCCJ K  ,,K FK FK G " " " 5 5 5!!!!&*j&9&?&?&A&A!!! % "TZ000z!!!"$*"5":":"<"<==DU@V@VVO$%%)).2G88$5$(J$6#2 J/$/ ==$$%4 J/$/ >>%%*.)D9  //++ /@+/ T"#RSSS.//!336D >t D D   '--.?@@++6+:::..0017 +AAA.L.tz/JKKKL +++++*.**=*C*C*E*E+++' 66J')@$$&&& G {$* E E E E +++s "B B, B''B,N)rArBrCrDr!rE)r!r )r!rE)r2rYrZr r[r\r!rE)r2rYrqrrr!rE)rwr r!r)rwr r;r|r!r})rr r!rY)rwr r!r)rrr!r})rrr!r})rrr!r)rcrrrr!r )__name__ __module__ __qualname____doc__rLpropertyrrXrprvr{rrrrrrrr%r-r+r@r@@s@ 3333111X1 # # # #*)*)*)*)X6           ####J!!!!FWWWWrRRRR f,f,f,f,f,f,r-r@c"eZdZdZeZ d d d Zd S) Resolverz3The thing that performs the actual resolution work.drcrrrr!r"ct|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)r@rArCrr>)rKrcr resolutionrs r+rzResolver.resolves>@  t}== ""r@rr5r%r-r+rs""""""HHHHHHHHHHHHHH                      /....... )88888888((((((