U
    ;»{j�  ã                   @   s°   d dl mZmZ d dlmZ d dlmZmZ d dlm	Z	 d dl
mZ ddlmZmZmZmZ G dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )é    )ÚAnyÚOptional)ÚSpecifierSet)ÚNormalizedNameÚcanonicalize_name)Úinstall_req_drop_extras)ÚInstallRequirementé   )Ú	CandidateÚCandidateLookupÚRequirementÚformat_namec                   @   s¦   e Zd Zeddœdd„Zedœdd„Zedœdd	„Zedœd
d„Z	e
edœdd„Zeedœdd„ƒZeedœdd„ƒZedœdd„Zedœdd„Zeedœdd„ZdS )ÚExplicitRequirementN©Ú	candidateÚreturnc                 C   s
   || _ d S ©N©r   ©Úselfr   © r   úQ/tmp/pip-install-zsn1f9xv/pip/pip/_internal/resolution/resolvelib/requirements.pyÚ__init__   s    zExplicitRequirement.__init__©r   c                 C   s
   t | jƒS r   )Ústrr   ©r   r   r   r   Ú__str__   s    zExplicitRequirement.__str__c                 C   s   | j j› d| j›d�S ©Nú(ú))Ú	__class__Ú__name__r   r   r   r   r   Ú__repr__   s    zExplicitRequirement.__repr__c                 C   s
   t | jƒS r   )Úhashr   r   r   r   r   Ú__hash__   s    zExplicitRequirement.__hash__©Úotherr   c                 C   s   t |tƒsdS | j|jkS ©NF)Ú
isinstancer   r   ©r   r&   r   r   r   Ú__eq__   s    
zExplicitRequirement.__eq__c                 C   s   | j jS r   )r   Úproject_namer   r   r   r   r+      s    z ExplicitRequirement.project_namec                 C   s   | j jS r   )r   Únamer   r   r   r   r,   #   s    zExplicitRequirement.namec                 C   s
   | j  ¡ S r   )r   Úformat_for_errorr   r   r   r   r-   (   s    z$ExplicitRequirement.format_for_errorc                 C   s
   | j d fS r   r   r   r   r   r   Úget_candidate_lookup+   s    z(ExplicitRequirement.get_candidate_lookupc                 C   s
   || j kS r   r   r   r   r   r   Úis_satisfied_by.   s    z#ExplicitRequirement.is_satisfied_by)r!   Ú
__module__Ú__qualname__r
   r   r   r   r"   Úintr$   r   Úboolr*   Úpropertyr   r+   r,   r-   r   r.   r/   r   r   r   r   r      s   r   c                   @   s¸   e Zd Zeddœdd„Zeedœdd„ƒZedœdd	„Zedœd
d„Z	e
edœdd„Zedœdd„Zeedœdd„ƒZeedœdd„ƒZedœdd„Zedœdd„Zeedœdd„ZdS )ÚSpecifierRequirementN©Úireqr   c                 C   s@   |j d kstdƒ‚|| _d | _d | _tdd„ | jjD ƒƒ| _d S )NúThis is a link, not a specifierc                 s   s   | ]}t |ƒV  qd S r   ©r   ©Ú.0Úer   r   r   Ú	<genexpr>8   s     z0SpecifierRequirement.__init__.<locals>.<genexpr>)ÚlinkÚAssertionErrorÚ_ireqÚ_equal_cacheÚ_hashÚ	frozensetÚextrasÚ_extras©r   r7   r   r   r   r   3   s
    zSpecifierRequirement.__init__r   c                 C   s"   | j d k	r| j S t| jƒ| _ | j S r   ©rA   r   r@   r   r   r   r   Ú_equal:   s    
