1111from .util import prepare_command , get_build_verbosity_extra_flags
1212
1313
14- def get_python_configurations (build_selector ):
14+ def get_python_configurations (build_selector , platform = 'intel' ):
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.5/python-3.7.5-macosx10.6.pkg' ),
17+ PythonConfiguration (version = '2.7' , identifier = 'cp27-macosx_10_6_' + platform , 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_' + platform , 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_' + platform , 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_' + platform , url = 'https://www.python.org/ftp/python/3.7.5/python-3.7.5-macosx10.6.pkg' ),
2121 PythonConfiguration (version = '3.8' , identifier = 'cp38-macosx_10_9_x86_64' , url = 'https://www.python.org/ftp/python/3.8.0/python-3.8.0-macosx10.9.pkg' ),
2222 ]
2323
@@ -26,7 +26,9 @@ def get_python_configurations(build_selector):
2626
2727
2828def build (project_dir , output_dir , test_command , test_requires , test_extras , before_build , build_verbosity , build_selector , environment ):
29- python_configurations = get_python_configurations (build_selector )
29+ platform = os .environ .get ('CIBW_MACOS_PLATFORM' , 'intel' )
30+ assert platform in ['intel' , 'x86_64' ]
31+ python_configurations = get_python_configurations (build_selector , platform )
3032 get_pip_url = 'https://bootstrap.pypa.io/get-pip.py'
3133 get_pip_script = '/tmp/get-pip.py'
3234
@@ -102,6 +104,15 @@ def call(args, env=None, cwd=None, shell=False):
102104 shutil .rmtree ('/tmp/delocated_wheel' )
103105 os .makedirs ('/tmp/delocated_wheel' )
104106
107+ # setup target platform
108+ current_platform = subprocess .check_output (['python' , '-c' , 'import distutils.util; print(distutils.util.get_platform())' ], env = env )
109+ if sys .version_info [0 ] >= 3 :
110+ current_platform = current_platform .decode ('utf8' )
111+ current_platform = current_platform .strip ()
112+ if platform == 'x86_64' and current_platform .endswith ('intel' ):
113+ env ['_PYTHON_HOST_PLATFORM' ] = current_platform .replace ('intel' , 'x86_64' ) # cross-compilation platform override
114+ env ['ARCHFLAGS' ] = '-arch x86_64' # https://github.com/python/cpython/blob/a5ed2fe0eedefa1649aa93ee74a0bafc8e628a10/Lib/_osx_support.py#L260
115+
105116 # run the before_build command
106117 if before_build :
107118 before_build_prepared = prepare_command (before_build , project = abs_project_dir )
0 commit comments