Skip to content

Commit

Permalink
Using C:\cibw as base folder for PyPy installation (cfr. pypa#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickJadoul committed Dec 12, 2019
1 parent 366cc5a commit 28f7339
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 22 deletions.
55 changes: 41 additions & 14 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def get_python_configurations(build_selector):
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'),
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'),
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'),
PythonConfiguration(version='2.7-v7.2.0', identifier='pp272-macosx_10_7_x86_64', url='https://bitbucket.org/pypy/pypy/downloads/pypy2.7-v7.2.0-osx64.tar.bz2'),
PythonConfiguration(version='3.6-v7.2.0', identifier='pp372-macosx_10_13_x86_64', url='https://bitbucket.org/pypy/pypy/downloads/pypy3.6-v7.2.0-osx64.tar.bz2'),
]

# skip builds as required
Expand Down Expand Up @@ -53,19 +55,41 @@ def call(args, env=None, cwd=None, shell=False):
call(['curl', '-L', '-o', get_pip_script, get_pip_url])

for config in python_configurations:
# if this version of python isn't installed, get it from python.org and install
python_package_identifier = 'org.python.Python.PythonFramework-%s' % config.version
if python_package_identifier not in installed_system_packages:
# download the pkg
call(['curl', '-L', '-o', '/tmp/Python.pkg', config.url])
# install
call(['sudo', 'installer', '-pkg', '/tmp/Python.pkg', '-target', '/'])
# patch open ssl
if config.version == '3.5':
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])
call(['sudo', 'tar', '-C', '/Library/Frameworks/Python.framework/Versions/%s/' % config.version, '-xmf', '/tmp/python-patch.tar.gz'])

installation_bin_path = '/Library/Frameworks/Python.framework/Versions/{}/bin'.format(config.version)
if config.identifier.startswith('cp'):
# if this version of python isn't installed, get it from python.org and install
python_package_identifier = 'org.python.Python.PythonFramework-%s' % config.version
if python_package_identifier not in installed_system_packages:
# download the pkg
call(['curl', '-L', '-o', '/tmp/Python.pkg', config.url])
# install
call(['sudo', 'installer', '-pkg', '/tmp/Python.pkg', '-target', '/'])
# patch open ssl
if config.version == '3.5':
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])
call(['sudo', 'tar', '-C', '/Library/Frameworks/Python.framework/Versions/%s/' % config.version, '-xmf', '/tmp/python-patch.tar.gz'])

installation_bin_path = '/Library/Frameworks/Python.framework/Versions/{}/bin'.format(config.version)
elif config.identifier.startswith('pp'):
pypy_tar_bz2 = config.url.rsplit('/', 1)[-1]
assert pypy_tar_bz2.endswith(".tar.bz2")
pypy_base_filename = os.path.splitext(os.path.splitext(pypy_tar_bz2)[0])[0]
installation_bin_path = os.path.join('/tmp', pypy_base_filename, 'bin')
if not os.path.exists(installation_bin_path):
call(['curl', '-L', '-o', os.path.join("/tmp", pypy_tar_bz2), config.url])
call(['tar', '-C', '/tmp', '-xf', os.path.join("/tmp", pypy_tar_bz2)])
pypy_executable = 'pypy' if config.version[0] == '2' else 'pypy3'
python_symlink = 'python' if config.version[0] == '2' else 'python3'
os.symlink(os.path.join(installation_bin_path, pypy_executable), os.path.join(installation_bin_path, python_symlink))

# Workaround for a too high 'MACOSX_DEPLOYMENT_TARGET' in PyPy 2.7, v7.2.0; fixed in HEAD and next release
if config.version[0] == '2':
sysconfig_pypy_path = os.path.join('/tmp', pypy_base_filename, 'lib-python', '2.7', 'distutils', 'sysconfig_pypy.py')
with open(sysconfig_pypy_path, 'r') as f:
sysconfig_pypy_contents = f.read()
sysconfig_pypy_contents = sysconfig_pypy_contents.replace("g['MACOSX_DEPLOYMENT_TARGET'] = '10.14'", "g['MACOSX_DEPLOYMENT_TARGET'] = '10.7'")
with open(sysconfig_pypy_path, 'w') as f:
f.write(sysconfig_pypy_contents)

assert os.path.exists(os.path.join(installation_bin_path, 'python3' if config.version[0] == '3' else 'python'))

