B
    `d                  @   s   d dl mZ d dlmZ ddlmZmZ erhd dlmZ d dl	m
Z
 d dlmZ ddlmZ dd	lmZ G d
d deZG dd deZG dd deZdS )    )canonicalize_name)MYPY_CHECK_RUNNING   )Requirementformat_name)Sequence)SpecifierSet)InstallRequirement)	Candidate)Factoryc               @   s8   e Zd Zdd Zdd Zedd Zdd Zd	d
 ZdS )ExplicitRequirementc             C   s
   || _ d S )N)	candidate)selfr    r   T/tmp/pip-unpacked-wheel-hu9qqap1/pip/_internal/resolution/resolvelib/requirements.py__init__   s    zExplicitRequirement.__init__c             C   s   dj | jj| jdS )Nz{class_name}({candidate!r}))
class_namer   )format	__class____name__r   )r   r   r   r   __repr__   s    zExplicitRequirement.__repr__c             C   s   | j jS )N)r   name)r   r   r   r   r      s    zExplicitRequirement.namec             C   s   | j gS )N)r   )r   r   r   r   find_matches$   s    z ExplicitRequirement.find_matchesc             C   s
   || j kS )N)r   )r   r   r   r   r   is_satisfied_by(   s    z#ExplicitRequirement.is_satisfied_byN)	r   
__module____qualname__r   r   propertyr   r   r   r   r   r   r   r      s
   r   c               @   s@   e Zd Zdd Zdd Zdd Zedd Zd	d
 Zdd Z	dS )SpecifierRequirementc             C   s,   |j d kstd|| _|| _|jj| _d S )NzThis is a link, not a specifier)linkAssertionError_ireq_factoryreqextras)r   Zireqfactoryr   r   r   r   .   s    zSpecifierRequirement.__init__c             C   s   t | jjS )N)strr    r"   )r   r   r   r   __str__5   s    zSpecifierRequirement.__str__c             C   s   dj | jjt| jjdS )Nz{class_name}({requirement!r}))r   requirement)r   r   r   r%   r    r"   )r   r   r   r   r   9   s    zSpecifierRequirement.__repr__c             C   s   t | jjj}t|| jS )N)r   r    r"   r   r   r#   )r   canonical_namer   r   r   r   @   s    zSpecifierRequirement.namec             C   s   | j | j| j}t|S )N)r!   Ziter_found_candidatesr    r#   list)r   itr   r   r   r   F   s    z!SpecifierRequirement.find_matchesc             C   s:   |j | j ks td|j | j | jjj}|j|jddS )Nz?Internal issue: Candidate is not for this requirement  {} vs {}T)prereleases)r   r   r   r    r"   	specifiercontainsversion)r   r   specr   r   r   r   K   s
    
z$SpecifierRequirement.is_satisfied_byN)
r   r   r   r   r&   r   r   r   r   r   r   r   r   r   r   -   s   r   c               @   s<   e Zd ZdZdd Zdd Zedd Zdd	 Zd
d Z	dS )RequiresPythonRequirementz9A requirement representing Requires-Python metadata.
    c             C   s   || _ || _d S )N)r,   
_candidate)r   r,   matchr   r   r   r   Z   s    z"RequiresPythonRequirement.__init__c             C   s   dj | jjt| jdS )Nz{class_name}({specifier!r}))r   r,   )r   r   r   r%   r,   )r   r   r   r   r   _   s    z"RequiresPythonRequirement.__repr__c             C   s   | j jS )N)r1   r   )r   r   r   r   r   f   s    zRequiresPythonRequirement.namec             C   s   | j j| jkr| j gS g S )N)r1   r.   r,   )r   r   r   r   r   k   s    z&RequiresPythonRequirement.find_matchesc             C   s(   |j | jj kstd| jj|jddS )NzNot Python candidateT)r+   )r   r1   r   r,   r-   r.   )r   r   r   r   r   r   q   s    z)RequiresPythonRequirement.is_satisfied_byN)
r   r   r   __doc__r   r   r   r   r   r   r   r   r   r   r0   W   s   r0   N)pip._vendor.packaging.utilsr   pip._internal.utils.typingr   baser   r   typingr   Z pip._vendor.packaging.specifiersr   Zpip._internal.req.req_installr	   r
   r$   r   r   r   r0   r   r   r   r   <module>   s   *