@@ -256,10 +256,20 @@ def _get_html_page(link, session=None):
256
256
return None
257
257
258
258
259
- def _check_link_requires_python (link , version_info ):
259
+ def _check_link_requires_python (
260
+ link , # type: Link
261
+ version_info , # type: Tuple[int, ...]
262
+ ignore_requires_python = False , # type: bool
263
+ ):
264
+ # type: (...) -> bool
260
265
"""
261
- Return whether the link's Requires-Python supports the given Python
262
- version.
266
+ Return whether the given Python version is compatible with a link's
267
+ "Requires-Python" value.
268
+
269
+ :param version_info: The Python version to use to check, as a 3-tuple
270
+ of ints (major-minor-micro).
271
+ :param ignore_requires_python: Whether to ignore the "Requires-Python"
272
+ value if the given Python version isn't compatible.
263
273
"""
264
274
try :
265
275
support_this_python = check_requires_python (
@@ -273,11 +283,18 @@ def _check_link_requires_python(link, version_info):
273
283
else :
274
284
if not support_this_python :
275
285
version = '.' .join (map (str , version_info ))
286
+ if not ignore_requires_python :
287
+ logger .debug (
288
+ 'Link requires a different Python (%s not in: %r): %s' ,
289
+ version , link .requires_python , link ,
290
+ )
291
+ return False
292
+
276
293
logger .debug (
277
- 'Link requires a different Python (%s not in: %r): %s' ,
294
+ 'Ignoring failed Requires-Python check (%s not in: %r) '
295
+ 'for link: %s' ,
278
296
version , link .requires_python , link ,
279
297
)
280
- return False
281
298
282
299
return True
283
300
@@ -295,6 +312,7 @@ def __init__(
295
312
prefer_binary = False , # type: bool
296
313
allow_all_prereleases = False , # type: bool
297
314
py_version_info = None , # type: Optional[Tuple[int, ...]]
315
+ ignore_requires_python = None , # type: Optional[bool]
298
316
):
299
317
# type: (...) -> None
300
318
"""
@@ -303,12 +321,17 @@ def __init__(
303
321
representing a major-minor-micro version, to use to check both
304
322
the Python version embedded in the filename and the package's
305
323
"Requires-Python" metadata. Defaults to `sys.version_info[:3]`.
324
+ :param ignore_requires_python: Whether to ignore incompatible
325
+ "Requires-Python" values in links. Defaults to False.
306
326
"""
307
327
if py_version_info is None :
308
328
py_version_info = sys .version_info [:3 ]
329
+ if ignore_requires_python is None :
330
+ ignore_requires_python = False
309
331
310
332
py_version = '.' .join (map (str , py_version_info [:2 ]))
311
333
334
+ self ._ignore_requires_python = ignore_requires_python
312
335
self ._prefer_binary = prefer_binary
313
336
self ._py_version = py_version
314
337
self ._py_version_info = py_version_info
@@ -383,6 +406,7 @@ def evaluate_link(self, link, search):
383
406
384
407
supports_python = _check_link_requires_python (
385
408
link , version_info = self ._py_version_info ,
409
+ ignore_requires_python = self ._ignore_requires_python ,
386
410
)
387
411
if not supports_python :
388
412
# Return None for the reason text to suppress calling
@@ -575,7 +599,8 @@ def create(
575
599
versions = None , # type: Optional[List[str]]
576
600
abi = None , # type: Optional[str]
577
601
implementation = None , # type: Optional[str]
578
- prefer_binary = False # type: bool
602
+ prefer_binary = False , # type: bool
603
+ ignore_requires_python = None , # type: Optional[bool]
579
604
):
580
605
# type: (...) -> PackageFinder
581
606
"""Create a PackageFinder.
@@ -599,6 +624,8 @@ def create(
599
624
to pep425tags.py in the get_supported() method.
600
625
:param prefer_binary: Whether to prefer an old, but valid, binary
601
626
dist over a new source dist.
627
+ :param ignore_requires_python: Whether to ignore incompatible
628
+ "Requires-Python" values in links. Defaults to False.
602
629
"""
603
630
if session is None :
604
631
raise TypeError (
@@ -634,6 +661,7 @@ def create(
634
661
candidate_evaluator = CandidateEvaluator (
635
662
valid_tags = valid_tags , prefer_binary = prefer_binary ,
636
663
allow_all_prereleases = allow_all_prereleases ,
664
+ ignore_requires_python = ignore_requires_python ,
637
665
)
638
666
639
667
# If we don't have TLS enabled, then WARN if anyplace we're looking
0 commit comments