U
    
Ha                     @   s   d dl mZmZmZmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZmZ d dlmZmZ d dlmZ d dlmZ eed ee f Zeeef Zeee ed	d
dZG dd dZG dd dZededddZG dd dZdS )    )	FrozenSetIterableOptionalTupleUnion)SpecifierSet)NormalizedNamecanonicalize_name)LegacyVersionVersion)Linklinks_equivalent)InstallRequirement)Hashes	Candidate)projectextrasreturnc                 C   s,   |s| S t dd |D }d| d|S )Nc                 s   s   | ]}t |V  qd S N)r	   ).0e r   L/tmp/pip-unpacked-wheel-tx790h60/pip/_internal/resolution/resolvelib/base.py	<genexpr>   s     zformat_name.<locals>.<genexpr>z{}[{}],)sortedformatjoin)r   r   Zcanonical_extrasr   r   r   format_name   s    r   c                   @   s   e Zd Zeeee ddddZed dddZ	ee
d dd	d
ZedddZedddZe
d dddZdedddZdS )
ConstraintN)	specifierhasheslinksr   c                 C   s   || _ || _|| _d S r   )r    r!   r"   )selfr    r!   r"   r   r   r   __init__   s    zConstraint.__init__r   c                 C   s   t t t t S r   )r   r   r   	frozenset)clsr   r   r   empty   s    zConstraint.empty)ireqr   c                 C   s.   |j rt|j gnt }t|j|jdd|S NF)trust_internet)linkr&   r   r    r!   )r'   r)   r"   r   r   r   	from_ireq"   s    zConstraint.from_ireqc                 C   s   t | jpt | jpt | jS r   )boolr    r!   r"   r#   r   r   r   __nonzero__'   s    zConstraint.__nonzero__c                 C   s   |   S r   )r0   r/   r   r   r   __bool__*   s    zConstraint.__bool__)otherr   c                 C   sR   t |tstS | j|j@ }| j|jdd@ }| j}|jrF||jg}t|||S r*   )	
isinstancer   NotImplementedr    r!   r"   r,   unionr   )r#   r2   r    r!   r"   r   r   r   __and__-   s    
zConstraint.__and__r   	candidater   c                    s4   | j r"t fdd| j D s"dS | jj jddS )Nc                 3   s   | ]}t | V  qd S r   )_match_link)r   r,   r8   r   r   r   9   s     z-Constraint.is_satisfied_by.<locals>.<genexpr>FT)prereleases)r"   allr    containsversionr#   r8   r   r:   r   is_satisfied_by7   s    zConstraint.is_satisfied_by)__name__
__module____qualname__r   r   r   r   r$   classmethodr(   r   r-   r.   r0   r1   r6   r@   r   r   r   r   r      s     
r   c                   @   s\   e Zd ZeedddZeedddZdeddd	Z	e
dd
dZedddZdS )Requirementr%   c                 C   s   t ddS )zThe "project name" of a requirement.

        This is different from ``name`` if this requirement contains extras,
        in which case ``name`` would contain the ``[...]`` part, while this
        refers to the name of the project.
        Subclass should overrideNNotImplementedErrorr/   r   r   r   project_nameB   s    zRequirement.project_namec                 C   s   t ddS )zThe name identifying this requirement in the resolver.

        This is different from ``project_name`` if this requirement contains
        extras, where ``project_name`` would not contain the ``[...]`` part.
        rF   NrG   r/   r   r   r   nameL   s    zRequirement.namer   r7   c                 C   s   dS NFr   r?   r   r   r   r@   U   s    zRequirement.is_satisfied_byc                 C   s   t dd S NrF   rG   r/   r   r   r   get_candidate_lookupX   s    z Requirement.get_candidate_lookupc                 C   s   t dd S rL   rG   r/   r   r   r   format_for_error[   s    zRequirement.format_for_errorN)rA   rB   rC   propertyr   rI   strrJ   r.   r@   CandidateLookuprM   rN   r   r   r   r   rE   A   s   	rE   )r,   r8   r   c                 C   s   |j rt| |j S dS rK   )source_linkr   )r,   r8   r   r   r   r9   _   s    r9   c                   @   s   e Zd ZeedddZeedddZeedddZ	ee
ddd	Zee
dd
dZeee dddZe
eee  dddZee dddZedddZdS )r   r%   c                 C   s   t ddS )zThe "project name" of the candidate.

        This is different from ``name`` if this candidate contains extras,
        in which case ``name`` would contain the ``[...]`` part, while this
        refers to the name of the project.
        Override in subclassNrG   r/   r   r   r   rI   f   s    zCandidate.project_namec                 C   s   t ddS )zThe name identifying this candidate in the resolver.

        This is different from ``project_name`` if this candidate contains
        extras, where ``project_name`` would not contain the ``[...]`` part.
        rS   NrG   r/   r   r   r   rJ   p   s    zCandidate.namec                 C   s   t dd S NrS   rG   r/   r   r   r   r>   y   s    zCandidate.versionc                 C   s   t dd S rT   rG   r/   r   r   r   is_installed}   s    zCandidate.is_installedc                 C   s   t dd S rT   rG   r/   r   r   r   is_editable   s    zCandidate.is_editablec                 C   s   t dd S rT   rG   r/   r   r   r   rR      s    zCandidate.source_link)with_requiresr   c                 C   s   t dd S rT   rG   )r#   rW   r   r   r   iter_dependencies   s    zCandidate.iter_dependenciesc                 C   s   t dd S rT   rG   r/   r   r   r   get_install_requirement   s    z!Candidate.get_install_requirementc                 C   s   t dd S rL   rG   r/   r   r   r   rN      s    zCandidate.format_for_errorN)rA   rB   rC   rO   r   rI   rP   rJ   CandidateVersionr>   r.   rU   rV   r   r   rR   r   rE   rX   r   rY   rN   r   r   r   r   r   e   s   	N)typingr   r   r   r   r   Z pip._vendor.packaging.specifiersr   pip._vendor.packaging.utilsr   r	   Zpip._vendor.packaging.versionr
   r   pip._internal.models.linkr   r   pip._internal.req.req_installr   pip._internal.utils.hashesr   rQ   rZ   rP   r   r   rE   r.   r9   r   r   r   r   r   <module>   s   +