HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_vendor/resolvelib/__pycache__/resolvers.cpython-310.pyc
o

@%Ne�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�B/usr/lib/python3/dist-packages/pip/_vendor/resolvelib/resolvers.pyr
sr
c�$eZdZ�fdd�Zdd�Z�ZS)�RequirementsConflictedc�tt|��|�||_dS�N)�superr�__init__�	criterion)�selfr��	__class__rrr�
zRequirementsConflicted.__init__cCs d�d�dd�|j��D���S)NzRequirements conflict: {}�, cs��|]}t|�VqdSr��repr��.0�rrrr�	<genexpr>��z1RequirementsConflicted.__str__.<locals>.<genexpr>)�format�joinr�iter_requirement�rrrr�__str__s�zRequirementsConflicted.__str__�rrr
rr)�
__classcell__rrrrrsrcr)�InconsistentCandidatecs"tt|��||�||_||_dSr)rr,r�	candidater)rr-rrrrr s
zInconsistentCandidate.__init__cCs$d�|jd�dd�|j��D���S)Nz+Provided candidate {!r} does not satisfy {}rcsrrrr rrrr#(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)rr0r1r2rrrr@�
zCriterion.__init__cCs d�dd�|jD��}d�|�S)Nrcss �|]\}}d�||�VqdS)z({!r}, via={!r})N)r%)r!�reqr	rrrr#Fs
�
�
�z%Criterion.__repr__.<locals>.<genexpr>z
Criterion({}))r&r1r%)r�requirementsrrr�__repr__Es
�
zCriterion.__repr__cC�dd�|jD�S)Ncs��|]}|jVqdSr)r�r!�irrrr#M��z-Criterion.iter_requirement.<locals>.<genexpr>�r1r(rrrr'L�zCriterion.iter_requirementcCr7)Ncsr8r�r	r9rrrr#Pr;z(Criterion.iter_parent.<locals>.<genexpr>r<r(rrr�iter_parentOr=zCriterion.iter_parentN)rrr
rrr6r'r?rrrrr.,sr.c@seZdZdS)�ResolutionErrorN)rrr
rrrrr@Ssr@c�eZdZ�fdd�Z�ZS)�ResolutionImpossiblecrr)rrBr�causes)rrCrrrrXs
zResolutionImpossible.__init__�rrr
rr+rrrrrBW�rBcrA)�ResolutionTooDeepcrr)rrFr�round_count)rrGrrrr_rzResolutionTooDeep.__init__rDrrrrrF^rErF�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�reporterrrrror3zResolution.__init__cCs$z|jdWStytd��w)N����state)rL�
IndexError�AttributeErrorr(rrrrPts
�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.
        rON��mapping�criteria�backtrack_causes)rLrHrT�copyrUrV�append)r�baserPrrr�_push_new_state{s
�zResolution._push_new_statec	Cs�|jj||d�|jj|d�}|�|�}|rt|j�}ng}|jj|t|t	�
d�||gi�t|t	�d�||i�d�}|rJt|j�}|�
t||��nt||�g}tt|�||d�}|js`t|��|||<dS)N)rr	)�requirement_or_candidater'r2��
identifierr5r2r/)rK�adding_requirementrJ�identify�get�listr2�find_matchesr�operator�methodcaller�
attrgetterr1rXrr.rr0r)	rrUrr	r]rr2�matchesr1rrr�_add_to_criteria�s>
���
�zResolution._add_to_criteriac	Cs>|jj||jjt|jjt�d��t|jjt�d��|jjd�S)Nr0r1)r]�resolutionsr0r1rV)	rJ�get_preferencerPrTrrUrcrerV)r�namerrr�_get_preference�s���zResolution._get_preferencecsBz�jj|�Wn
tyYdSwt��fdd�|��D��S)NFc3� �|]}�jj|�d�VqdS�)rr-N�rJ�is_satisfied_byr ��current_pinrrrr#��
��
�z8Resolution._is_current_pin_satisfying.<locals>.<genexpr>)rPrT�KeyError�allr')rrjrrrpr�_is_current_pin_satisfying�s��z%Resolution._is_current_pin_satisfyingcCs4|jj��}|jj|d�D]
}|j|||d�q
|S)N�r-r>)rPrUrWrJ�get_dependenciesrg)rr-rUrrrr�_get_updated_criteria�sz Resolution._get_updated_criteriacs��jj|}g}|jD]V�z����}Wnty,}z|�|j�WYd}~qd}~wwt��fdd�|��D��}|sBt	�|���j
j�d��jj�|��jj
�|d���jj
|<gS|S)Nc3rlrmrnr �r-rrrr#�rrz7Resolution._attempt_to_pin_criterion.<locals>.<genexpr>rv)rPrUr0rxrrXrrtr'r,rK�pinning�updaterT�pop)rrjrrCrU�e�	satisfiedrryr�_attempt_to_pin_criterion�s*
���
z$Resolution._attempt_to_pin_criterioncs�t�j�dkrI�jd=�j��}|j��\}}dd�|j��D����||gf��jj	|d���fdd�}��
�|�}|rBdSt�j�dksd	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.
        �rOcSsg|]\}}|t|j�f�qSr)rar2�r!�k�vrrr�
<listcomp>s��z)Resolution._backtrack.<locals>.<listcomp>rvc	s��D]R\}}|s	qz�jj|}Wn	tyYqw�jj|t�jjt�d��t�jjt�d�||i�d�}t	|�}|s@dS|�
|j�t|t
|j�|d��jj|<qdS)Nr'r2r\Fr/T)rPrUrsrJrbrrcrdrer�extendr2r.rar1)r�r2rrfr0��incompatibilities_from_brokenrrr�_patch_criteria s<�����z.Resolution._backtrack.<locals>._patch_criteriaTF)�lenrLr|rT�popitemrU�itemsrXrK�backtrackingrZ)r�broken_staterjr-r��successrr�r�
_backtrack�s 
��=zResolution._backtrackcsT�jrtd���j��tt��igd�g�_|D] }z�j�jj	|dd�Wqt
y9}zt|jj
��d}~ww���t|�D]c}�jj|d��fdd��jj	��D�}|sg�jj�jd��jSt|�jd�}��|�}|r�d	d�|D�}	�jj|	d
����}
|	�jjdd�<|
s�t�jj��n����jj|�jd�qBt|��)Nzalready resolvedrSr>)�indexcs g|]\}}��||�s|�qSr)ru)r!�keyrr(rrr�hs
��z&Resolution.resolve.<locals>.<listcomp>)rP)r�cSsg|]
}|jD]}|�qqSrr<)r!�cr:rrrr�xs)rC)r�rP)rL�RuntimeErrorrK�startingrH�collections�OrderedDictrgrPrUrrBrr1rZ�range�starting_roundr��ending�minrkr�resolving_conflictsr�rV�ending_roundrF)rr5�
max_roundsr"r}�round_index�unsatisfied_namesrj�failure_causesrCr�rr(r�resolveLsL
����

�

�zResolution.resolveN)rrr
rr�propertyrPrZrgrkrurxrr�r�rrrrrIhs
'
$YrIc	Cs�||vrdS||vrdS||��D]/}z|t|�}Wn	ty%Yqw||vr2|�|�dSt||||�rA|�|�dSqdS)NTF)r?�idrs�add�_has_route_to_root)rUr��all_keys�	connected�p�pkeyrrrr��s$�

�r��Resultzmapping graph criteriac
s�|j}dd�|��D�}d|td�<t�}|�d�dh�|j��D]>\}}t|j||��s/q"||vr8|�|�|��D]#}z|t|�}Wn	tyOYq<w||vrY|�|�|�	||�q<q"t
�fdd�|��D�||jd�S)NcSsi|]	\}}t|�|�qSr)r�r�rrr�
<dictcomp>�sz!_build_result.<locals>.<dictcomp>csi|]\}}|�vr||�qSrrr��r�rrr��s)rT�graphrU)rTr�r�rr�rUr�r?rs�connectr�)rPrTr�r�r�rr�r�rr�r�
_build_result�s4

�
�	�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�)rIrMrNr�r�)rr5r��
resolutionrPrrrr��szResolver.resolveN)r�)rrr
rr
�base_exceptionr�rrrrr��sr�)r�rc�	providersr�structsrrr�
namedtupler�	Exceptionr
rr,�objectr.r@rBrFrHrIr�r�r�r�rrrr�<module>s,�
'%