3
ûâdeˆ  ã               @   sì   d dl Z d dlZd dlmZ d dlmZ 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 d d
lmZ ejeƒZee eedf edœdd„Zeedœdd„Zeedœdd„Ze jdd�eedœdd„ƒZ dS )é    N)ÚMessage)Ú
FeedParser)ÚOptionalÚTuple)Úpkg_resources)Ú
specifiersÚversion)ÚRequirement)ÚDistribution)ÚNoneMetadataError)Údisplay_path.)Úrequires_pythonÚversion_infoÚreturnc             C   s4   | dkrdS t j| ƒ}tjdjtt|ƒƒƒ}||kS )a˜  
    Check if the given Python version matches a "Requires-Python" specifier.

    :param version_info: A 3-tuple of ints representing a Python
        major-minor-micro version to check (e.g. `sys.version_info[:3]`).

    :return: `True` if the given Python version satisfies the requirement.
        Otherwise, return `False`.

    :raises InvalidSpecifier: If `requires_python` has an invalid format.
    NTÚ.)r   ÚSpecifierSetr   ÚparseÚjoinÚmapÚstr)r   r   Úrequires_python_specifierÚpython_version© r   ú</tmp/pip-build-red6nood/pip/pip/_internal/utils/packaging.pyÚcheck_requires_python   s
    
r   )Údistr   c             C   s€   d}t | tjƒr&| j|ƒr&| j|ƒ}n0| jdƒr@d}| j|ƒ}ntjdt| jƒƒ d}|dkrht	| |ƒ‚t
ƒ }|j|ƒ |jƒ S )z�
    :raises NoneMetadataError: if the distribution reports `has_metadata()`
        True but `get_metadata()` returns None.
    ÚMETADATAzPKG-INFOzNo metadata found in %sÚ N)Ú
isinstancer   ÚDistInfoDistributionÚhas_metadataÚget_metadataÚloggerÚwarningr   Úlocationr   r   ÚfeedÚclose)r   Úmetadata_nameÚmetadataÚfeed_parserr   r   r   r!   )   s    


r!   c             C   s2   | j dƒr.x"| jdƒD ]}|jƒ r|jƒ S qW dS )NÚ	INSTALLERr   )r    Úget_metadata_linesÚstrip)r   Úliner   r   r   Úget_installerD   s
    
r.   i   )Úmaxsize)Ú
req_stringr   c             C   s   t | ƒS )z5Construct a packaging.Requirement object with caching)r	   )r0   r   r   r   Úget_requirementL   s    r1   )!Ú	functoolsÚloggingÚemail.messager   Úemail.parserr   Útypingr   r   Úpip._vendorr   Zpip._vendor.packagingr   r   Ú"pip._vendor.packaging.requirementsr	   Zpip._vendor.pkg_resourcesr
   Zpip._internal.exceptionsr   Zpip._internal.utils.miscr   Ú	getLoggerÚ__name__r"   r   ÚintÚboolr   r!   r.   Ú	lru_cacher1   r   r   r   r   Ú<module>   s"   

