3333from pip ._vendor import html5lib , requests , six
3434from pip ._vendor .packaging .version import parse as parse_version
3535from pip ._vendor .packaging .utils import canonicalize_name
36+ from pip ._vendor .packaging import specifiers
3637from pip ._vendor .requests .exceptions import SSLError
3738from pip ._vendor .distlib .compat import unescape
3839
@@ -642,8 +643,12 @@ def _link_package_versions(self, link, search):
642643 self ._log_skipped_link (
643644 link , 'Python version is incorrect' )
644645 return
646+ try :
647+ support_this_python = check_requires_python (link .requires_python )
648+ except specifiers .InvalidSpecifier :
649+ support_this_python = True
645650
646- if not check_requires_python ( link . requires_python ) :
651+ if not support_this_python :
647652 logger .debug ("The package %s is incompatible with the python"
648653 "version in use. Acceptable python versions are:%s" ,
649654 link , link .requires_python )
@@ -836,7 +841,7 @@ def links(self):
836841 url = self .clean_link (
837842 urllib_parse .urljoin (self .base_url , href )
838843 )
839- pyrequire = anchor .get ('data-requires-python' )
844+ pyrequire = unescape ( anchor .get ('data-requires-python' ) )
840845 yield Link (url , self , requires_python = pyrequire )
841846
842847 _clean_re = re .compile (r'[^a-z0-9$&+,/:;=?@.#%_\\|-]' , re .I )
@@ -857,13 +862,11 @@ def __init__(self, url, comes_from=None, requires_python=None):
857862
858863 url:
859864 url of the resource pointed to (href of the link)
860- comes_form :
865+ comes_from :
861866 <Not sure>
862867 requires_python:
863868 String containing the `Requires-Python` metadata field, specified
864- in PEP 345. This is to understand pep 503. The `requires_python`
865- string will be unescaped as pep 503 requires `<` and `>` to be
866- escaped, then stored under the `requires_python` attribute.
869+ in PEP 345.
867870 """
868871
869872 # url can be a UNC windows share
@@ -875,7 +878,7 @@ def __init__(self, url, comes_from=None, requires_python=None):
875878 if not requires_python :
876879 self .requires_python = None
877880 else :
878- self .requires_python = unescape ( requires_python )
881+ self .requires_python = requires_python
879882
880883 def __str__ (self ):
881884 if self .requires_python :
0 commit comments