zSpecifierRequirement._equalc                 C   s   t | jjƒS r   )r   r@   Úreqr   r   r   r   r   B   s    zSpecifierRequirement.__str__c                 C   s   | j j› dt| jjƒ›d�S r   )r    r!   r   r@   rI   r   r   r   r   r"   E   s    zSpecifierRequirement.__repr__r%   c                 C   s   t |tƒstS | j|jkS r   )r(   r5   ÚNotImplementedrH   r)   r   r   r   r*   H   s    
zSpecifierRequirement.__eq__c                 C   s"   | j d k	r| j S t| jƒ| _ | j S r   ©rB   r#   rH   r   r   r   r   r$   M   s    
zSpecifierRequirement.__hash__c                 C   s   | j jstdƒ‚t| j jjƒS )Nú'Specifier-backed ireq is always PEP 508)r@   rI   r?   r   r,   r   r   r   r   r+   T   s    z!SpecifierRequirement.project_namec                 C   s   t | j| jƒS r   )r   r+   rE   r   r   r   r   r,   Y   s    zSpecifierRequirement.namec                 C   sZ   dd„ t | ƒ d¡D ƒ}t|ƒdkr(dS t|ƒdkr<|d S d |d d… ¡d	 |d  S )
Nc                 S   s   g | ]}|  ¡ ‘qS r   )Ústrip)r;   Úsr   r   r   Ú
<listcomp>b   s     z9SpecifierRequirement.format_for_error.<locals>.<listcomp>ú,r   Ú r	   z, éÿÿÿÿz and )r   ÚsplitÚlenÚjoin)r   Úpartsr   r   r   r-   ]   s    z%SpecifierRequirement.format_for_errorc                 C   s
   d | j fS r   )r@   r   r   r   r   r.   j   s    z)SpecifierRequirement.get_candidate_lookupr   c                 C   sN   |j | j ks$td|j › d| j › �ƒ‚| jjs4tdƒ‚| jjj}|j|jdd�S )Nz6Internal issue: Candidate is not for this requirement z vs rL   T©Úprereleases)r,   r?   r@   rI   Ú	specifierÚcontainsÚversion)r   r   Úspecr   r   r   r/   m   s    ÿ
z$SpecifierRequirement.is_satisfied_by)r!   r0   r1   r   r   r4   r   rH   r   r"   Úobjectr3   r*   r2   r$   r   r+   r,   r-   r   r.   r
   r/   r   r   r   r   r5   2   s   r5   c                   @   sP   e Zd ZdZeddœdd„Zeedœdd„ƒZe	e
d	œd
d„Zedœdd„ZdS )Ú!SpecifierWithoutExtrasRequirementz‰
    Requirement backed by an install requirement on a base package.
    Trims extras from its install requirement if there are any.
    Nr6   c                 C   sD   |j d kstdƒ‚t|ƒ| _d | _d | _tdd„ | jjD ƒƒ| _d S )Nr8   c                 s   s   | ]}t |ƒV  qd S r   r9   r:   r   r   r   r=   …   s     z=SpecifierWithoutExtrasRequirement.__init__.<locals>.<genexpr>)	r>   r?   r   r@   rA   rB   rC   rD   rE   rF   r   r   r   r   €   s
    
z*SpecifierWithoutExtrasRequirement.__init__r   c                 C   s"   | j d k	r| j S t| jƒ| _ | j S r   rG   r   r   r   r   rH   ‡   s    
z(SpecifierWithoutExtrasRequirement._equalr%   c                 C   s   t |tƒstS | j|jkS r   )r(   r^   rJ   rH   r)   r   r   r   r*   �   s    
z(SpecifierWithoutExtrasRequirement.__eq__c                 C   s"   | j d k	r| j S t| jƒ| _ | j S r   rK   r   r   r   r   r$   ”   s    
z*SpecifierWithoutExtrasRequirement.__hash__)r!   r0   r1   Ú__doc__r   r   r4   r   rH   r]   r3   r*   r2   r$   r   r   r   r   r^   z   s   r^   c                   @   s¬   e Zd ZdZeeddœdd„Zedœdd„Zedœd	d
„Z	e
dœdd„Zeedœdd„Zeedœdd„ƒZeedœdd„ƒZedœdd„Zedœdd„Zeedœdd„ZdS )ÚRequiresPythonRequirementz4A requirement representing Requires-Python metadata.N)rY   Úmatchr   c                 C   s    || _ t|ƒ| _d | _|| _d S r   )rY   r   Ú_specifier_stringrB   Ú
_candidate)r   rY   ra   r   r   r   r   Ÿ   s    
z"RequiresPythonRequirement.__init__r   c                 C   s   d| j › �S )NzPython )rY   r   r   r   r   r   ¥   s    z!RequiresPythonRequirement.__str__c                 C   s   | j j› dt| jƒ›d�S r   )r    r!   r   rY   r   r   r   r   r"   ¨   s    z"RequiresPythonRequirement.__repr__c                 C   s(   | j d k	r| j S t| j| jfƒ| _ | j S r   )rB   r#   rb   rc   r   r   r   r   r$   «   s    
z"RequiresPythonRequirement.__hash__r%   c                 C   s&   t |tƒsdS | j|jko$| j|jkS r'   )r(   r`   rb   rc   r)   r   r   r   r*   ²   s
    

