From 5b65230f6438c3e15f0c672d2be51b3b5eac3781 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 8 May 2025 12:12:14 -0400 Subject: [PATCH] fix: virtualenv 20.31 no-wheel (#2382) * fix: virtualenv 20.31 no-wheel Signed-off-by: Henry Schreiner * fix: show failed output on failure Signed-off-by: Henry Schreiner * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update linux.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update linux.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Henry Schreiner Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- cibuildwheel/platforms/linux.py | 4 +++- cibuildwheel/venv.py | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) 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.