Skip to content

Commit dc7c55c

Browse files
committed
Only build x86_64 / Intel 10.9+ on macOS
1 parent 6732812 commit dc7c55c

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

cibuildwheel/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def main():
6161
args = parser.parse_args()
6262

6363
detect_obsolete_options()
64-
64+
6565
if args.platform != 'auto':
6666
platform = args.platform
6767
else:
@@ -97,7 +97,7 @@ def main():
9797
if platform == 'linux':
9898
repair_command_default = 'auditwheel repair -w {dest_dir} {wheel}'
9999
elif platform == 'macos':
100-
repair_command_default = 'delocate-listdeps {wheel} && delocate-wheel -w {dest_dir} {wheel}'
100+
repair_command_default = 'delocate-listdeps {wheel} && delocate-wheel --require-archs x86_64 -w {dest_dir} {wheel}'
101101
else:
102102
repair_command_default = ''
103103
repair_command = get_option_from_environment('CIBW_REPAIR_WHEEL_COMMAND', platform=platform, default=repair_command_default)

cibuildwheel/macos.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
def get_python_configurations(build_selector):
1515
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'identifier', 'url'])
1616
python_configurations = [
17-
PythonConfiguration(version='2.7', identifier='cp27-macosx_10_6_intel', url='https://www.python.org/ftp/python/2.7.17/python-2.7.17-macosx10.6.pkg'),
18-
PythonConfiguration(version='3.5', identifier='cp35-macosx_10_6_intel', url='https://www.python.org/ftp/python/3.5.4/python-3.5.4-macosx10.6.pkg'),
19-
PythonConfiguration(version='3.6', identifier='cp36-macosx_10_6_intel', url='https://www.python.org/ftp/python/3.6.8/python-3.6.8-macosx10.6.pkg'),
20-
PythonConfiguration(version='3.7', identifier='cp37-macosx_10_6_intel', url='https://www.python.org/ftp/python/3.7.6/python-3.7.6-macosx10.6.pkg'),
17+
PythonConfiguration(version='2.7', identifier='cp27-macosx_10_9_x86_64', url='https://www.python.org/ftp/python/2.7.17/python-2.7.17-macosx10.9.pkg'),
18+
PythonConfiguration(version='3.5', identifier='cp35-macosx_10_9_x86_64', url='https://www.python.org/ftp/python/3.5.4/python-3.5.4-macosx10.6.pkg'),
19+
PythonConfiguration(version='3.6', identifier='cp36-macosx_10_9_x86_64', url='https://www.python.org/ftp/python/3.6.8/python-3.6.8-macosx10.9.pkg'),
20+
PythonConfiguration(version='3.7', identifier='cp37-macosx_10_9_x86_64', url='https://www.python.org/ftp/python/3.7.6/python-3.7.6-macosx10.9.pkg'),
2121
PythonConfiguration(version='3.8', identifier='cp38-macosx_10_9_x86_64', url='https://www.python.org/ftp/python/3.8.1/python-3.8.1-macosx10.9.pkg'),
2222
]
2323

@@ -31,7 +31,8 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
3131
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
3232
repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel')
3333

34-
python_configurations = get_python_configurations(build_selector)
34+
python_configurations = get_python_configurations(build_selector, machine)
35+
3536
get_pip_url = 'https://bootstrap.pypa.io/get-pip.py'
3637
get_pip_script = '/tmp/get-pip.py'
3738

@@ -50,20 +51,19 @@ def call(args, env=None, cwd=None, shell=False):
5051
return subprocess.check_call(args, env=env, cwd=cwd, shell=shell)
5152

5253
# get latest pip once and for all
53-
54-
call(['curl', '-L', '--retry', '3', '--retry-delay', '3', '-o', get_pip_script, get_pip_url])
54+
call(['curl', '--retry', '3', '--retry-delay', '3', '-sSLo', get_pip_script, get_pip_url])
5555

5656
for config in python_configurations:
5757
# if this version of python isn't installed, get it from python.org and install
5858
python_package_identifier = 'org.python.Python.PythonFramework-%s' % config.version
5959
if python_package_identifier not in installed_system_packages:
6060
# download the pkg
61-
call(['curl', '-L', '-o', '/tmp/Python.pkg', config.url])
61+
call(['curl', '--retry', '3', '--retry-delay', '3', '-sSLo', '/tmp/Python.pkg', config.url])
6262
# install
6363
call(['sudo', 'installer', '-pkg', '/tmp/Python.pkg', '-target', '/'])
6464
# patch open ssl
6565
if config.version == '3.5':
66-
call(['curl', '-fsSLo', '/tmp/python-patch.tar.gz', 'https://github.com/mayeut/patch-macos-python-openssl/releases/download/v1.0.2t/patch-macos-python-%s-openssl-v1.0.2t.tar.gz' % config.version])
66+
call(['curl', '--retry', '3', '--retry-delay', '3', '-fsSLo', '/tmp/python-patch.tar.gz', 'https://github.com/mayeut/patch-macos-python-openssl/releases/download/v1.0.2t/patch-macos-python-%s-openssl-v1.0.2t.tar.gz' % config.version])
6767
call(['sudo', 'tar', '-C', '/Library/Frameworks/Python.framework/Versions/%s/' % config.version, '-xmf', '/tmp/python-patch.tar.gz'])
6868

6969
installation_bin_path = '/Library/Frameworks/Python.framework/Versions/{}/bin'.format(config.version)
@@ -98,6 +98,15 @@ def call(args, env=None, cwd=None, shell=False):
9898
call(['pip', '--version'], env=env)
9999
call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate'], env=env)
100100

101+
# setup target platform, only required for python 3.5
102+
current_platform = subprocess.check_output(['python', '-c', 'import distutils.util; print(distutils.util.get_platform())'], env=env)
103+
if sys.version_info[0] >= 3:
104+
current_platform = current_platform.decode('utf8')
105+
current_platform = current_platform.strip()
106+
if current_platform.endswith('intel'):
107+
env['_PYTHON_HOST_PLATFORM'] = current_platform.replace('intel', 'x86_64') # cross-compilation platform override
108+
env['ARCHFLAGS'] = '-arch x86_64' # https://github.com/python/cpython/blob/a5ed2fe0eedefa1649aa93ee74a0bafc8e628a10/Lib/_osx_support.py#L260
109+
101110
# run the before_build command
102111
if before_build:
103112
before_build_prepared = prepare_command(before_build, project=abs_project_dir)

test/shared/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ def get_platform_tags(python_abi_tag):
9090
return ['win32', 'win_amd64']
9191
elif platform == 'macos':
9292
def get_platform_tags(python_abi_tag):
93-
if python_abi_tag == 'cp38-cp38':
94-
return ['macosx_10_9_x86_64']
95-
else:
96-
return ['macosx_10_6_intel']
93+
return ['macosx_10_9_x86_64']
9794
else:
9895
raise Exception('unsupported platform')
9996

0 commit comments

Comments
 (0)