þz RequiresPythonRequirement.__eq__c                 C   s   | j jS r   )rc   r+   r   r   r   r   r+   º   s    z&RequiresPythonRequirement.project_namec                 C   s   | j jS r   )rc   r,   r   r   r   r   r,   ¾   s    zRequiresPythonRequirement.namec                 C   s   t | ƒS r   ©r   r   r   r   r   r-   Â   s    z*RequiresPythonRequirement.format_for_errorc                 C   s"   | j j| jjdd�r| jd fS dS )NTrW   ©NN)rY   rZ   rc   r[   r   r   r   r   r.   Å   s    
z.RequiresPythonRequirement.get_candidate_lookupr   c                 C   s(   |j | jj kstdƒ‚| jj|jdd�S )NzNot Python candidateTrW   )r,   rc   r?   rY   rZ   r[   r   r   r   r   r/   Ê   s    z)RequiresPythonRequirement.is_satisfied_by)r!   r0   r1   r_   r   r
   r   r   r   r"   r2   r$   r   r3   r*   r4   r   r+   r,   r-   r   r.   r/   r   r   r   r   r`   œ   s   r`   c                   @   sª   e Zd ZdZeddœdd„Zedœdd„Zedœd	d
„Ze	e
dœdd„Zedœdd„Zeedœdd„ƒZeedœdd„ƒZedœdd„Zedœdd„Zee
dœdd„ZdS )ÚUnsatisfiableRequirementz'A requirement that cannot be satisfied.N)r,   r   c                 C   s
   || _ d S r   ©Ú_name)r   r,   r   r   r   r   Õ   s    z!UnsatisfiableRequirement.__init__r   c                 C   s   | j › d�S )Nz (unavailable)rg   r   r   r   r   r   Ø   s    z UnsatisfiableRequirement.__str__c                 C   s   | j j› dt| jƒ›d�S r   )r    r!   r   rh   r   r   r   r   r"   Û   s    z!UnsatisfiableRequirement.__repr__r%   c                 C   s   t |tƒstS | j|jkS r   )r(   rf   rJ   rh   r)   r   r   r   r*   Þ   s    
zUnsatisfiableRequirement.__eq__c                 C   s
   t | jƒS r   )r#   rh   r   r   r   r   r$   ã   s    z!UnsatisfiableRequirement.__hash__c                 C   s   | j S r   rg   r   r   r   r   r+   æ   s    z%UnsatisfiableRequirement.project_namec                 C   s   | j S r   rg   r   r   r   r   r,   ê   s    zUnsatisfiableRequirement.namec                 C   s   t | ƒS r   rd   r   r   r   r   r-   î   s    z)UnsatisfiableRequirement.format_for_errorc                 C   s   dS )Nre   r   r   r   r   r   r.   ñ   s    z-UnsatisfiableRequirement.get_candidate_lookupr   c                 C   s   dS r'   r   r   r   r   r   r/   ô   s    z(UnsatisfiableRequirement.is_satisfied_by)r!   r0   r1   r_   r   r   r   r   r"   r]   r3   r*   r2   r$   r4   r+   r,   r-   r   r.   r
   r/   r   r   r   r   rf   Ò   s   rf   N)Útypingr   r   Z pip._vendor.packaging.specifiersr   Úpip._vendor.packaging.utilsr   r   Úpip._internal.req.constructorsr   Zpip._internal.req.req_installr   Úbaser
   r   r   r   r   r5   r^   r`   rf   r   r   r   r   Ú<module>   s   &H"6