From 2af85bdb44035be8049e0731c75c59292955b1f7 Mon Sep 17 00:00:00 2001 From: "Robert T. McGibbon" Date: Tue, 2 Feb 2016 00:35:20 -0800 Subject: [PATCH 1/7] Add PEP 513 support --- pip/pep425tags.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/pip/pep425tags.py b/pip/pep425tags.py index 2d91ccc6d5f..0ffe29c560d 100644 --- a/pip/pep425tags.py +++ b/pip/pep425tags.py @@ -127,6 +127,54 @@ def get_platform(): return distutils.util.get_platform().replace('.', '_').replace('-', '_') +def is_manylinux1_compatible(): + # Only Linux, and only x86-64 / i686 + if get_platform() not in ("linux_x86_64", "linux_i686"): + return False + + # "wide" Unicode mode is mandatory (always true on CPython 3.3+) + if sys.maxunicode <= 0xFFFF: + return False + + # Check for presence of _manylinux module + try: + import _manylinux + return bool(_manylinux.manylinux1_compatible) + except (ImportError, AttributeError): + # Fall through to heuristic check below + pass + + # Check glibc version. CentOS 5 uses glibc 2.5. + return have_compatible_glibc(2, 5) + + +def have_compatible_glibc(major, minimum_minor): + import ctypes + process_namespace = ctypes.CDLL(None) + try: + gnu_get_libc_version = process_namespace.gnu_get_libc_version + except AttributeError: + # Symbol doesn't exist -> therefore, we are not linked to + # glibc. + return False + + # Call gnu_get_libc_version, which returns a string like "2.5". + gnu_get_libc_version.restype = ctypes.c_char_p + version_str = gnu_get_libc_version() + # py2 / py3 compatibility: + if not isinstance(version_str, str): + version_str = version_str.decode("ascii") + + # Parse string and check against requested version. + version = [int(piece) for piece in version_str.split(".")] + assert len(version) == 2 + if major != version[0]: + return False + if minimum_minor > version[1]: + return False + return True + + def get_supported(versions=None, noarch=False): """Return a list of supported tags for each version specified in `versions`. @@ -189,6 +237,11 @@ def get_supported(versions=None, noarch=False): else: # arch pattern didn't match (?!) arches = [arch] + elif sys.platform == 'linux': + if is_manylinux1_compatible(): + arches = [arch, arch.replace('linux', 'manylinux1')] + else: + arches = [arch] else: arches = [arch] From ad2f9104c6026b780dea8d7d66849b52bf17ce1e Mon Sep 17 00:00:00 2001 From: "Robert T. McGibbon" Date: Tue, 2 Feb 2016 13:08:22 -0800 Subject: [PATCH 2/7] Add some tests for manylinux1 tags --- tests/unit/test_wheel.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py index e3b8b3d6816..6deaa5e6d26 100644 --- a/tests/unit/test_wheel.py +++ b/tests/unit/test_wheel.py @@ -396,6 +396,36 @@ def test_manual_abi_dm_flags(self): self.abi_tag_unicode('dm', {'Py_DEBUG': True, 'WITH_PYMALLOC': True}) +class TestManylinux1Tags(object): + + @patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64') + @patch('pip.pep425tags.have_compatible_glibc', lambda foo, bar: True) + @patch('sys.maxunicode', 0x10FFFF) + def test_manylinux1_1(self): + """ + Test that manylinux1 is enabled on wide unicode linux_x86_64 + """ + assert pep425tags.is_manylinux1_compatible() is True + + @patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64') + @patch('pip.pep425tags.have_compatible_glibc', lambda foo, bar: True) + @patch('sys.maxunicode', 0xFFFF) + def test_manylinux1_2(self): + """ + Test that manylinux1 is disabled on narrow unicode builds + """ + assert pep425tags.is_manylinux1_compatible() is False + + @patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64') + @patch('pip.pep425tags.have_compatible_glibc', lambda foo, bar: False) + @patch('sys.maxunicode', 0x10FFFF) + def test_manylinux1_3(self): + """ + Test that manylinux1 is disabled with incompatible glibc + """ + assert pep425tags.is_manylinux1_compatible() is False + + class TestMoveWheelFiles(object): """ Tests for moving files from wheel src to scheme paths From 372ec26d53c9e87a7413d78c26dde9fa6f0d36c1 Mon Sep 17 00:00:00 2001 From: "Robert T. McGibbon" Date: Wed, 3 Feb 2016 18:12:11 -0800 Subject: [PATCH 3/7] Add get_platform 32-bit check suggested by @njsmith --- pip/pep425tags.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pip/pep425tags.py b/pip/pep425tags.py index 0ffe29c560d..5e10055a201 100644 --- a/pip/pep425tags.py +++ b/pip/pep425tags.py @@ -124,7 +124,10 @@ def get_platform(): split_ver = release.split('.') return 'macosx_{0}_{1}_{2}'.format(split_ver[0], split_ver[1], machine) # XXX remove distutils dependency - return distutils.util.get_platform().replace('.', '_').replace('-', '_') + platform = distutils.util.get_platform().replace('.', '_').replace('-', '_') + if platform == "linux_x86_64" and sys.maxsize == 2147483647: + platform = "linux_i686" + return platform def is_manylinux1_compatible(): From 3dc019a9af473758f4ce70d842a3abd990640d8a Mon Sep 17 00:00:00 2001 From: "Robert T. McGibbon" Date: Wed, 3 Feb 2016 20:17:24 -0800 Subject: [PATCH 4/7] Fix pep8 error --- pip/pep425tags.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pip/pep425tags.py b/pip/pep425tags.py index 5e10055a201..b6e4e9f3d14 100644 --- a/pip/pep425tags.py +++ b/pip/pep425tags.py @@ -124,10 +124,10 @@ def get_platform(): split_ver = release.split('.') return 'macosx_{0}_{1}_{2}'.format(split_ver[0], split_ver[1], machine) # XXX remove distutils dependency - platform = distutils.util.get_platform().replace('.', '_').replace('-', '_') - if platform == "linux_x86_64" and sys.maxsize == 2147483647: - platform = "linux_i686" - return platform + result = distutils.util.get_platform().replace('.', '_').replace('-', '_') + if result == "linux_x86_64" and sys.maxsize == 2147483647: + result = "linux_i686" + return result def is_manylinux1_compatible(): From d7b90708dad2a9b806dae453e7bcb2568b14325c Mon Sep 17 00:00:00 2001 From: "Robert T. McGibbon" Date: Thu, 4 Feb 2016 15:52:59 -0800 Subject: [PATCH 5/7] Change style of assertions --- tests/unit/test_wheel.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py index 6deaa5e6d26..6db2f5a63ee 100644 --- a/tests/unit/test_wheel.py +++ b/tests/unit/test_wheel.py @@ -405,7 +405,7 @@ def test_manylinux1_1(self): """ Test that manylinux1 is enabled on wide unicode linux_x86_64 """ - assert pep425tags.is_manylinux1_compatible() is True + assert pep425tags.is_manylinux1_compatible() @patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64') @patch('pip.pep425tags.have_compatible_glibc', lambda foo, bar: True) @@ -414,7 +414,7 @@ def test_manylinux1_2(self): """ Test that manylinux1 is disabled on narrow unicode builds """ - assert pep425tags.is_manylinux1_compatible() is False + assert not pep425tags.is_manylinux1_compatible() @patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64') @patch('pip.pep425tags.have_compatible_glibc', lambda foo, bar: False) @@ -423,7 +423,7 @@ def test_manylinux1_3(self): """ Test that manylinux1 is disabled with incompatible glibc """ - assert pep425tags.is_manylinux1_compatible() is False + assert not pep425tags.is_manylinux1_compatible() class TestMoveWheelFiles(object): From c9a2deaafafb7c9aa256918171da2809ad0180d3 Mon Sep 17 00:00:00 2001 From: "Robert T. McGibbon" Date: Tue, 9 Feb 2016 22:43:30 -0800 Subject: [PATCH 6/7] remove special unicode check --- pip/pep425tags.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pip/pep425tags.py b/pip/pep425tags.py index b6e4e9f3d14..555afaa7946 100644 --- a/pip/pep425tags.py +++ b/pip/pep425tags.py @@ -135,10 +135,6 @@ def is_manylinux1_compatible(): if get_platform() not in ("linux_x86_64", "linux_i686"): return False - # "wide" Unicode mode is mandatory (always true on CPython 3.3+) - if sys.maxunicode <= 0xFFFF: - return False - # Check for presence of _manylinux module try: import _manylinux From 2d3a62f59bac7fc1c796b09188f2651484c02e6b Mon Sep 17 00:00:00 2001 From: "Robert T. McGibbon" Date: Tue, 9 Feb 2016 23:27:38 -0800 Subject: [PATCH 7/7] Fix tests --- tests/unit/test_wheel.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py index 6db2f5a63ee..7df46b1e817 100644 --- a/tests/unit/test_wheel.py +++ b/tests/unit/test_wheel.py @@ -400,31 +400,28 @@ class TestManylinux1Tags(object): @patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64') @patch('pip.pep425tags.have_compatible_glibc', lambda foo, bar: True) - @patch('sys.maxunicode', 0x10FFFF) def test_manylinux1_1(self): """ - Test that manylinux1 is enabled on wide unicode linux_x86_64 + Test that manylinux1 is enabled on linux_x86_64 """ assert pep425tags.is_manylinux1_compatible() - @patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64') - @patch('pip.pep425tags.have_compatible_glibc', lambda foo, bar: True) - @patch('sys.maxunicode', 0xFFFF) - def test_manylinux1_2(self): - """ - Test that manylinux1 is disabled on narrow unicode builds - """ - assert not pep425tags.is_manylinux1_compatible() @patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64') @patch('pip.pep425tags.have_compatible_glibc', lambda foo, bar: False) - @patch('sys.maxunicode', 0x10FFFF) def test_manylinux1_3(self): """ Test that manylinux1 is disabled with incompatible glibc """ assert not pep425tags.is_manylinux1_compatible() + @patch('pip.pep425tags.get_platform', lambda: 'arm6vl') + @patch('pip.pep425tags.have_compatible_glibc', lambda foo, bar: True) + def test_manylinux1_3(self): + """ + Test that manylinux1 is disabled on arm6vl + """ + assert not pep425tags.is_manylinux1_compatible() class TestMoveWheelFiles(object): """