Skip to content

Commit c8eae11

Browse files
committed
fix: virtualenv 20.31 no-wheel
Signed-off-by: Henry Schreiner <[email protected]>
1 parent e91560e commit c8eae11

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

cibuildwheel/platforms/linux.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from pathlib import Path, PurePath, PurePosixPath
99
from typing import assert_never
1010

11+
from packaging.version import Version
12+
1113
from .. import errors
1214
from ..architecture import Architecture
1315
from ..frontend import BuildFrontendConfig, get_build_frontend_extra_flags
@@ -353,7 +355,14 @@ def build_in_container(
353355
container.call(["uv", "venv", venv_dir, "--python", python_bin / "python"], env=env)
354356
else:
355357
# Use embedded dependencies from virtualenv to ensure determinism
356-
venv_args = ["--no-periodic-update", "--pip=embed", "--no-setuptools", "--no-wheel"]
358+
venv_version = (
359+
container.call(["python", "-m", "virtualenv", "--version"], env=env)
360+
.strip()
361+
.split()[1]
362+
)
363+
venv_args = ["--no-periodic-update", "--pip=embed", "--no-setuptools"]
364+
if Version(venv_version) < Version("20.31") or "38" in config.identifier:
365+
venv_args.append("--no-wheel")
357366
container.call(["python", "-m", "virtualenv", *venv_args, venv_dir], env=env)
358367

359368
virtualenv_env = env.copy()

cibuildwheel/venv.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
@functools.cache
23-
def _ensure_virtualenv(version: str) -> Path:
23+
def _ensure_virtualenv(version: str) -> tuple[Path, Version]:
2424
version_parts = version.split(".")
2525
key = f"py{version_parts[0]}{version_parts[1]}"
2626
with resources.VIRTUALENV.open("rb") as f:
@@ -32,7 +32,7 @@ def _ensure_virtualenv(version: str) -> Path:
3232
with FileLock(str(path) + ".lock"):
3333
if not path.exists():
3434
download(url, path)
35-
return path
35+
return (path, Version(version))
3636

3737

3838
def constraint_flags(
@@ -110,10 +110,12 @@ def virtualenv(
110110
if use_uv:
111111
call("uv", "venv", venv_path, "--python", python)
112112
else:
113-
virtualenv_app = _ensure_virtualenv(version)
113+
virtualenv_app, virtualenv_version = _ensure_virtualenv(version)
114114
if pip_version is None:
115115
pip_version = _parse_pip_constraint_for_virtualenv(dependency_constraint)
116-
additional_flags = [f"--pip={pip_version}", "--no-setuptools", "--no-wheel"]
116+
additional_flags = [f"--pip={pip_version}", "--no-setuptools"]
117+
if virtualenv_version < Version("20.31") or Version(version) < Version("3.9"):
118+
additional_flags.append("--no-wheel")
117119

118120
# Using symlinks to pre-installed seed packages is really the fastest way to get a virtual
119121
# environment. The initial cost is a bit higher but reusing is much faster.

0 commit comments

Comments
 (0)