diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index dc7238a6..20dae7e6 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -145,6 +145,8 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef venv_dir=`mktemp -d`/venv python -m virtualenv "$venv_dir" + export __CIBW_VIRTUALENV_PATH__=$venv_dir + # run the tests in a subshell to keep that `activate` # script from polluting the env ( diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index dd2a412b..3b3edcba 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -209,6 +209,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef os.path.join(venv_dir, 'bin'), virtualenv_env['PATH'], ]) + virtualenv_env["__CIBW_VIRTUALENV_PATH__"] = venv_dir # check that we are using the Python from the virtual environment call(['which', 'python'], env=virtualenv_env) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index bd93e1db..f179be94 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -197,6 +197,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef os.path.join(venv_dir, 'Scripts'), virtualenv_env['PATH'], ]) + virtualenv_env["__CIBW_VIRTUALENV_PATH__"] = venv_dir # check that we are using the Python from the virtual environment shell(['which', 'python'], env=virtualenv_env) diff --git a/test/02_test/test/spam_test.py b/test/02_test/test/spam_test.py index faf7e6bc..58ce05d0 100644 --- a/test/02_test/test/spam_test.py +++ b/test/02_test/test/spam_test.py @@ -1,9 +1,26 @@ +from __future__ import print_function +import os +import sys from unittest import TestCase import spam +def normalize_path(path_str): + """because of windows short path""" + return os.path.normcase(path_str).replace("vssadm~1", "vssadministrator") + + class TestSpam(TestCase): def test_system(self): self.assertEqual(0, spam.system('python -c "exit(0)"')) self.assertNotEqual(0, spam.system('python -c "exit(1)"')) + + def test_virtualenv(self): + virtualenv_path = normalize_path(os.environ.get("__CIBW_VIRTUALENV_PATH__")) + print("=[executable]", sys.executable) + print("=[spam location]", spam.__file__) + print("=[virtualenv path]", virtualenv_path) + self.assertTrue(virtualenv_path in normalize_path(sys.executable)) + self.assertTrue(virtualenv_path in normalize_path(spam.__file__)) +