Current File : //lib/python3.9/site-packages/pip/_vendor/resolvelib/__pycache__/resolvers.cpython-39.pyc
a

[��f�D�@s�ddlZddlZddlmZddlmZmZmZe�dddg�Z	Gdd	�d	e
�ZGd
d�de�ZGdd
�d
e�Z
Gdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Ze�dd�ZGdd�de�Zdd�Ze�dd�Zdd�ZGd d!�d!e�ZdS)"�N�)�AbstractResolver)�
DirectedGraph�IteratorMapping�build_iter_view�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�D/usr/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.pyr

sr
cs$eZdZ�fdd�Zdd�Z�ZS)�RequirementsConflictedcstt|��|�||_dS�N)�superr�__init__�	criterion)�selfr��	__class__rrrszRequirementsConflicted.__init__cCs d�d�dd�|j��D���S)NzRequirements conflict: {}�, css|]}t|�VqdSr��repr��.0�rrrr�	<genexpr>�z1RequirementsConflicted.__str__.<locals>.<genexpr>)�format�joinr�iter_requirement�rrrr�__str__s�zRequirementsConflicted.__str__�rrr
rr%�
__classcell__rrrrrsrcs$eZdZ�fdd�Zdd�Z�ZS)�InconsistentCandidatecs"tt|��||�||_||_dSr)rr(r�	candidater)rr)rrrrr!szInconsistentCandidate.__init__cCs$d�|jd�dd�|j��D���S)Nz+Provided candidate {!r} does not satisfy {}rcss|]}t|�VqdSrrrrrrr)r z0InconsistentCandidate.__str__.<locals>.<genexpr>)r!r)r"rr#r$rrrr%&s�zInconsistentCandidate.__str__r&rrrrr( sr(c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�	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�information�incompatibilities)rr,r-r.rrrrAszCriterion.__init__cCs d�dd�|jD��}d�|�S)Nrcss|]\}}d�||�VqdS)z({!r}, via={!r})N)r!)rZreqr	rrrrGs�z%Criterion.__repr__.<locals>.<genexpr>z
Criterion({}))r"r-r!)r�requirementsrrr�__repr__Fs
�zCriterion.__repr__cCsdd�|jD�S)Ncss|]}|jVqdSr)r�r�irrrrNr z-Criterion.iter_requirement.<locals>.<genexpr>�r-r$rrrr#MszCriterion.iter_requirementcCsdd�|jD�S)Ncss|]}|jVqdSr�r	r1rrrrQr z(Criterion.iter_parent.<locals>.<genexpr>r3r$rrr�iter_parentPszCriterion.iter_parentN)rrr
rrr0r#r5rrrrr*-s
r*c@seZdZdS)�ResolutionErrorN)rrr
rrrrr6Tsr6cseZdZ�fdd�Z�ZS)�ResolutionImpossiblecstt|��|�||_dSr)rr7r�causes)rr8rrrrYszResolutionImpossible.__init__�rrr
rr'rrrrr7Xsr7cseZdZ�fdd�Z�ZS)�ResolutionTooDeepcstt|��|�||_dSr)rr:r�round_count)rr;rrrr`szResolutionTooDeep.__init__r9rrrrr:_sr:�Statez!mapping criteria backtrack_causesc@sdeZdZdZdd�Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�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|_dSr)�_p�_r�_states)r�provider�reporterrrrrpszResolution.__init__cCs,z|jdWSty&td��Yn0dS)N����state)r@�
IndexError�AttributeErrorr$rrrrDuszResolution.statecCs>|jd}t|j��|j��|jdd�d�}|j�|�dS)z�Push a new state into history.

        This new state will be used to hold resolution results of the next
        coming round.
        rCN��mapping�criteria�backtrack_causes)r@r<rH�copyrIrJ�append)r�baserDrrr�_push_new_state|s
