From 78c113781a5e2bee13c6ecce8779c207002d2996 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 9 Nov 2019 20:42:21 +0100 Subject: [PATCH] Run 32-bit tests on macOS --- cibuildwheel/macos.py | 82 ++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 40e59a864..efcc27ba1 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -73,6 +73,7 @@ def call(args, env=None, cwd=None, shell=False): if config.version[0] == '3': os.symlink(os.path.join(installation_bin_path, 'python3'), '/tmp/cibw_bin/python') + os.symlink(os.path.join(installation_bin_path, 'python3-32'), '/tmp/cibw_bin/python-32') os.symlink(os.path.join(installation_bin_path, 'python3-config'), '/tmp/cibw_bin/python-config') os.symlink(os.path.join(installation_bin_path, 'pip3'), '/tmp/cibw_bin/pip') @@ -122,39 +123,54 @@ def call(args, env=None, cwd=None, shell=False): delocated_wheel = glob('/tmp/delocated_wheel/*.whl')[0] if test_command: - # set up a virtual environment to install and test from, to make sure - # there are no dependencies that were pulled in at build time. - call(['pip', 'install', 'virtualenv'], env=env) - venv_dir = tempfile.mkdtemp() - call(['python', '-m', 'virtualenv', venv_dir], env=env) - - virtualenv_env = env.copy() - virtualenv_env['PATH'] = os.pathsep.join([ - os.path.join(venv_dir, 'bin'), - virtualenv_env['PATH'], - ]) - # Fix some weird issue with the shebang of installed scripts - # See https://github.com/theacodes/nox/issues/44 and https://github.com/pypa/virtualenv/issues/620 - virtualenv_env.pop('__PYVENV_LAUNCHER__', None) - - # check that we are using the Python from the virtual environment - call(['which', 'python'], env=virtualenv_env) - - # install the wheel - call(['pip', 'install', delocated_wheel + test_extras], env=virtualenv_env) - - # test the wheel - if test_requires: - call(['pip', 'install'] + test_requires, env=virtualenv_env) - - # run the tests from $HOME, with an absolute path in the command - # (this ensures that Python runs the tests against the installed wheel - # and not the repo code) - test_command_prepared = prepare_command(test_command, project=abs_project_dir) - call(test_command_prepared, cwd=os.environ['HOME'], env=virtualenv_env, shell=True) - - # clean up - shutil.rmtree(venv_dir) + # Because of https://github.com/pypa/virtualenv/issues/1437, we can only test + # 32-bit mode using python 3 embedded venv module. + if 'intel' in config.identifier and config.version[0] == '3': + test_drivers = ['python', 'python-32'] + else: + test_drivers = ['python'] + + for test_driver in test_drivers: + # set up a virtual environment to install and test from, to make sure + # there are no dependencies that were pulled in at build time. + if config.version[0] == '2': + call([test_driver, '-m', 'pip', 'install', 'virtualenv'], env=env) + venv_dir = tempfile.mkdtemp() + if config.version[0] == '2': + call([test_driver, '-m', 'virtualenv', venv_dir], env=env) + else: + call([test_driver, '-m', 'venv', venv_dir], env=env) + + virtualenv_env = env.copy() + virtualenv_env['PATH'] = os.pathsep.join([ + os.path.join(venv_dir, 'bin'), + virtualenv_env['PATH'], + ]) + # Fix some weird issue with the shebang of installed scripts + # See https://github.com/theacodes/nox/issues/44 and https://github.com/pypa/virtualenv/issues/620 + virtualenv_env.pop('__PYVENV_LAUNCHER__', None) + + # check that we are using the Python from the virtual environment + call(['which', 'python'], env=virtualenv_env) + + if test_driver == 'python-32': + call([test_driver, '-c', 'import sys; assert sys.maxsize < 2 ** 32'], env=virtualenv_env) + + # install the wheel + call(['pip', 'install', delocated_wheel + test_extras], env=virtualenv_env) + + # test the wheel + if test_requires: + call(['pip', 'install'] + test_requires, env=virtualenv_env) + + # run the tests from $HOME, with an absolute path in the command + # (this ensures that Python runs the tests against the installed wheel + # and not the repo code) + test_command_prepared = prepare_command(test_command, project=abs_project_dir) + call(test_command_prepared, cwd=os.environ['HOME'], env=virtualenv_env, shell=True) + + # clean up + shutil.rmtree(venv_dir) # we're all done here; move it to output (overwrite existing) dst = os.path.join(output_dir, os.path.basename(delocated_wheel))