o
    Ëý°j»&  ã                
   @   sú   d dl Z d dlZd dlmZmZmZmZmZmZm	Z	m
Z
 d dlmZ ddlmZmZmZ ddlmZ ddlmZ erTd dlmZ d d	lmZ eeef Zeeeef ZneZe	d
ƒZe	dƒZdeeef dedede
eef fdd„ZG dd„ deƒZdS )é    N)ÚTYPE_CHECKINGÚDictÚIterableÚIteratorÚMappingÚSequenceÚTypeVarÚUnion)ÚAbstractProvideré   )Ú	CandidateÚ
ConstraintÚRequirement)ÚREQUIRES_PYTHON_IDENTIFIER)ÚFactory)Ú
Preference)ÚRequirementInformationÚDÚVÚmappingÚ
identifierÚdefaultÚreturnc                 C   s8   || v r| | S |  d¡\}}}|r|| v r| | S |S )ai  Get item from a package name lookup mapping with a resolver identifier.

    This extra logic is needed when the target mapping is keyed by package
    name, which cannot be directly looked up with an identifier (which may
    contain requested extras). Additional logic is added to also look up a value
    by "cleaning up" the extras from the identifier.
    ú[)Ú	partition)r   r   r   ÚnameÚopen_bracketÚ_© r   úŸ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/provider.pyÚ_get_with_identifier5   s   r    c                   @   s"  e Zd ZdZdedeeef dededeee	f ddfd	d
„Z
deeef defdd„Zdedeeef deeee f deeed f ded ddfdd„Zdedeeee f deeee f dee fdd„Zdededefdd„Zdedee fdd „Zededed defd!d"„ƒZdS )#ÚPipProvidera´  Pip's provider implementation for resolvelib.

    :params constraints: A mapping of constraints specified by the user. Keys
        are canonicalized project names.
    :params ignore_dependencies: Whether the user specified ``--no-deps``.
    :params upgrade_strategy: The user-specified upgrade strategy.
    :params user_requested: A set of canonicalized package names that the user
        supplied for pip to install/upgrade.
    ÚfactoryÚconstraintsÚignore_dependenciesÚupgrade_strategyÚuser_requestedr   Nc                 C   s2   || _ || _|| _|| _|| _t dd„ ¡| _d S )Nc                   S   s   t jS ©N)ÚmathÚinfr   r   r   r   Ú<lambda>f   s    z&PipProvider.__init__.<locals>.<lambda>)Ú_factoryÚ_constraintsÚ_ignore_dependenciesÚ_upgrade_strategyÚ_user_requestedÚcollectionsÚdefaultdictÚ_known_depths)Úselfr"   r#   r$   r%   r&   r   r   r   Ú__init__Y   s   zPipProvider.__init__Úrequirement_or_candidatec                 C   s   |j S r'   )r   )r3   r5   r   r   r   Úidentifyh   s   zPipProvider.identifyr   ÚresolutionsÚ
candidatesÚinformationÚPreferenceInformationÚbacktrack_causesr   c              	      s  dd„ || D ƒ}t |Ž \}}dd„ dd„ |D ƒD ƒ}	|du}
tdd„ |	D ƒƒ}t|	ƒ}zˆ j| }W n" tyU   tj}‡ fdd„|| D ƒ}td	d„ |D ƒƒd
 }Y nw d
}|ˆ j|< ˆ j 	|tj¡}|t
k}|dk}ˆ  ||¡}| ||
 | | ||| |f	S )a[  Produce a sort key for given requirement based on preference.

        The lower the return value is, the more preferred this group of
        arguments is.

        Currently pip considers the followings in order:

        * Prefer if any of the known requirements is "direct", e.g. points to an
          explicit URL.
        * If equal, prefer if any requirement is "pinned", i.e. contains
          operator ``===`` or ``==``.
        * If equal, calculate an approximate "depth" and resolve requirements
          closer to the user-specified requirements first.
        * Order user-specified requirements by the order they are specified.
        * If equal, prefers "non-free" requirements, i.e. contains at least one
          operator, such as ``>=`` or ``<``.
        * If equal, order alphabetically for consistency (helps debuggability).
        c                 s   s   � | ]	\}}|  ¡ V  qd S r'   )Úget_candidate_lookup)Ú.0Úrr   r   r   r   Ú	<genexpr>…   s   € z-PipProvider.get_preference.<locals>.<genexpr>c                 S   s   g | ]
}|D ]}|j ‘qqS r   )Úoperator)r=   Úspecifier_setÚ	specifierr   r   r   Ú
<listcomp>‡   s    ýþÿz.PipProvider.get_preference.<locals>.<listcomp>c                 s   s   � | ]}|r|j V  qd S r'   )rB   )r=   Úireqr   r   r   r?   ‰   s   € Nc                 s   s    � | ]}|d d… dkV  qd S )Né   z==r   )r=   Úopr   r   r   r?   Ž   s   € c                 3   s,   � | ]\}}|d urˆ j |j ndV  qd S )Ng        )r2   r   )r=   r   Úparent©r3   r   r   r?   •   s
   € ÿ