�zResolution._push_new_statec	Cs�|jj||d�|jj|d�}|�|�}|r8t|j�}ng}|jj|t|t	�
d�||gi�t|t	�d�||i�d�}|r�t|j�}|�
t||��nt||�g}tt|�||d�}|js�t|��|||<dS)N)rr	)Zrequirement_or_candidater#r.��
identifierr/r.r+)r?Zadding_requirementr>Zidentify�get�listr.�find_matchesr�operator�methodcaller�
attrgetterr-rLrr*rr,r)	rrIrr	rPrr.�matchesr-rrr�_add_to_criteria�s>
���
�zResolution._add_to_criteriac	Cs>|jj||jjt|jjt�d��t|jjt�d��|jjd�S)Nr,r-)rPZresolutionsr,r-rJ)	r>Zget_preferencerDrHrrIrTrVrJ)r�namerrr�_get_preference�s���zResolution._get_preferencecsBz�jj|�Wnty$YdS0t��fdd�|��D��S)NFc3s|]}�jj|�d�VqdS�)rr)N�r>Zis_satisfied_byr�Zcurrent_pinrrrr�s�z8Resolution._is_current_pin_satisfying.<locals>.<genexpr>)rDrH�KeyError�allr#)rrYrrr]r�_is_current_pin_satisfying�s�z%Resolution._is_current_pin_satisfyingcCs4|jj��}|jj|d�D]}|j|||d�q|S)N�r)r4)rDrIrKr>Zget_dependenciesrX)rr)rIrrrr�_get_updated_criteria�sz Resolution._get_updated_criteriacs��jj|}g}|jD]��z����}Wn<tyd}z$|�|j�WYd}~qWYd}~n
d}~00t��fdd�|��D��}|s�t	�|���j
j�d��jj�|��jj
�|d���jj
|<gS|S)Nc3s|]}�jj|�d�VqdSr[r\r�r)rrrr�s�z7Resolution._attempt_to_pin_criterion.<locals>.<genexpr>ra)rDrIr,rbrrLrr_r#r(r?Zpinning�updaterH�pop)rrYrr8rI�eZ	satisfiedrrcr�_attempt_to_pin_criterion�s&
"�
z$Resolution._attempt_to_pin_criterioncs�t�j�dkr��jd=�j��}|j��\}}dd�|j��D����||gf��jj	|d���fdd�}��
�|�}|rdSqd	S)
a�Perform backtracking.

        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.  Discard Z.
        2.  Discard Y but remember its incompatibility information gathered
            previously, and the failure we're dealing with right now.
        3.  Push a new state Y' based on X, and apply the incompatibility
            information from Y to Y'.
        4a. If this causes Y' to conflict, we need to backtrack again. Make Y'
            the new Z and go back to step 2.
        4b. If the incompatibilities apply cleanly, end backtracking.
        �rCcSsg|]\}}|t|j�f�qSr)rRr.�r�k�vrrr�
<listcomp>s�z)Resolution._backtrack.<locals>.<listcomp>rac	s��D]�\}}|sqz�jj|}Wnty8YqYn0�jj|t�jjt�d��t�jjt�d�||i�d�}t	|�}|s�dS|�
|j�t|t
|j�|d��jj|<qdS)Nr#r.rOFr+T)rDrIr^r>rSrrTrUrVr�extendr.r*rRr-)rjr.rrWr,�Zincompatibilities_from_brokenrrr�_patch_criteria!s:
����z.Resolution._backtrack.<locals>._patch_criteriaTF)�lenr@rerH�popitemrI�itemsrLr?ZbacktrackingrN)rZbroken_staterYr)ro�successrrnr�
_backtrack�s
�zResolution._backtrackc
sX�jrtd���j��tt��igd�g�_|D]N}z�j�jj	|dd�Wq2t
y~}zt|jj
��WYd}~q2d}~00q2���t|�D]�}�jj|d��fdd��jj	��D�}|s܈jj�jd��jSt|�jd�}��|�}|�r0���}	d	d�|D��jjdd�<|	�s8t�jj��n����jj|�jd
�q�t|��dS)Nzalready resolvedrGr4)�indexcs g|]\}}��||�s|�qSr)r`)r�keyrr$rrrlis�z&Resolution.resolve.<locals>.<listcomp>)rD)rvcSsg|]}|jD]}|�qqSrr3)r�cr2rrrrl|s)rurD)r@�RuntimeErrorr?Zstartingr<�collections�OrderedDictrXrDrIrr7rr-rN�rangeZstarting_roundrrZending�minrZrgrtrJZending_roundr:)
rr/�
max_roundsrrfZround_indexZunsatisfied_namesrYZfailure_causesrsrr$r�resolveMsF
��$

�

�zResolution.resolveN)rrr
rr�propertyrDrNrXrZr`rbrgrtr~rrrrr=is
'
$Yr=c	Cs�||vrdS||vrdS||��D]b}z|t|�}WntyNYq$Yn0||vrh|�|�dSt||||�r$|�|�dSq$dS)NTF)r5�idr^�add�_has_route_to_root)rIrv�all_keys�	connected�p�pkeyrrrr��s 


r��Resultzmapping graph criteriac
s�|j}dd�|��D�}d|td�<t�}|�d�dh�|j��D]�\}}t|j||��s^qD||vrp|�|�|��D]J}z|t|�}Wnty�YqxYn0||vr�|�|�|�	||�qxqDt
�fdd�|��D�||jd�S)NcSsi|]\}}t|�|�qSr)r�rirrr�
<dictcomp>�r z!_build_result.<locals>.<dictcomp>csi|]\}}|�vr||�qSrrri�r�rrr��r )rH�graphrI)rHrrr�rr�rIr�r5r^Zconnectr�)rDrHr�r�rvrr�r�rr�r�
_build_result�s0



�r�c@seZdZdZeZddd�ZdS)�Resolverz3The 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.
        )r})r=rArBr~r�)rr/r}Z
resolutionrDrrrr~�szResolver.resolveN)r�)rrr
rr
Zbase_exceptionr~rrrrr��sr�)ryrTZ	providersrZstructsrrr�
namedtupler�	Exceptionr
rr(�objectr*r6r7r:r<r=r�r�r�r�rrrr�<module>s*�
'%