Current File : //usr/lib/python3/dist-packages/pip/_vendor/resolvelib/__pycache__/resolvers.cpython-312.pyc
�

/�gP���ddlZddlZddlZddlmZddlmZmZmZejdddg�Z
Gd�d	e�ZGd
�de�Z
Gd�d
e�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Zejdd�ZGd�de�Zd�Zejdd�Zd�ZGd�de�Zy) �N�)�AbstractResolver)�
DirectedGraph�IteratorMapping�build_iter_view�RequirementInformation�requirement�parentc��eZdZdZy)�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__���B/usr/lib/python3/dist-packages/pip/_vendor/resolvelib/resolvers.pyrr
s��rrc�$��eZdZ�fd�Zd�Z�xZS)�RequirementsConflictedc�:��tt|�|�||_y�N)�superr�__init__�	criterion)�selfr�	__class__s  �rrzRequirementsConflicted.__init__s���
�$�d�4�Y�?�"��rc��djdjd�|jj�D���S)NzRequirements conflict: {}�, c3�2K�|]}t|����y�wr��repr��.0�rs  r�	<genexpr>z1RequirementsConflicted.__str__.<locals>.<genexpr>�����I�!�d�1�g�I���)�format�joinr�iter_requirement�rs r�__str__zRequirementsConflicted.__str__s4��*�1�1��I�I�I�t�~�~�'F�'F�'H�I�I�
�	
r�r
rrrr,�
__classcell__�rs@rrrs
���#�
rrc�$��eZdZ�fd�Zd�Z�xZS)�InconsistentCandidatec�J��tt|�||�||_||_yr)rr1r�	candidater)rr3rrs   �rrzInconsistentCandidate.__init__!s#���
�#�T�3�I�y�I�"���"��rc��dj|jdjd�|jj	�D���S)Nz+Provided candidate {!r} does not satisfy {}rc3�2K�|]}t|����y�wrr r"s  rr%z0InconsistentCandidate.__str__.<locals>.<genexpr>)r&r')r(r3r)rr*r+s rr,zInconsistentCandidate.__str__&s;��<�C�C��N�N��I�I�I�t�~�~�'F�'F�'H�I�I�
�	
rr-r/s@rr1r1 s
���#�

rr1c�(�eZdZdZd�Zd�Zd�Zd�Zy)�	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.
    c�.�||_||_||_yr��
candidates�information�incompatibilities)rr:r;r<s    rrzCriterion.__init__As��$���&���!2��rc�h�djd�|jD��}dj|�S)Nrc3�FK�|]\}}dj||����y�w)z({!r}, via={!r})N)r()r#�reqr
s   rr%z%Criterion.__repr__.<locals>.<genexpr>Gs)����!
���V�
�%�%�c�6�2�!
�s�!z
Criterion({}))r)r;r()r�requirementss  r�__repr__zCriterion.__repr__Fs6���y�y�!
�#�/�/�!
�
���%�%�l�3�3rc�(�d�|jD�S)Nc3�4K�|]}|j���y�wr�r	�r#�is  rr%z-Criterion.iter_requirement.<locals>.<genexpr>Ns����8�!��
�
�8����r;r+s rr*zCriterion.iter_requirementMs��8�t�'7�'7�8�8rc�(�d�|jD�S)Nc3�4K�|]}|j���y�wr�r
rEs  rr%z(Criterion.iter_parent.<locals>.<genexpr>Qs����3�Q����3�rGrHr+s r�iter_parentzCriterion.iter_parentPs��3�$�"2�"2�3�3rN)r
rrrrrAr*rLrrrr7r7-s���&3�
4�9�4rr7c��eZdZy)�ResolutionErrorN)r
rrrrrrNrNTs��rrNc���eZdZ�fd�Z�xZS)�ResolutionImpossiblec�:��tt|�|�||_yr)rrPr�causes)rrRrs  �rrzResolutionImpossible.__init__Ys���
�"�D�2�6�:���r�r
rrrr.r/s@rrPrPXs
����rrPc���eZdZ�fd�Z�xZS)�ResolutionTooDeepc�:��tt|�|�||_yr)rrUr�round_count)rrWrs  �rrzResolutionTooDeep.__init__`s���
���/��<�&��rrSr/s@rrUrU_s
���'�'rrU�Statez!mapping criteria backtrack_causesc�\�eZdZdZd�Zed��Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zy
)�
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.
    c�.�||_||_g|_yr)�_p�_r�_states)r�provider�reporters   rrzResolution.__init__ps����������rc�R�	|jdS#t$rtd��wxYw)N����state)r^�
IndexError�AttributeErrorr+s rrczResolution.stateus0��	*��<�<��#�#���	*� ��)�)�	*�s��&c���|jd}t|jj�|jj�|j
dd��}|jj
|�y)z�Push a new state into history.

        This new state will be used to hold resolution results of the next
        coming round.
        rbN��mapping�criteria�backtrack_causes)r^rXrh�copyrirj�append)r�basercs   r�_push_new_statezResolution._push_new_state|s^���|�|�B�����L�L�%�%�'��]�]�'�'�)�!�2�2�1�5�
��
	
�����E�"rc
�p�|jj||��|jj|��}|j	|�}|rt|j�}ng}|jj|t|tjd�||gi�t|tjd�||i���}|r1t|j�}|jt||��n
t||�g}tt!|�||��}|j"st%|��|||<y)N)r	r
)�requirement_or_candidater*r<��
identifierr@r<r9)r]�adding_requirementr\�identify�get�listr<�find_matchesr�operator�methodcaller�
attrgetterr;rlrr7rr:r)	rrir	r
rrrr<�matchesr;s	         r�_add_to_criteriazResolution._add_to_criteria�s/�����"�"�{�6�"�J��W�W�%�%�{�%�K�
��L�L��,�	�� $�Y�%@�%@� A�� "���'�'�&�&�!�(���%�%�&8�9��k�]�+��
.���#�#�$7�8��.�/��'�
����y�4�4�5�K����5�k�6�J�K�1�+�v�F�G�K��&�w�/�#�/�
�	�
�#�#�(��3�3�(���rc
�"�|sy|j�D]t\}}t|j|jD�cgc]7}|j�'|j
j
|j�|vr|��9c}|j�||<�vycc}w)aWRemove information from parents of criteria.

        Concretely, removes all values from each criterion's ``information``
        field that have one of ``parents`` as provider of the requirement.

        :param criteria: The criteria to update.
        :param parents: Identifiers for which to remove information from all criteria.
        N)�itemsr7r:r;r
r\rtr<)rri�parents�keyrr;s      r�!_remove_information_from_criteriaz,Resolution._remove_information_from_criteria�s�����&�n�n�.�	�N�C��%��$�$�(1�'<�'<��#�#�*�*�2��7�7�+�+�K�,>�,>�?�w�N�	 ���+�+��H�S�M�	��s�<Bc�V�|jj||jjt	|jj
t
jd��t	|jj
t
jd��|jj��S)Nr:r;)rr�resolutionsr:r;rj)	r\�get_preferencercrhrrirxrzrj)r�names  r�_get_preferencezResolution._get_preference�s����w�w�%�%���
�
�*�*�&��
�
�#�#��#�#�L�1��(��
�
�#�#��#�#�M�2��"�Z�Z�8�8�&�
�	
rc����	�jj|�t��fd�|j	�D��S#t$rYywxYw)NFc3�X�K�|]!}�jj|������#y�w�)r	r3N�r\�is_satisfied_by)r#r$�current_pinrs  ��rr%z8Resolution._is_current_pin_satisfying.<locals>.<genexpr>�s-�����
��
�G�G�#�#��[�#�I�
���'*)rcrh�KeyError�allr*)rr�rr�s`  @r�_is_current_pin_satisfyingz%Resolution._is_current_pin_satisfying�sU���	��*�*�,�,�T�2�K��
��/�/�1�
�
�	
���	��	�s�A�	A�Ac��|jjj�}|jj	|��D]}|j|||���|S)N�r3rK)rcrirkr\�get_dependenciesr|)rr3rir	s    r�_get_updated_criteriaz Resolution._get_updated_criteria�sW���:�:�&�&�+�+�-���7�7�3�3�i�3�H�	K�K��!�!�(�K�	�!�J�	K��rc�����jj|}g}|jD]��	�j��}t��fd�|j�D��}|st�|���j
j����jjj|��jjj|d���jj|<gcS|S#t$rL}�j
j
|j��|j|j�Yd}~��d}~wwxYw)Nc3�X�K�|]!}�jj|������#y�wr�r�)r#r$r3rs  ��rr%z7Resolution._attempt_to_pin_criterion.<locals>.<genexpr>�s-����������'�'�A��'�K��r�r�)rcrir:r�rr]�rejecting_candidaterrlr�r*r1�pinning�updaterh�pop)rr�rrRri�e�	satisfiedr3s`      @r�_attempt_to_pin_criterionz$Resolution._attempt_to_pin_criterion�s����J�J�'�'��-�	���"�-�-�	�I�
��5�5�i�@����"�3�3�5���I��+�I�y�A�A��G�G�O�O�i�O�0��J�J���&�&�x�0�
�J�J���"�"�4��.�'0�D�J�J���t�$��I�7	�>�
��9*�
����+�+�A�K�K��C��
�
�a�k�k�*���
�s�C7�7	E�AE�Ec����tjd�|D�d�|D��}|D�chc]}�jj|���}}t	�j
�dk\�r/�j
d=d}|s�	�j
j
�}|jj�\}}�jj|�D�	chc]}	�jj|	���}
}	|
j|�}|s��jj�D��cgc]\}}|t!|j"�f��c}}��j%gf���fd�}
�j'�|
�}|ryt	�j
�dk\r��/ycc}w#ttf$rt|��wxYwcc}	wcc}}w)a2Perform backjumping.

        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.  Identify Z. The incompatibility is not always caused by the latest
            state. For example, given three requirements A, B and C, with
            dependencies A1, B1 and C1, where A1 and B1 are incompatible: the
            last state might be related to C, so we want to discard the
            previous state.
        2.  Discard Z.
        3.  Discard Y but remember its incompatibility information gathered
            previously, and the failure we're dealing with right now.
        4.  Push a new state Y' based on X, and apply the incompatibility
            information from Y to Y'.
        5a. If this causes Y' to conflict, we need to backtrack again. Make Y'
            the new Z and go back to step 2.
        5b. If the incompatibilities apply cleanly, end backtracking.
        c3�NK�|]}|j��|j���y�wrrK�r#�cs  rr%z'Resolution._backjump.<locals>.<genexpr>.s����>�!����)=�Q�X�X�>�s�%�%c3�4K�|]}|j���y�wrrDr�s  rr%z'Resolution._backjump.<locals>.<genexpr>/s����+�q�Q�]�]�+�rG�rbFc�B���D�]\}}|s�
	�jj|}�jj	|t�jjt