# Python bin folders on Mac don't symlink python3 to python, so we do that
Expand All @@ -85,14 +109,17 @@ def call(args, env=None, cwd=None, shell=False):
installation_bin_path,
env['PATH'],
])
# PyPy 3.6, v7.2.0 doesn't set MACOSX_DEPLOYMENT_TARGET in distutils.sysconfig, so let's set it ourselves until this gets settled
if config.identifier.startswith('pp') and config.version[0] == '3' and 'MACOSX_DEPLOYMENT_TARGET' not in env:
env['MACOSX_DEPLOYMENT_TARGET'] = '10.13'
env = environment.as_dictionary(prev_environment=env)

# check what version we're on
call(['which', 'python'], env=env)
call(['python', '--version'], env=env)

# install pip & wheel
call(['python', get_pip_script, '--no-setuptools', '--no-wheel'], env=env, cwd="/tmp")
call(['python', get_pip_script], env=env, cwd="/tmp")
assert os.path.exists(os.path.join(installation_bin_path, 'pip'))
call(['pip', '--version'], env=env)
call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate'], env=env)
Expand Down
4 changes: 2 additions & 2 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_python_path(config):
elif config.identifier.startswith('pp'):
# Inside the PyPy zip file is a directory with the same name
filename = config.url.rsplit('/', 1)[-1]
return os.path.join("C:\\PyPy", os.path.splitext(filename)[0])
return os.path.join("C:\\cibw", os.path.splitext(filename)[0])


def get_nuget_args(configuration):
Expand Down Expand Up @@ -118,7 +118,7 @@ def shell(args, env=None, cwd=None):
if config.identifier.startswith('cp'):
simple_shell([nuget, "install"] + get_nuget_args(config))
elif config.identifier.startswith('pp') and not os.path.exists(config_python_path):
pypy_zip = config.url.rsplit('/', 1)[-1]
pypy_zip = os.path.join("C:\\cibw", config.url.rsplit('/', 1)[-1])
download(config.url, pypy_zip)
# Extract to the parent of config_python_path because the zip file still contains a directory
extract_zip(pypy_zip, os.path.dirname(config_python_path))
Expand Down
16 changes: 10 additions & 6 deletions test/shared/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ def expected_wheels(package_name, package_version, manylinux_versions=['manylinu
# {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform tag}.whl
# {python tag} and {abi tag} are closely related to the python interpreter used to build the wheel
# so we'll merge them below as python_abi_tag
python_abi_tags = ['cp27-cp27m', 'cp35-cp35m', 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38']
python_abi_tags = ['cp27-cp27m', 'cp35-cp35m', 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38',
'pp272-pypy_41', 'pp372-pypy3_72']
if platform == 'linux':
python_abi_tags.append('cp27-cp27mu') # python 2.7 has 2 different ABI on manylinux
# Starting out by adding PyPy support on Linux
python_abi_tags.extend(['pp272-pypy_41', 'pp372-pypy3_72'])
cp_architectures = ['x86_64', 'i686']
pp_architectures = ['x86_64']
def get_platform_tags(python_abi_tag):
Expand All @@ -92,16 +91,21 @@ def get_platform_tags(python_abi_tag):
for manylinux_version in manylinux_versions
for architecture in architectures]
elif platform == 'windows':
# Second step: adding PyPy support on Windows
python_abi_tags.extend(['pp272-pypy_41', 'pp372-pypy372'])
# The PyPy3 ABI tag for Windows will be consistent in the 7.3.0 release
python_abi_tags[python_abi_tags.index('pp372-pypy3_72')] = 'pp372-pypy372'
def get_platform_tags(python_abi_tag):
if python_abi_tag.startswith('pp'):
return ['win32']
else:
return ['win32', 'win_amd64']
elif platform == 'macos':
def get_platform_tags(python_abi_tag):
if python_abi_tag == 'cp38-cp38':
# This mess should be fixed by PR #156
if python_abi_tag == 'pp272-pypy_41':
return ['macosx_10_7_x86_64']
elif python_abi_tag == 'pp372-pypy3_72':
return ['macosx_10_13_x86_64']
elif python_abi_tag == 'cp38-cp38':
return ['macosx_10_9_x86_64']
else:
return ['macosx_10_6_intel']
Expand Down

0 comments on commit 28f7339

Please sign in to comment.