From f752e9c307463a8225325e377ef21fb5af702b5a Mon Sep 17 00:00:00 2001 From: MinRK Date: Sun, 12 Jan 2014 13:22:18 -0800 Subject: [PATCH 1/5] support earlier OS X versions in wheels Wheels built for 10.6 (e.g. Python.org) work on later OS X (e.g. System Python). The reverse is not assumed. --- pip/pep425tags.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pip/pep425tags.py b/pip/pep425tags.py index b760c922c5d..285cf364246 100644 --- a/pip/pep425tags.py +++ b/pip/pep425tags.py @@ -1,5 +1,6 @@ """Generate and work with PEP 425 Compatibility Tags.""" +import re import sys import warnings @@ -10,6 +11,8 @@ import distutils.sysconfig as sysconfig import distutils.util +_osx_arch_pat = re.compile(r'(.+)_(\d+)_(\d+)_(.+)') + def get_abbr_impl(): """Return abbreviated implementation name.""" @@ -77,10 +80,23 @@ def get_supported(versions=None, noarch=False): if not noarch: arch = get_platform() + if sys.platform == 'darwin': + # support macosx-10.6-intel on macosx-10.9-intel + match = _osx_arch_pat.match(arch) + if match: + name, major, minor, actual_arch = match.groups() + tpl = '{}_{}_%i_{}'.format(name, major, actual_arch) + arches = [tpl % m for m in range(int(minor))] + else: + # arch pattern didn't match (?!) + arches = [arch] + else: + arches = [arch] # Current version, current API (built specifically for our Python): for abi in abis: - supported.append(('%s%s' % (impl, versions[0]), abi, arch)) + for arch in arches: + supported.append(('%s%s' % (impl, versions[0]), abi, arch)) # No abi / arch, but requires our implementation: for i, version in enumerate(versions): From 6d1e9b4eabf537353b1f3cfb7d8c476c6d05a4fe Mon Sep 17 00:00:00 2001 From: MinRK Date: Sun, 12 Jan 2014 13:22:36 -0800 Subject: [PATCH 2/5] test OS X arch support --- tests/unit/test_wheel.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py index 5b813a91597..3c2de8be96e 100644 --- a/tests/unit/test_wheel.py +++ b/tests/unit/test_wheel.py @@ -5,7 +5,7 @@ from mock import patch, Mock from pip._vendor import pkg_resources -from pip import wheel +from pip import pep425tags, wheel from pip.exceptions import InvalidWheelFilename, UnsupportedWheel from pip.util import unpack_file @@ -149,6 +149,24 @@ def test_not_supported_version(self): w = wheel.Wheel('simple-0.1-py2-none-any.whl') assert not w.supported(tags=[('py1', 'none', 'any')]) + def test_supported_arch_darwin(self): + """ + Wheels built for OS X 10.6 are supported on 10.9 + """ + with patch('pip.pep425tags.get_platform', lambda : 'macosx_10_9_intel'): + tags = pep425tags.get_supported(['27'], False) + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_6_intel.whl') + assert w.supported(tags=tags) + + def test_not_supported_arch_darwin(self): + """ + Wheels built for OS X 10.9 are not supported on 10.6 + """ + with patch('pip.pep425tags.get_platform', lambda : 'macosx_10_6_intel'): + tags = pep425tags.get_supported(['27'], False) + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_9_intel.whl') + assert not w.supported(tags=tags) + def test_support_index_min(self): """ Test results from `support_index_min` From a954a72a652de07468362c06aff3e8c6951f9a14 Mon Sep 17 00:00:00 2001 From: MinRK Date: Sun, 23 Feb 2014 22:59:57 -0800 Subject: [PATCH 3/5] support intel and universal multi-arch tags on OS X - intel == x86_64, i386 - universal == x86_64, i386, ppc, ppc64 --- pip/pep425tags.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pip/pep425tags.py b/pip/pep425tags.py index 285cf364246..0778f092a97 100644 --- a/pip/pep425tags.py +++ b/pip/pep425tags.py @@ -85,8 +85,16 @@ def get_supported(versions=None, noarch=False): match = _osx_arch_pat.match(arch) if match: name, major, minor, actual_arch = match.groups() - tpl = '{}_{}_%i_{}'.format(name, major, actual_arch) - arches = [tpl % m for m in range(int(minor))] + actual_arches = [actual_arch] + if actual_arch in ('i386', 'x86_64'): + actual_arches.append('intel') + if actual_arch in ('i386', 'x86_64', 'intel', 'ppc', 'ppc64'): + actual_arches.append('universal') + tpl = '{0}_{1}_%i_%s'.format(name, major) + arches = [] + for m in range(int(minor) + 1): + for a in actual_arches: + arches.append(tpl % (m, a)) else: # arch pattern didn't match (?!) arches = [arch] From 471f7b4e8c312f56dd1607797d2fe6d323aedbb8 Mon Sep 17 00:00:00 2001 From: MinRK Date: Sun, 23 Feb 2014 23:24:48 -0800 Subject: [PATCH 4/5] test multi-arch wheels on darwin --- tests/unit/test_wheel.py | 78 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py index 3c2de8be96e..3f9acb905f2 100644 --- a/tests/unit/test_wheel.py +++ b/tests/unit/test_wheel.py @@ -149,24 +149,90 @@ def test_not_supported_version(self): w = wheel.Wheel('simple-0.1-py2-none-any.whl') assert not w.supported(tags=[('py1', 'none', 'any')]) - def test_supported_arch_darwin(self): + @patch('sys.platform', 'darwin') + @patch('pip.pep425tags.get_abbr_impl', lambda: 'cp') + @patch('pip.pep425tags.get_platform', lambda: 'macosx_10_9_intel') + def test_supported_osx_version(self): """ Wheels built for OS X 10.6 are supported on 10.9 """ - with patch('pip.pep425tags.get_platform', lambda : 'macosx_10_9_intel'): - tags = pep425tags.get_supported(['27'], False) + tags = pep425tags.get_supported(['27'], False) w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_6_intel.whl') assert w.supported(tags=tags) + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_9_intel.whl') + assert w.supported(tags=tags) - def test_not_supported_arch_darwin(self): + @patch('sys.platform', 'darwin') + @patch('pip.pep425tags.get_abbr_impl', lambda: 'cp') + @patch('pip.pep425tags.get_platform', lambda: 'macosx_10_6_intel') + def test_not_supported_osx_version(self): """ Wheels built for OS X 10.9 are not supported on 10.6 """ - with patch('pip.pep425tags.get_platform', lambda : 'macosx_10_6_intel'): - tags = pep425tags.get_supported(['27'], False) + tags = pep425tags.get_supported(['27'], False) w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_9_intel.whl') assert not w.supported(tags=tags) + @patch('sys.platform', 'darwin') + @patch('pip.pep425tags.get_abbr_impl', lambda: 'cp') + def test_supported_multiarch_darwin(self): + """ + Multi-arch wheels (intel) are supported on components (i386, x86_64) + """ + with patch('pip.pep425tags.get_platform', + lambda: 'macosx_10_5_universal'): + universal = pep425tags.get_supported(['27'], False) + with patch('pip.pep425tags.get_platform', + lambda: 'macosx_10_5_intel'): + intel = pep425tags.get_supported(['27'], False) + with patch('pip.pep425tags.get_platform', + lambda: 'macosx_10_5_x86_64'): + x64 = pep425tags.get_supported(['27'], False) + with patch('pip.pep425tags.get_platform', + lambda: 'macosx_10_5_i386'): + i386 = pep425tags.get_supported(['27'], False) + with patch('pip.pep425tags.get_platform', + lambda: 'macosx_10_5_ppc'): + ppc = pep425tags.get_supported(['27'], False) + with patch('pip.pep425tags.get_platform', + lambda: 'macosx_10_5_ppc64'): + ppc64 = pep425tags.get_supported(['27'], False) + + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_5_intel.whl') + assert w.supported(tags=intel) + assert w.supported(tags=x64) + assert w.supported(tags=i386) + assert not w.supported(tags=universal) + assert not w.supported(tags=ppc) + assert not w.supported(tags=ppc64) + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_5_universal.whl') + assert w.supported(tags=universal) + assert w.supported(tags=intel) + assert w.supported(tags=x64) + assert w.supported(tags=i386) + assert w.supported(tags=ppc) + assert w.supported(tags=ppc64) + + @patch('sys.platform', 'darwin') + @patch('pip.pep425tags.get_abbr_impl', lambda: 'cp') + def test_not_supported_multiarch_darwin(self): + """ + Single-arch wheels (x86_64) are not supported on multi-arch (intel) + """ + with patch('pip.pep425tags.get_platform', + lambda: 'macosx_10_5_universal'): + universal = pep425tags.get_supported(['27'], False) + with patch('pip.pep425tags.get_platform', + lambda: 'macosx_10_5_intel'): + intel = pep425tags.get_supported(['27'], False) + + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_5_i386.whl') + assert not w.supported(tags=intel) + assert not w.supported(tags=universal) + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_5_x86_64.whl') + assert not w.supported(tags=intel) + assert not w.supported(tags=universal) + def test_support_index_min(self): """ Test results from `support_index_min` From 27f447178b5313ff16a371e4d313ec88b4ff18f1 Mon Sep 17 00:00:00 2001 From: MinRK Date: Thu, 6 Mar 2014 17:51:51 -0800 Subject: [PATCH 5/5] add missing multi-arch tags all multi-arch tags are supported: fat, intel, fat3, fat64, universal --- pip/pep425tags.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pip/pep425tags.py b/pip/pep425tags.py index 0778f092a97..997626cf07d 100644 --- a/pip/pep425tags.py +++ b/pip/pep425tags.py @@ -81,13 +81,19 @@ def get_supported(versions=None, noarch=False): if not noarch: arch = get_platform() if sys.platform == 'darwin': - # support macosx-10.6-intel on macosx-10.9-intel + # support macosx-10.6-intel on macosx-10.9-x86_64 match = _osx_arch_pat.match(arch) if match: name, major, minor, actual_arch = match.groups() actual_arches = [actual_arch] + if actual_arch in ('i386', 'ppc'): + actual_arches.append('fat') if actual_arch in ('i386', 'x86_64'): actual_arches.append('intel') + if actual_arch in ('i386', 'ppc', 'x86_64'): + actual_arches.append('fat3') + if actual_arch in ('ppc64', 'x86_64'): + actual_arches.append('fat64') if actual_arch in ('i386', 'x86_64', 'intel', 'ppc', 'ppc64'): actual_arches.append('universal') tpl = '{0}_{1}_%i_%s'.format(name, major)