3 ”Reª:ã@søddlZddlmZddlmZddlmZejdddgƒZGd d „d e ƒZ Gd d „d e ƒZ Gd d„de ƒZ Gdd„de ƒZGdd„de ƒZGdd„deƒZGdd„deƒZejddƒZGdd„de ƒZdd„ZejddƒZdd „ZGd!d"„d"eƒZdS)#éNé)Úcollections_abc)ÚAbstractResolver)Ú DirectedGraphÚRequirementInformationÚ requirementÚparentc@seZdZdZdS)ÚResolverExceptionzÆA 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__©rrú�/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.pyr sr cs$eZdZ‡fdd„Zdd„Z‡ZS)ÚRequirementsConflictedcstt|ƒj|ƒ||_dS)N)ÚsuperrÚ__init__Ú criterion)Úselfr)Ú __class__rrrszRequirementsConflicted.__init__cCs djdjdd„|jjƒDƒƒƒS)NzRequirements conflict: {}z, css|]}t|ƒVqdS)N)Úrepr)Ú.0Úrrrrú sz1RequirementsConflicted.__str__..)ÚformatÚjoinrÚiter_requirement)rrrrÚ__str__szRequirementsConflicted.__str__)r r r rrÚ __classcell__rr)rrrs rcs$eZdZ‡fdd„Zdd„Z‡ZS)ÚInconsistentCandidatecs"tt|ƒj||ƒ||_||_dS)N)rrrÚ candidater)rr r)rrrr!szInconsistentCandidate.__init__cCs$dj|jdjdd„|jjƒDƒƒƒS)Nz+Provided candidate {!r} does not satisfy {}z, css|]}t|ƒVqdS)N)r)rrrrrr)sz0InconsistentCandidate.__str__..)rr rrr)rrrrr&szInconsistentCandidate.__str__)r r r rrrrr)rrr s rc@sLeZdZdZdd„Zdd„Zedd„ƒZdd „Zd d „Z d d „Z dd„Z dS)Ú 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. cCs||_||_||_dS)N)Ú candidatesÚ informationÚincompatibilities)rr"r#r$rrrrAszCriterion.__init__cCs djdd„|jDƒƒ}dj|ƒS)Nz, css|]\}}dj||ƒVqdS)z({!r}, via={!r})N)r)rÚreqrrrrrHsz%Criterion.__repr__..z Criterion({}))rr#r)rÚ requirementsrrrÚ__repr__Fs zCriterion.__repr__cCsF|j|gƒ}t|tjƒs t|ƒ}||t||ƒggd�}|sBt|ƒ‚|S)z.Build an instance from a requirement. )r"r#r$)Ú find_matchesÚ isinstancerÚSequenceÚlistrr)ÚclsÚproviderrrr"rrrrÚfrom_requirementMs   zCriterion.from_requirementcCsdd„|jDƒS)Ncss|] }|jVqdS)N)r)rÚirrrr^sz-Criterion.iter_requirement..)r#)rrrrr]szCriterion.iter_requirementcCsdd„|jDƒS)Ncss|] }|jVqdS)N)r)rr/rrrrasz(Criterion.iter_parent..)r#)rrrrÚ iter_parent`szCriterion.iter_parentcCsht|jƒ}|jt||ƒƒ|jdd„|Dƒƒ}t|tjƒsBt|ƒ}t|ƒ||t|j ƒƒ}|sdt |ƒ‚|S)z>Build a new instance from this and a new requirement. cSsg|] \}}|‘qSrr)rrÚ_rrrú hsz)Criterion.merged_with..) r+r#Úappendrr(r)rr*Útyper$r)rr-rrÚinfosr"rrrrÚ merged_withcs  zCriterion.merged_withcsJt|jƒ}|jˆƒ‡fdd„|jDƒ}|s0dSt|ƒ|t|jƒ|ƒ}|S)zœBuild a new instance from this, but excluding specified candidate. Returns the new instance, or None if we still have no valid candidates. csg|]}|ˆkr|‘qSrr)rÚc)r rrr2wsz)Criterion.excluded_of..N)r+r$r3r"r4r#)rr Z incompatsr"rr)r rÚ excluded_ofps  zCriterion.excluded_ofN) r r r r rr'Ú classmethodr.rr0r6r8rrrrr!-s  r!c@s eZdZdS)ÚResolutionErrorN)r r r rrrrr:~sr:cseZdZ‡fdd„Z‡ZS)ÚResolutionImpossiblecstt|ƒj|ƒ||_dS)N)rr;rÚcauses)rr<)rrrrƒszResolutionImpossible.__init__)r r r rrrr)rrr;‚sr;cseZdZ‡fdd„Z‡ZS)ÚResolutionTooDeepcstt|ƒj|ƒ||_dS)N)rr=rÚ round_count)rr>)rrrrŠszResolutionTooDeep.__init__)r r r rrrr)rrr=‰sr=ÚStatezmapping criteriac@sdeZdZdZdd„Zedd„ƒZdd„Zdd „Zd d „Z d d „Z dd„Z dd„Z dd„Z dd„ZdS)Ú Resolutionz­Stateful resolution object. This is designed as a one-off object that holds information to kick start the resolution process, and holds the results afterwards. cCs||_||_g|_dS)N)Ú_pÚ_rÚ_states)rr-ÚreporterrrrršszResolution.__init__c Cs,y |jdStk r&tdƒ‚YnXdS)NrÚstateéÿÿÿÿ)rCÚ IndexErrorÚAttributeError)rrrrrEŸs zResolution.statec Cs\y|jd}Wn$tk r2ttjƒid�}YnXt|jjƒ|jjƒd�}|jj|ƒdS)z‰Push a new state into history. This new state will be used to hold resolution results of the next coming round. r)ÚmappingÚcriteriaNrF) rCrGr?Ú collectionsÚ OrderedDictrIÚcopyrJr3)rÚbaserErrrÚ_push_new_state¦szResolution._push_new_statec Csh|jj||ƒ|jj|ƒ}y|jj|}Wn$tk rNtj|j||ƒ}YnX|j |j||ƒ}||fS)N) rBZadding_requirementrAZidentifyrErJÚKeyErrorr!r.r6)rrrÚnameÚcritrrrÚ_merge_into_criterion¶s z Resolution._merge_into_criterionc CsF|\}}y|jj|}Wntk r0d}YnX|jj||j|jƒS)N)rErIrPrAZget_preferencer"r#)rÚitemrQrZpinnedrrrÚ_get_criterion_item_preferenceÁs z)Resolution._get_criterion_item_preferencec sByˆjj|‰Wntk r$dSXt‡‡fdd„|jƒDƒƒS)NFc3s|]}ˆjj|ˆƒVqdS)N)rAÚis_satisfied_by)rr)Ú current_pinrrrrÑsz8Resolution._is_current_pin_satisfying..)rErIrPÚallr)rrQrr)rWrrÚ_is_current_pin_satisfyingËs z%Resolution._is_current_pin_satisfyingcCs8i}x.|jj|ƒD]}|j||d�\}}|||<qW|S)N)r)rAZget_dependenciesrS)rr rJrrQrRrrrÚ_get_criteria_to_updateÕs  z"Resolution._get_criteria_to_updatecsºg}x°|jD]¦‰yˆjˆƒ}Wn0tk rN}z|j|jƒw WYdd}~XnXt‡‡fdd„|jƒDƒƒ}|sztˆ|ƒ‚ˆjj ˆƒˆj j j |dƒˆˆj j |<ˆj j j|ƒgSW|S)Nc3s|]}ˆjj|ˆƒVqdS)N)rArV)rr)r rrrrêsz7Resolution._attempt_to_pin_criterion..)r"rZrr3rrXrrrBZpinningrErIÚpoprJÚupdate)rrQrr<rJÚeZ satisfiedr)r rrÚ_attempt_to_pin_criterionÜs$      z$Resolution._attempt_to_pin_criterionc Csš|jd=xŒt|jƒdkr”|jjƒ}y|jjƒ\}}Wntk rJw YnX|jj|ƒ|jƒ|j j |j |ƒ}|dkr„|jd=q ||j j |<dSWdS)NréTFrFrF) rCÚlenr[rIÚpopitemrPrBZ backtrackingrOrErJr8)rZ prev_staterQr rrrrÚ _backtrackýs    zResolution._backtrackcsFˆjrtdƒ‚ˆjƒx^|D]V}yˆj|dd�\}}Wn.tk rd}zt|jjƒ‚WYdd}~XnX|ˆjj |<qWˆj j ƒx¸t |ƒD]¬}ˆj j |ƒˆjƒˆj}‡fdd„ˆjj jƒDƒ} | sàˆjd=ˆj j|ƒˆjSt| ˆjd�\}} ˆj|| ƒ} | �r(ˆjƒ} | �s(dd„| Dƒ} t| ƒ‚ˆj j||ƒqŠWt|ƒ‚dS) Nzalready resolved)rcsg|]}ˆj|Žs|‘qSr)rY)rrT)rrrr24sz&Resolution.resolve..r)ÚkeycSsg|]}|jD]}|‘qqSr)r#)rrRr/rrrr2KsrF)rCÚ RuntimeErrorrOrSrr;rr#rErJrBZstartingÚrangeZstarting_roundÚitemsZendingÚminrUr^rbZ ending_roundr=)rr&Ú max_roundsrrQrRr]Z round_indexÚcurrZunsatisfied_criterion_itemsrZfailure_causesÚresultr<r)rrÚresolves>      zResolution.resolveN)r r r r rÚpropertyrErOrSrUrYrZr^rbrkrrrrr@“s    !"r@cCsŒ||kr dS||krdSxn||jƒD]^}y|t|ƒ}Wntk rPw&YnX||krh|j|ƒdSt||||ƒr&|j|ƒdSq&WdS)NTF)r0ÚidrPÚaddÚ_has_route_to_root)rJrcÚall_keysÚ connectedÚpÚpkeyrrrroTs   roÚResultzmapping graph criteriac sð|j}dd„|jƒDƒ}d|tdƒ<tƒ}|jdƒdh‰x’|jjƒD]„\}}t|j||ˆƒs`qF||krr|j|ƒxV|jƒD]J}y|t|ƒ}Wntk r¦w|YnX||krº|j|ƒ|j ||ƒq|WqFWt ‡fdd„|jƒDƒ||jd�S)NcSsi|]\}}|t|ƒ“qSr)rm)rÚkÚvrrrú lsz!_build_result..csi|]\}}|ˆkr||“qSrr)rrurv)rqrrrw‚s)rIÚgraphrJ) rIrfrmrrnrJror0rPÚconnectrt)rErIrprxrcrrrrsr)rqrÚ _build_resultjs.    rzc@seZdZdZeZddd„ZdS)ÚResolverz8The thing that performs the actual resolution work. édcCs$t|j|jƒ}|j||d�}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. )rh)r@r-rDrkrz)rr&rhÚ resolutionrErrrrkŽszResolver.resolveN)r|)r r r r r Zbase_exceptionrkrrrrr{ˆsr{)rKÚcompatrZ providersrÚstructsrÚ namedtuplerÚ Exceptionr rrÚobjectr!r:r;r=r?r@rortrzr{rrrrÚs&      Q B