jd��t�jjt
jd�||i���}t|�}|sy|j|j�t|t|j�|���jj|<��y#t$rY��wxYw)Nr*r<rqFr9T)rcrir�r\rwrrxryrzr�extendr<r7rvr;)�kr<rr{r:�incompatibilities_from_brokenrs     ��r�_patch_criteriaz-Resolution._backjump.<locals>._patch_criteriaQs���,I��(�A�(�,� �!�$(�J�J�$7�$7��$:�	�#�g�g�2�2�#$�%4� �J�J�/�/�$�1�1�2D�E�&�+:� �J�J�/�/�$�/�/�0C�D�� 1�2�+�
3��G�"1��!9�J�%�$�%�,�,�Y�-H�-H�I�-6�#-�$(��)>�)>�$?�*;�.�D�J�J�'�'��*�/�8��/$�!� �!�s�D�	D�DT)�	itertools�chainr\rt�lenr^r�rh�popitemrdr�rPr��
isdisjointrir~rvr<rlrn)rrR�incompatible_reqsr$�incompatible_deps�incompatible_state�broken_stater�r3�d�current_dependenciesr��vr��successr�s`              @r�	_backjumpzResolution._backjumps����>&�O�O�>�v�>�+�F�+�
��;L�L�Q�T�W�W�-�-�a�0�L��L��$�,�,��1�$����R� �"'��(�7�#'�<�<�#3�#3�#5�L�&2�&:�&:�&B�&B�&D�O�D�)�
"�W�W�5�5�i�@�(���G�G�$�$�Q�'�(�$�(�*>�)H�)H�%�*�&�"�)�")�1�1�7�7�9�-��A�q��D��,�,�-�.�-�)�
*�0�0�$���1D�E�
�>
� � �"�%�'�G���G�$�,�,��1�$�R��UM��#�H�-�7�.�v�6�6�7��(��-s�"F�:7F�"F;�$!G�F8c	�L�|jrtd��|jj�t	tj�ig��g|_|D]+}	|j|jj|d���-|j�t|�D�]2}|jj!|��|jjj#�D��cgc]\}}|j%||�s|��}}}|s4|jj'|j��|jcSt)|jjj+��t)|�z
}	t-||j.��}
|j1|
�}|r�|D��
cgc]}|jD]}
|
���}}}
|jj3|��|j5|�}||jj6dd|s�t|jj6��|jjj#�D��chc]\}}||	vr|j%||�s|��}}}|j9|jj|�|j�|jj;||j����5t=|��#t$r$}t|jj��d}~wwxYwcc}}wcc}
}wcc}}w)	Nzalready resolvedrgrK)�index)rc)r�)rR)r�rc)r^�RuntimeErrorr]�startingrX�collections�OrderedDictr|rcrirrPrr;rn�range�starting_roundr~r��ending�set�keys�minr�r��resolving_conflictsr�rjr��ending_roundrU)rr@�
max_roundsr$r��round_indexr�r�unsatisfied_names�satisfied_namesr��failure_causesr�rFrRr��newly_unsatisfied_namess                 r�resolvezResolution.resolve}s����<�<��1�2�2�������
�#�/�/�1��!#�
�
����	D�A�
D��%�%�d�j�j�&9�&9�1�T�%�J�	D�	
���� ��,�1	F�K��G�G�"�"��"�5�'+�j�j�&9�&9�&?�&?�&A�!�"�C���6�6�s�I�F��!��!�%������T�Z�Z��0��z�z�!�"�$�*�*�"5�"5�":�":�"<�=��!�A��O�
�(�d�.B�.B�C�D�!�;�;�D�A�N��%3�K��Q�]�]�K��!�K�!�K��K����+�+�6�+�:��.�.��0��17��
�
�+�+�A�.��.�t�z�z�/J�/J�K�K�+/�*�*�*=�*=�*C�*C�*E�+�&��Y��o�-� �;�;�C��K��+�'�+��6�6��J�J�'�'�)@���$�$�&��G�G� � �{�$�*�*� �E�c1	F�f �
�+�+��w*�
D�*�1�;�;�+B�+B�C�C��
D��!��*L��+s*�(K$�*L�)L�"L �$	L�-L�LN)r
rrrr�propertyrcrnr|r�r�r�r�r�r�r�rrrrZrZisR����
�*��*�#�%)�N�2

�
��#�Jm�^L,rrZc���||vry||vry||j�D]I}	|t|�}||vr|j|�yt	||||�s�8|j|�yy#t$rY�XwxYw)NTF)rL�idr��add�_has_route_to_root)rir��all_keys�	connected�p�pkeys      rr�r��s���
�i���
�(���
�c�]�
&�
&�
(�
��	��B�q�E�?�D��9���M�M�#����h��h�	�B��M�M�#���
����	��	�s�A+�+	A7�6A7�Resultzmapping graph criteriac��|j}|j�D��cic]\}}t|�|��}}}d|td�<t�}|j	d�dh}|j
j�D]~\}}t
|j
|||�s�||vr|j	|�|j�D]8}		|t|	�}
|
|vr|j	|
�|j|
|��:��t|j�D��cic]
\}}||vs�||��c}}||j
��Scc}}w#t$rY��wxYwcc}}w)N)rh�graphri)rhr~r�rr�rir�rLr��connectr�)rcrhr�r�r�r�r�r�rr�r�s           r�
_build_resultr��sE���m�m�G�%,�]�]�_�5�T�Q���1��q��5�H�5��H�R��X���O�E�	�I�I�d�O���I��.�.�.�.�0�%���Y�!�%�.�.�#�x��K���e���I�I�c�N��&�&�(�	%�A�
���1�����5� ��	�	�$���M�M�$��$�	%�%��")�-�-�/�D�$�!�Q�Q�)�^��A��D��������+6���
��
��Es#�D?�E�E
�%E
�	E�Ec��eZdZdZeZdd�Zy)�Resolverz3The thing that performs the actual resolution work.c�~�t|j|j�}|j||��}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�)rZr_r`r�r�)rr@r��
resolutionrcs     rr�zResolver.resolves8��8 ��
�
�t�}�}�=�
��"�"�<�J�"�G���U�#�#rN)�d)r
rrrr�base_exceptionr�rrrr�r�s��=�&�N�$rr�)r�r�rx�	providersr�structsrrr�
namedtupler�	Exceptionrrr1�objectr7rNrPrUrXrZr�r�r�r�rrr�<module>r�s������'�D�D�/��/�/��}�h�7���
�	��
�.�
�

�-�

�$4��$4�N	�'�	��?��'��'�	����w�(K�L��`,��`,�F�&
 ��	�	��*B�	C���<#$��#$r