57
57
_32_BIT_INTERPRETER = sys .maxsize <= 2 ** 32
58
58
59
59
60
+ _LEGACY_MANYLINUX_MAP = {
61
+ # CentOS 7 w/ glibc 2.17 (PEP 599)
62
+ (2 , 17 ): "manylinux2014" ,
63
+ # CentOS 6 w/ glibc 2.12 (PEP 571)
64
+ (2 , 12 ): "manylinux2010" ,
65
+ # CentOS 5 w/ glibc 2.5 (PEP 513)
66
+ (2 , 5 ): "manylinux1" ,
67
+ }
68
+
69
+
60
70
class Tag (object ):
61
71
"""
62
72
A representation of the tag triple for a wheel.
@@ -494,11 +504,11 @@ def _glibc_version_string_ctypes():
494
504
495
505
496
506
# Separated out from have_compatible_glibc for easier unit testing.
497
- def _check_glibc_version (version_str , required_major , minimum_minor ):
507
+ def _check_glibc_version (version_str , tag_major , tag_minor ):
498
508
# type: (str, int, int) -> bool
499
509
# Check against requested version.
500
- major , minor = _parse_glibc_version (version_str )
501
- return major == required_major and minor >= minimum_minor
510
+ sys_major , sys_minor = _parse_glibc_version (version_str )
511
+ return ( sys_major , sys_minor ) >= ( tag_major , tag_minor )
502
512
503
513
504
514
def _parse_glibc_version (version_str ):
@@ -516,16 +526,16 @@ def _parse_glibc_version(version_str):
516
526
" got: %s" % version_str ,
517
527
RuntimeWarning ,
518
528
)
519
- return ( - 1 , - 1 )
529
+ return - 1 , - 1
520
530
return (int (m .group ("major" )), int (m .group ("minor" )))
521
531
522
532
523
- def _have_compatible_glibc (required_major , minimum_minor ):
533
+ def _have_compatible_glibc (tag_major , tag_minor ):
524
534
# type: (int, int) -> bool
525
535
version_str = _glibc_version_string ()
526
536
if version_str is None :
527
537
return False
528
- return _check_glibc_version (version_str , required_major , minimum_minor )
538
+ return _check_glibc_version (version_str , tag_major , tag_minor )
529
539
530
540
531
541
def _get_glibc_version ():
@@ -651,7 +661,7 @@ def _have_compatible_manylinux_abi(arch):
651
661
return _is_linux_armhf ()
652
662
if arch == "i686" :
653
663
return _is_linux_i686 ()
654
- return True
664
+ return arch in { "x86_64" , "aarch64" , "ppc64" , "ppc64le" , "s390x" }
655
665
656
666
657
667
def _linux_platforms (is_32bit = _32_BIT_INTERPRETER ):
@@ -664,38 +674,34 @@ def _linux_platforms(is_32bit=_32_BIT_INTERPRETER):
664
674
linux = "linux_armv7l"
665
675
_ , arch = linux .split ("_" , 1 )
666
676
if _have_compatible_manylinux_abi (arch ):
667
- map_glibc_to_manylinux = {}
668
- # glibc in manylinux2014 is 2.17
669
- min_minor = 16
670
- if arch in {"x86_64" , "i686" , "aarch64" , "armv7l" , "ppc64" , "ppc64le" , "s390x" }:
671
- # CentOS 7 w/ glibc 2.17 (PEP 599)
672
- map_glibc_to_manylinux [(2 , 17 )] = "manylinux2014"
673
- if arch in {"x86_64" , "i686" }:
674
- # CentOS 6 w/ glibc 2.12 (PEP 571)
675
- map_glibc_to_manylinux [(2 , 12 )] = "manylinux2010"
676
- # CentOS 5 w/ glibc 2.5 (PEP 513)
677
- map_glibc_to_manylinux [(2 , 5 )] = "manylinux1"
678
- # glibc in manylinux1 is 2.5
679
- min_minor = 4
680
- cur_glibc = _get_glibc_version ()
681
- manylinux_compat = False
682
- for glibc_minor in range (cur_glibc [1 ], min_minor , - 1 ):
683
- plat = "manylinux_2_{}" .format (glibc_minor )
677
+ # Oldest glibc to be supported is (2, 17).
678
+ too_old_glibc = (2 , 16 )
679
+ if arch in {"x86_64" , "i686" }:
680
+ # On x86/i686 also oldest glibc to be supported is (2, 5).
681
+ too_old_glibc = (2 , 4 )
682
+ current_glibc = _get_glibc_version ()
683
+ is_compat = False
684
+ if current_glibc [0 ] == too_old_glibc [0 ]:
685
+ min_minor = too_old_glibc [1 ]
686
+ else :
687
+ # For glibc major version x>2, oldest supported is (x, 0).
688
+ min_minor = - 1
689
+ for glibc_minor in range (current_glibc [1 ], min_minor , - 1 ):
690
+ glibc_version = (current_glibc [0 ], glibc_minor )
691
+ tag = "manylinux_{}_{}" .format (* glibc_version )
684
692
# Once _is_manylinux_compatible() is True, it is True for any
685
- # lower manylinux tag.
686
- manylinux_compat = manylinux_compat or _is_manylinux_compatible (
687
- plat , (2 , glibc_minor )
688
- )
689
- if manylinux_compat :
690
- yield linux .replace ("linux" , plat )
691
- # Handle the manylinux1, manylinux2010, manylinux2014 tags
692
- if (2 , glibc_minor ) in map_glibc_to_manylinux :
693
- plat = map_glibc_to_manylinux [(2 , glibc_minor )]
694
- manylinux_compat = manylinux_compat or _is_manylinux_compatible (
695
- plat , (2 , glibc_minor )
693
+ # lower manylinux tag for this glibc major version.
694
+ is_compat = is_compat or _is_manylinux_compatible (tag , glibc_version )
695
+ if is_compat :
696
+ yield linux .replace ("linux" , tag )
697
+ # Handle the manylinux1, manylinux2010, manylinux2014 tags.
698
+ if glibc_version in _LEGACY_MANYLINUX_MAP :
699
+ legacy_tag = _LEGACY_MANYLINUX_MAP [glibc_version ]
700
+ is_compat = is_compat or _is_manylinux_compatible (
701
+ legacy_tag , glibc_version
696
702
)
697
- if manylinux_compat :
698
- yield linux .replace ("linux" , plat )
703
+ if is_compat :
704
+ yield linux .replace ("linux" , legacy_tag )
699
705
yield linux
700
706
701
707
0 commit comments