U o a8@sddlZddlmZddlmZedddgZGdd d eZGd d d eZ Gd d d eZ Gddde Z GdddeZ Gddde ZGddde ZeddZGddde ZddZeddZddZGd d!d!eZdS)"N)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__r r aC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_vendor\resolvelib\resolvers.pyr srcs$eZdZfddZddZZS)RequirementsConflictedcstt||||_dSN)superr__init__ criterion)selfr __class__r rrszRequirementsConflicted.__init__cCs dddd|jDS)NzRequirements conflict: {}, css|]}t|VqdSrrepr.0rr r r sz1RequirementsConflicted.__str__..)formatjoinriter_requirementrr r r__str__szRequirementsConflicted.__str__r r r rr" __classcell__r r rrrs rcs$eZdZfddZddZZS)InconsistentCandidatecs"tt|||||_||_dSr)rr%r candidater)rr&rrr rr szInconsistentCandidate.__init__cCs$d|jddd|jDS)Nz+Provided candidate {!r} does not satisfy {}rcss|]}t|VqdSrrrr r rr(sz0InconsistentCandidate.__str__..)rr&rrr r!r r rr"%szInconsistentCandidate.__str__r#r r rrr%s r%c@sLeZdZdZddZddZeddZdd 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||_||_||_dSr candidates informationincompatibilities)rr)r*r+r r rr@szCriterion.__init__cCs ddd|jD}d|S)Nrcss|]\}}d||VqdS)z{!r} from {!r}N)r)rreqrr r rrFsz%Criterion.__repr__..z)rr*r)r requirementsr r r__repr__Es zCriterion.__repr__cCs0||}||t||ggd}|s,t||S)z.Build an instance from a requirement. r()Z find_matchesrr)clsproviderrrr)rr r rfrom_requirementLs  zCriterion.from_requirementcCsdd|jDS)Ncss|] }|jVqdSr)rrir r rr[sz-Criterion.iter_requirement..r*r!r r rr ZszCriterion.iter_requirementcCsdd|jDS)Ncss|] }|jVqdSrrr2r r rr^sz(Criterion.iter_parent..r4r!r r r iter_parent]szCriterion.iter_parentcsVt|j}|t|fdd|jD}t|||t|j}|sRt||S)z>Build a new instance from this and a new requirement. csg|]}|r|qSr )is_satisfied_byrcr0rr r es z)Criterion.merged_with..)listr*appendrr)typer+r)rr0rrinfosr)rr r:r merged_with`s  zCriterion.merged_withcsJt|j}|fdd|jD}|s0dSt||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. csg|]}|kr|qSr r r8r&r rr;vsz)Criterion.excluded_of..N)r<r+r=r)r>r*)rr&Z incompatsr)rr rAr excluded_ofos  zCriterion.excluded_ofN) r r r r rr. classmethodr1r r6r@rBr r r rr',s r'c@s eZdZdS)ResolutionErrorN)r r r r r r rrD}srDcseZdZfddZZS)ResolutionImpossiblecstt||||_dSr)rrErcauses)rrFrr rrszResolutionImpossible.__init__r r r rr$r r rrrEsrEcseZdZfddZZS)ResolutionTooDeepcstt||||_dSr)rrHr round_count)rrIrr rrszResolutionTooDeep.__init__rGr r rrrHsrHStatezmapping criteriac@sdeZdZdZddZeddZddZdd 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|_dSr)_p_r_states)rr0reporterr r rrszResolution.__init__cCs.z |jdWStk r(tdYnXdS)Nstate)rN IndexErrorAttributeErrorr!r r rrQs zResolution.statecCs\z|jd}Wn$tk r2ttid}YnXt|j|jd}|j|dS)zPush a new state into history. This new state will be used to hold resolution results of the next coming round. rP)mappingcriteriaN) rNrRrJ collections OrderedDictrTcopyrUr=)rbaserQr r r_push_new_stateszResolution._push_new_statecCsf|j||j|}z|jj|}Wn$tk rLt|j||}YnX| |j||}||fSr) rMZadding_requirementrLZidentifyrQrUKeyErrorr'r1r@)rrrnamecritr r r_merge_into_criterions  z Resolution._merge_into_criterioncCsF|\}}z|jj|}Wntk r0d}YnX|j||j|jSr)rQrTr[rLZget_preferencer)r*)ritemr\rZpinnedr r r_get_criterion_item_preferences z)Resolution._get_criterion_item_preferencecsDzjj|Wntk r&YdSXtfdd|DS)NFc3s|]}j|VqdSr)rLr7rZ current_pinrr rrsz8Resolution._is_current_pin_satisfying..)rQrTr[allr )rr\rr rar_is_current_pin_satisfyingsz%Resolution._is_current_pin_satisfyingcCs4i}|j|D]}|j||d\}}|||<q|S)Nr5)rLZget_dependenciesr^)rr&rUrr\r]r r r_get_criteria_to_updates  z"Resolution._get_criteria_to_updatec Csg}t|jD]}z||}Wn6tk rV}z||jWYqW5d}~XYnX|j||jj |d||jj |<|jj || ||st||gS|Sr)reversedr)rdrr=rrMZpinningrQrTpoprUupdatercr%)rr\rrFr&rUer r r_attempt_to_pin_criterions     z$Resolution._attempt_to_pin_criterioncCsnt|jdkrj|jd=|jj\}}|j|||jj | |}|dkrZq||jj |<dSdS)NrPTF) lenrNrfrTpopitemrMZ backtrackingrZrQrUrB)rr\r&rr r r _backtracks  zResolution._backtrackc sBjrtd|D]V}zj|dd\}}Wn.tk rb}zt|jjW5d}~XYnX|jj |<qj t |D]}j |j}fddjj D} | sވjd=j |jSt| jd\}} || } | r&} | s&dd| D} t| j ||qt|dS)Nzalready resolvedr5csg|]}j|s|qSr )rc)rr_r!r rr;%s z&Resolution.resolve..rP)keycSsg|]}|jD]}|qqSr r4)rr]r3r r rr;<s)rN RuntimeErrorrZr^rrErr*rQrUrMZstartingrangeZstarting_rounditemsZendingminr`rirmZ ending_roundrH)rr- max_roundsrr\r]rhZ round_indexcurrZunsatisfied_criterion_itemsrZfailure_causesresultrFr r!rresolvesF         zResolution.resolveN)r r r r rpropertyrQrZr^r`rcrdrirmrvr r r rrKs    rKc Cs||kr dS||krdS||D]d}z|t|}Wntk rPYq$YnX||krj||dSt||||r$||dSq$dS)NTF)r6idr[add_has_route_to_root)rUrnall_keys connectedppkeyr r rrzFs    rzResultzmapping graph criteriac s|j}dd|D}d|td<t}|ddh|jD]\}}t|j||s^qD||krp|||D]L}z|t|}Wntk rYqxYnX||kr||| ||qxqDt fdd|D||jdS)NcSsi|]\}}t||qSr )rxrkvr r r ^sz!_build_result..csi|]\}}|kr||qSr r rr|r rrts)rTgraphrU) rTrqrxrryrUrzr6r[connectr)rQrTr{rrnrr}r~r rr _build_result\s0      rc@seZdZdZeZdddZdS)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. )rs)rKr0rOrvr)rr-rs resolutionrQr r rrvszResolver.resolveN)r)r r r r rZbase_exceptionrvr r r rrzsr)rVZ providersrstructsr namedtupler Exceptionrrr%objectr'rDrErHrJrKrzrrrr r r rs(    Q 5