Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run 32-bit tests on macOS #202

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 49 additions & 33 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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')

Expand Down Expand Up @@ -122,39 +123,54 @@ def call(args, env=None, cwd=None, shell=False):
repaired_wheel = glob(os.path.join(repaired_wheel_dir, '*.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', repaired_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 repaired_wheel.endswith('_intel.whl') 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', repaired_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(repaired_wheel))
Expand Down