Re:@sZddlZddlmZddlmZddlmZejdddgZGd d d e Z Gd d d e Z Gd dde Z Gddde ZGddde ZGdddeZGdddeZejddZGddde ZddZejddZdd ZGd!d"d"eZdS)#N)collections_abc)AbstractResolver) DirectedGraphRequirementInformation requirementparentc@seZdZdZdS)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__rr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/resolvelib/resolvers.pyr s r cs.eZdZfddZddZS)RequirementsConflictedcs#tt|j|||_dS)N)superr__init__ criterion)selfr) __class__rrrszRequirementsConflicted.__init__cCs,djdjdd|jjDS)NzRequirements conflict: {}z, css|]}t|VqdS)N)repr).0rrrr sz1RequirementsConflicted.__str__..)formatjoinriter_requirement)rrrr__str__szRequirementsConflicted.__str__)r r r rrrr)rrrs rcs.eZdZfddZddZS)InconsistentCandidatecs/tt|j||||_||_dS)N)rrr candidater)rrr)rrrr!s zInconsistentCandidate.__init__cCs2dj|jdjdd|jjDS)Nz+Provided candidate {!r} does not satisfy {}z, css|]}t|VqdS)N)r)rrrrrr)sz0InconsistentCandidate.__str__..)rrrrr)rrrrr&szInconsistentCandidate.__str__)r r r rrrr)rrr s rc@speZdZdZddZddZeddZdd Zd d Z d d Z ddZ 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 informationincompatibilities)rr!r"r#rrrrAs  zCriterion.__init__cCs,djdd|jD}dj|S)Nz, css'|]\}}dj||VqdS)z({!r}, via={!r})N)r)rreqrrrrrHsz%Criterion.__repr__..z Criterion({}))rr"r)r requirementsrrr__repr__Fs zCriterion.__repr__cCsm|j|g}t|tjs0t|}|d|dt||gdg}|sit||S)z.Build an instance from a requirement. r!r"r#) find_matches isinstancerSequencelistrr)clsproviderrrr!rrrrfrom_requirementMs   zCriterion.from_requirementcCsdd|jDS)Ncss|]}|jVqdS)N)r)rirrrr^sz-Criterion.iter_requirement..)r")rrrrr]szCriterion.iter_requirementcCsdd|jDS)Ncss|]}|jVqdS)N)r)rr.rrrrasz(Criterion.iter_parent..)r")rrrr iter_parent`szCriterion.iter_parentcCst|j}|jt|||jdd|D}t|tjs_t|}t|||t|j }|st ||S)z>Build a new instance from this and a new requirement. cSsg|]\}}|qSrr)rr_rrr hs z)Criterion.merged_with..) r*r"appendrr'r(rr)typer#r)rr,rrinfosr!rrrr merged_withcs ! zCriterion.merged_withcsgt|j}|jfdd|jD}|sBdSt||t|j|}|S)zBuild a new instance from this, but excluding specified candidate. Returns the new instance, or None if we still have no valid candidates. cs"g|]}|kr|qSrr)rc)rrrr1ws z)Criterion.excluded_of..N)r*r#r2r!r3r")rrZ incompatsr!rr)rr excluded_ofps !zCriterion.excluded_ofN) r r r r rr& classmethodr-rr/r5r7rrrrr -s      r c@seZdZdS)ResolutionErrorN)r r r rrrrr9~s r9cs"eZdZfddZS)ResolutionImpossiblecs#tt|j|||_dS)N)rr:rcauses)rr;)rrrrszResolutionImpossible.__init__)r r r rrr)rrr:s r:cs"eZdZfddZS)ResolutionTooDeepcs#tt|j|||_dS)N)rr<r round_count)rr=)rrrrszResolutionTooDeep.__init__)r r r rrr)rrr<s r<Statezmapping criteriac@seZdZdZddZeddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZdS) 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. cCs||_||_g|_dS)N)_p_r_states)rr,reporterrrrrs  zResolution.__init__c Cs4y|jdSWntk r/tdYnXdS)Nrstate)rB IndexErrorAttributeError)rrrrrDs zResolution.statec Cs|y|jd}Wn-tk r@tdtjdi}Yn(Xtd|jjd|jj}|jj|dS)zPush a new state into history. This new state will be used to hold resolution results of the next coming round. rmappingcriteriaNrE) rBrFr> collections OrderedDictrHcopyrIr2)rbaserDrrr_push_new_states  !zResolution._push_new_statec Cs|jj|||jj|}y|jj|}Wn*tk retj|j||}YnX|j |j||}||fS)N) rAZadding_requirementr@ZidentifyrDrIKeyErrorr r-r5)rrrnamecritrrr_merge_into_criterions z Resolution._merge_into_criterionc CsW|\}}y|jj|}Wntk r:d}YnX|jj||j|jS)N)rDrHrOr@Zget_preferencer!r")ritemrPrZpinnedrrr_get_criterion_item_preferences    z)Resolution._get_criterion_item_preferencec sSyjj|Wntk r,dSYnXtfdd|jDS)NFc3s$|]}jj|VqdS)N)r@is_satisfied_by)rr) current_pinrrrrsz8Resolution._is_current_pin_satisfying..)rDrHrOallr)rrPrr)rVrr_is_current_pin_satisfyings  z%Resolution._is_current_pin_satisfyingcCsLi}x?|jj|D]+}|j|d|\}}|||.)r!rYrr2rrWrrrAZpinningrDrHpoprIupdate)rrPrr;rIeZ satisfiedr)rrr_attempt_to_pin_criterions$z$Resolution._attempt_to_pin_criterionc Cs|jd=xt|jdkr|jj}y|jj\}}Wntk raw YnX|jj||j|j j |j |}|dkr|jd=q ||j j |.rkeycSs&g|]}|jD] }|qqSr)r")rrQr.rrrr1Ks rE)rB RuntimeErrorrNrRrr:rr"rDrIrAZstartingrangeZstarting_rounditemsZendingminrTr]raZ ending_roundr<)rr% max_roundsrrPrQr\Z round_indexcurrZunsatisfied_criterion_itemsrZfailure_causesresultr;r)rrresolves>    %      zResolution.resolveN)r r r r rpropertyrDrNrRrTrXrYr]rarjrrrrr?s     ! "r?cCs||krdS||kr dSx||jD]u}y|t|}Wntk rbw1YnX||kr|j|dSt||||r1|j|dSq1WdS)NTF)r/idrOadd_has_route_to_root)rIrball_keys connectedppkeyrrrrnTs       rnResultzmapping graph criteriac sF|j}dd|jD}d|tdls z!_build_result..rHcs+i|]!\}}|kr||qSrr)rrtru)rprrrvs graphrI) rHrerlrrmrIrnr/rOconnectrs)rDrHrorwrbrrqrrr)rpr _build_resultjs.         ryc@s+eZdZdZeZdddZdS)Resolverz8The thing that performs the actual resolution work. dcCs4t|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. rg)r?r,rCrjry)rr%rg resolutionrDrrrrjszResolver.resolveN)r r r r r Zbase_exceptionrjrrrrrzs rz)rJcompatrZ providersrstructsr namedtupler Exceptionr rrobjectr r9r:r<r>r?rnrsryrzrrrrs$   Q