ÿc                 s   s   � | ]}|V  qd S r'   r   )r=   Údr   r   r   r?   ™   s   € g      ð?Ú
setuptools)ÚzipÚanyÚboolr/   ÚKeyErrorr(   r)   Úminr2   Úgetr   Úis_backtrack_cause)r3   r   r7   r8   r9   r;   ÚlookupsÚ	candidateÚireqsÚ	operatorsÚdirectÚpinnedÚunfreeÚrequested_orderÚparent_depthsÚinferred_depthÚrequires_pythonÚ
delay_thisÚbacktrack_causer   rH   r   Úget_preferencek   sB   þ
þú

÷zPipProvider.get_preferenceÚrequirementsÚincompatibilitiesc                    sF   dt dtf‡ fdd„}tˆ j|t ¡ d�}ˆ jj|||||ƒ |d�S )Nr   r   c                    s4   ˆ j dkrdS ˆ j dkrtˆ j| dd�}|duS dS )aÔ  Are upgrades allowed for this project?

            This checks the upgrade strategy, and whether the project was one
            that the user specified in the command line, in order to decide
            whether we should upgrade if there's a newer version available.

            (Note that we don't need access to the `--upgrade` flag, because
            an upgrade strategy of "to-satisfy-only" means that `--upgrade`
            was not specified).
            ÚeagerTzonly-if-neededN©r   F)r.   r    r/   )r   Ú
user_orderrH   r   r   Ú_eligible_for_upgradeÅ   s   

ýz7PipProvider.find_matches.<locals>._eligible_for_upgraderc   )r   r`   Ú
constraintÚprefers_installedra   )ÚstrrM   r    r,   r   Úemptyr+   Úfind_candidates)r3   r   r`   ra   re   rf   r   rH   r   Úfind_matches¿   s   ýûzPipProvider.find_matchesÚrequirementrS   c                 C   s
   |  |¡S r'   )Úis_satisfied_by)r3   rl   rS   r   r   r   rm   è   s   
zPipProvider.is_satisfied_byc                 C   s   | j  }dd„ | |¡D ƒS )Nc                 S   s   g | ]}|d ur|‘qS r'   r   )r=   r>   r   r   r   rC   í   s    z0PipProvider.get_dependencies.<locals>.<listcomp>)r-   Úiter_dependencies)r3   rS   Úwith_requiresr   r   r   Úget_dependenciesë   s   zPipProvider.get_dependenciesc                 C   s8   |D ]}| |j jkr dS |jr| |jjkr dS qdS )NTF)rl   r   rG   )r   r;   r^   r   r   r   rQ   ï   s   €zPipProvider.is_backtrack_cause)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   rh   r   rM   Úintr4   r	   r   r   r6   r   r   r   r   r_   rk   rm   rp   ÚstaticmethodrQ   r   r   r   r   r!   N   s`    
þ
ýüû
ú
ùþ
ýüûú
ùTþýü
û)ÿÿþr!   )r0   r(   Útypingr   r   r   r   r   r   r   r	   Ú pip._vendor.resolvelib.providersr
   Úbaser   r   r   r8   r   r"   r   r   Ú pip._vendor.resolvelib.resolversr   r:   rh   Ú_ProviderBaser   r   r    r!   r   r   r   r   Ú<module>   s2    (
ÿþý

ü