diff --git a/cibuildwheel/platforms/linux.py b/cibuildwheel/platforms/linux.py index e39a24e0..28650525 100644 --- a/cibuildwheel/platforms/linux.py +++ b/cibuildwheel/platforms/linux.py @@ -353,7 +353,9 @@ def build_in_container( container.call(["uv", "venv", venv_dir, "--python", python_bin / "python"], env=env) else: # Use embedded dependencies from virtualenv to ensure determinism - venv_args = ["--no-periodic-update", "--pip=embed", "--no-setuptools", "--no-wheel"] + venv_args = ["--no-periodic-update", "--pip=embed", "--no-setuptools"] + if "38" in config.identifier: + venv_args.append("--no-wheel") container.call(["python", "-m", "virtualenv", *venv_args, venv_dir], env=env) virtualenv_env = env.copy() diff --git a/cibuildwheel/venv.py b/cibuildwheel/venv.py index 77624b68..567ba400 100644 --- a/cibuildwheel/venv.py +++ b/cibuildwheel/venv.py @@ -20,7 +20,7 @@ _IS_WIN: Final[bool] = sys.platform.startswith("win") @functools.cache -def _ensure_virtualenv(version: str) -> Path: +def _ensure_virtualenv(version: str) -> tuple[Path, Version]: version_parts = version.split(".") key = f"py{version_parts[0]}{version_parts[1]}" with resources.VIRTUALENV.open("rb") as f: @@ -32,7 +32,7 @@ def _ensure_virtualenv(version: str) -> Path: with FileLock(str(path) + ".lock"): if not path.exists(): download(url, path) - return path + return (path, Version(version)) def constraint_flags( @@ -110,10 +110,12 @@ def virtualenv( if use_uv: call("uv", "venv", venv_path, "--python", python) else: - virtualenv_app = _ensure_virtualenv(version) + virtualenv_app, virtualenv_version = _ensure_virtualenv(version) if pip_version is None: pip_version = _parse_pip_constraint_for_virtualenv(dependency_constraint) - additional_flags = [f"--pip={pip_version}", "--no-setuptools", "--no-wheel"] + additional_flags = [f"--pip={pip_version}", "--no-setuptools"] + if virtualenv_version < Version("20.31") or Version(version) < Version("3.9"): + additional_flags.append("--no-wheel") # Using symlinks to pre-installed seed packages is really the fastest way to get a virtual # environment. The initial cost is a bit higher but reusing is much faster.