3
�Pf � @ s~ d dl mZ d dlmZ d dlZd dlZd dlmZ d dlmZ d dl m
Z
d dlmZ ej
e�Zdd � Zd
d� Zdd
� ZdS )� )�absolute_import)�
FeedParserN)�
specifiers)�version)�
pkg_resources)�
exceptionsc C s> | dkrdS t j| �}tjdjtttjdd� ���}||kS )aG
Check if the python version in use match the `requires_python` specifier.
Returns `True` if the version of python in use matches the requirement.
Returns `False` if the version of python in use does not matches the
requirement.
Raises an InvalidSpecifier if `requires_python` have an invalid format.
NT�.� ) r ZSpecifierSetr �parse�join�map�str�sys�version_info)�requires_pythonZrequires_python_specifierZpython_version� r �/usr/lib/python3.6/packaging.py�check_requires_python s
r c C s8 t | tj�r | jd�r | jd�S | jd�r4| jd�S d S )NZMETADATAzPKG-INFO)�
isinstancer ZDistInfoDistributionZhas_metadata�get_metadata)�distr r r r % s
r c C s� t | �}t� }|j|� |j� }|jd�}y8t|�s`tjd| j|dj t
ttj
d d� ��f ��W n8 tjk
r� } ztjd| j||f � d S d }~X nX d S )NzRequires-Pythonz4%s requires Python '%s' but the running Python is %sr r z7Package %s has an invalid Requires-Python entry %s - %s)r r Zfeed�close�getr r ZUnsupportedPythonVersionZproject_namer r r
r r r ZInvalidSpecifier�loggerZwarning)r ZmetadataZfeed_parserZ
pkg_info_dictr �er r r �check_dist_requires_python- s"
$r )Z
__future__r Zemail.parserr Zloggingr Zpip._vendor.packagingr r Zpip._vendorr Zpipr Z getLogger�__name__r r r r r r r r �