Skip to content

Commit

Permalink
Test package in a virtualenv on Linux and Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Sep 10, 2019
1 parent fdc2ba8 commit 4096889
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cibuildwheel/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
fi
delocated_wheel=(/tmp/delocated_wheel/*.whl)
# Set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
pip install virtualenv
virtualenv tmp-test-env
source tmp-test-env/bin/activate
# Check that we are using the Python from the virtual environment
which python
# Install the wheel we just built
"$PYBIN/pip" install "$delocated_wheel"{test_extras}
Expand Down
5 changes: 4 additions & 1 deletion cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,14 @@ def call(args, env=None, cwd=None, shell=False):
call(['delocate-wheel', '-w', '/tmp/delocated_wheel', built_wheel], env=env)
delocated_wheel = glob('/tmp/delocated_wheel/*.whl')[0]

# set up a virtual environment to install and test from
# 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(['virtualenv', venv_dir], env=env)
env['PATH'] = os.pathsep.join([os.path.join(venv_dir, 'bin'), env['PATH']])

# check that we are using the Python from the virtual environment
call(['which', 'python'], env=env)

# install the wheel
Expand Down
10 changes: 10 additions & 0 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ def shell(args, env=None, cwd=None):
shell(['pip', 'wheel', abs_project_dir, '-w', built_wheel_dir, '--no-deps'] + get_build_verbosity_extra_flags(build_verbosity), env=env)
built_wheel = glob(built_wheel_dir+'/*.whl')[0]

# set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
shell(['pip', 'install', 'virtualenv'], env=env)
venv_dir = tempfile.mkdtemp()
shell(['virtualenv', venv_dir], env=env)
env['PATH'] = os.pathsep.join([os.path.join(venv_dir, 'Scripts'), env['PATH']])

# check that we are using the Python from the virtual environment
shell(['which', 'python'], env=env)

# install the wheel
shell(['pip', 'install', built_wheel + test_extras], env=env)

Expand Down

0 comments on commit 4096889

Please sign in to comment.