From 40968897a8e7c7fcdc5a5ff0972894e605dc7585 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Sat, 7 Sep 2019 20:45:09 +0100 Subject: [PATCH] Test package in a virtualenv on Linux and Windows --- cibuildwheel/linux.py | 9 +++++++++ cibuildwheel/macos.py | 5 ++++- cibuildwheel/windows.py | 10 ++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 473838b0..2df50c2e 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -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} diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 3111e26f..cba86b31 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -121,11 +121,14 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef 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 diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 13fd4f54..034879e9 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -121,6 +121,16 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef 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)