3
ûâded  ã               @   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j| dj|ƒƒS )Nc             s   s   | ]}t |ƒV  qd S )N)r	   )Ú.0Úe© r   úG/tmp/pip-build-red6nood/pip/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               @   sx   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d„Zdedœdd„ZdS )Ú
ConstraintN)Ú	specifierÚhashesÚlinksr   c             C   s   || _ || _|| _d S )N)r   r    r!   )Úselfr   r    r!   r   r   r   Ú__init__   s    zConstraint.__init__)r   c             C   s   t tƒ tƒ tƒ ƒS )N)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 )N)Úboolr   r    r!   )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|jgƒ}t|||ƒS )NF)r(   )	Ú
isinstancer   ÚNotImplementedr   r    r!   r)   Úunionr   )r"   r-   r   r    r!   r   r   r   Ú__and__*   s    
zConstraint.__and__r   )Ú	candidater   c                s6   | j r$t‡ fdd„| j D ƒƒ r$dS | jjˆ jdd�S )Nc             3   s   | ]}t |ˆ ƒV  qd S )N)Ú_match_link)r   r)   )r2   r   r   r   6   s    z-Constraint.is_satisfied_by.<locals>.<genexpr>FT)Úprereleases)r!   Úallr   ÚcontainsÚversion)r"   r2   r   )r2   r   Úis_satisfied_by4   s     zConstraint.is_satisfied_by)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r#   Úclassmethodr&   r   r*   r+   r,   r1   r8   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 )ÚRequirement)r   c             C   s   t dƒ‚dS )zòThe "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.
        zSubclass should overrideN)ÚNotImplementedError)r"   r   r   r   Úproject_name?   s    zRequirement.project_namec             C   s   t dƒ‚dS )zÚThe 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.
        zSubclass should overrideN)r>   )r"   r   r   r   ÚnameI   s    zRequirement.namer   )r2   r   c             C   s   dS )NFr   )r"   r2   r   r   r   r8   R   s    zRequirement.is_satisfied_byc             C   s   t dƒ‚d S )NzSubclass should override)r>   )r"   r   r   r   Úget_candidate_lookupU   s    z Requirement.get_candidate_lookupc             C   s   t dƒ‚d S )NzSubclass should override)r>   )r"   r   r   r   Úformat_for_errorX   s    zRequirement.format_for_errorN)r9   r:   r;   Úpropertyr   r?   Ústrr@   r+   r8   ÚCandidateLookuprA   rB   r   r   r   r   r=   >   s   	r=   )r)   r2   r   c             C   s   |j rt| |j ƒS dS )NF)Úsource_linkr   )r)   r2   r   r   r   r3   \   s    r3   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 )zðThe "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.
        zOverride in subclassN)r>   )r"   r   r   r   r?   c   s    zCandidate.project_namec             C   s   t dƒ‚dS )zÖThe 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.
        zOverride in subclassN)r>   )r"   r   r   r   r@   m   s    zCandidate.namec             C   s   t dƒ‚d S )NzOverride in subclass)r>   )r"   r   r   r   r7   v   s    zCandidate.versionc             C   s   t dƒ‚d S )NzOverride in subclass)r>   )r"   r   r   r   Úis_installedz   s    zCandidate.is_installedc             C   s   t dƒ‚d S )NzOverride in subclass)r>   )r"   r   r   r   Úis_editable~   s    zCandidate.is_editablec             C   s   t dƒ‚d S )NzOverride in subclass)r>   )r"   r   r   r   rF   ‚   s    zCandidate.source_link)Úwith_requiresr   c             C   s   t dƒ‚d S )NzOverride in subclass)r>   )r"   rI   r   r   r   Úiter_dependencies†   s    zCandidate.iter_dependenciesc             C   s   t dƒ‚d S )NzOverride in subclass)r>   )r"   r   r   r   Úget_install_requirement‰   s    z!Candidate.get_install_requirementc             C   s   t dƒ‚d S )NzSubclass should override)r>   )r"   r   r   r   rB   Œ   s    zCandidate.format_for_errorN)r9   r:   r;   rC   r   r?   rD   r@   ÚCandidateVersionr7   r+   rG   rH   r   r   rF   r   r=   rJ   r   rK   rB   r   r   r   r   r   b   s   	N)Útypingr   r   r   r   r   Z pip._vendor.packaging.specifiersr   Úpip._vendor.packaging.utilsr   r	   Zpip._vendor.packaging.versionr
   r   Zpip._internal.models.linkr   r   Zpip._internal.req.req_installr   Zpip._internal.utils.hashesr   rE   rL   rD   r   r   r=   r+   r3   r   r   r   r   r   Ú<module>   s   (