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 Ú