Skip to content

Commit c333b13

Browse files
authored
fix: include VIRTUAL_ENV variable (#1842)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 4c2ed1e commit c333b13

File tree

6 files changed

+6
-0
lines changed

6 files changed

+6
-0
lines changed

cibuildwheel/linux.py

+1
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ def build_in_container(
343343

344344
virtualenv_env = env.copy()
345345
virtualenv_env["PATH"] = f"{venv_dir / 'bin'}:{virtualenv_env['PATH']}"
346+
virtualenv_env["VIRTUAL_ENV"] = str(venv_dir)
346347

347348
# TODO remove me once virtualenv provides pip>=24.1b1
348349
if config.version == "3.13":

cibuildwheel/macos.py

+1
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ def build(options: Options, tmp_path: Path) -> None:
576576
virtualenv_env["PATH"],
577577
]
578578
)
579+
virtualenv_env["VIRTUAL_ENV"] = str(venv_dir)
579580

580581
# check that we are using the Python from the virtual environment
581582
call_with_arch("which", "python", env=virtualenv_env)

cibuildwheel/pyodide.py

+1
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ def build(options: Options, tmp_path: Path) -> None:
353353
virtualenv_env["PATH"],
354354
]
355355
)
356+
virtualenv_env["VIRTUAL_ENV"] = str(venv_dir)
356357

357358
# check that we are using the Python from the virtual environment
358359
call("which", "python", env=virtualenv_env)

cibuildwheel/util.py

+1
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ def virtualenv(
700700
paths = [str(venv_path), str(venv_path / "Scripts")] if IS_WIN else [str(venv_path / "bin")]
701701
env = os.environ.copy()
702702
env["PATH"] = os.pathsep.join([*paths, env["PATH"]])
703+
env["VIRTUAL_ENV"] = str(venv_path)
703704
return env
704705

705706

cibuildwheel/windows.py

+1
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ def build(options: Options, tmp_path: Path) -> None:
501501
virtualenv_env["PATH"],
502502
]
503503
)
504+
virtualenv_env["VIRTUAL_ENV"] = str(venv_dir)
504505

505506
# check that we are using the Python from the virtual environment
506507
call("where", "python", env=virtualenv_env)

test/test_testing.py

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def test_virtualenv(self):
5858
5959
self.assertTrue(path_contains(sys.prefix, sys.executable))
6060
self.assertTrue(path_contains(sys.prefix, spam.__file__))
61+
self.assertIn("VIRTUAL_ENV", os.environ)
6162
6263
def test_uname(self):
6364
if platform.system() == "Windows":

0 commit comments

Comments
 (0)