diff --git a/bin/update_virtualenv.py b/bin/update_virtualenv.py index a18c5f7db..fc69cf63d 100755 --- a/bin/update_virtualenv.py +++ b/bin/update_virtualenv.py @@ -53,10 +53,6 @@ def git_ls_remote_versions(url) -> list[VersionTuple]: if version.is_prerelease: log.info("Ignoring pre-release %r", str(version)) continue - # Do not upgrade past 20.22.0 to keep python 3.6 compat - if version >= Version("20.22.0"): - log.info("Ignoring %r which is not compatible with python 3.6", str(version)) - continue versions.append(VersionTuple(version, version_string)) except InvalidVersion: log.warning("Ignoring ref %r", ref) @@ -82,15 +78,20 @@ def update_virtualenv(force: bool, level: str) -> None: original_toml = toml_file_path.read_text() with toml_file_path.open("rb") as f: - loaded_file = tomllib.load(f) - version = str(loaded_file["version"]) + configurations = tomllib.load(f) + default = configurations.pop("default") + version = str(default["version"]) versions = git_ls_remote_versions(GET_VIRTUALENV_GITHUB) if versions[0].version > Version(version): version = versions[0].version_string - result_toml = ( - f'version = "{version}"\n' - f'url = "{GET_VIRTUALENV_URL_TEMPLATE.format(version=version)}"\n' + configurations["default"] = { + "version": version, + "url": GET_VIRTUALENV_URL_TEMPLATE.format(version=version), + } + result_toml = "".join( + f'{key} = {{ version = "{value["version"]}", url = "{value["url"]}" }}\n' + for key, value in configurations.items() ) rich.print() # spacer diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 44f9ecf0e..6b219a102 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -181,7 +181,9 @@ def setup_python( log.step("Setting up build environment...") venv_path = tmp / "venv" - env = virtualenv(base_python, venv_path, dependency_constraint_flags) + env = virtualenv( + python_configuration.version, base_python, venv_path, dependency_constraint_flags + ) venv_bin_path = venv_path / "bin" assert venv_bin_path.exists() # Fix issue with site.py setting the wrong `sys.prefix`, `sys.exec_prefix`, diff --git a/cibuildwheel/resources/virtualenv.toml b/cibuildwheel/resources/virtualenv.toml index 446d0540e..8d89dc106 100644 --- a/cibuildwheel/resources/virtualenv.toml +++ b/cibuildwheel/resources/virtualenv.toml @@ -1,2 +1,2 @@ -version = "20.21.1" -url = "https://github.com/pypa/get-virtualenv/blob/20.21.1/public/virtualenv.pyz?raw=true" +py36 = { version = "20.21.1", url = "https://github.com/pypa/get-virtualenv/blob/20.21.1/public/virtualenv.pyz?raw=true" } +default = { version = "20.26.2", url = "https://github.com/pypa/get-virtualenv/blob/20.26.2/public/virtualenv.pyz?raw=true" } diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 410b1c02a..66be99ca7 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -526,12 +526,15 @@ def get_pip_version(env: Mapping[str, str]) -> str: @lru_cache(maxsize=None) -def _ensure_virtualenv() -> Path: +def _ensure_virtualenv(version: str) -> Path: + version_parts = version.split(".") + key = f"py{version_parts[0]}{version_parts[1]}" input_file = resources_dir / "virtualenv.toml" with input_file.open("rb") as f: loaded_file = tomllib.load(f) - version = str(loaded_file["version"]) - url = str(loaded_file["url"]) + configuration = loaded_file.get(key, loaded_file["default"]) + version = str(configuration["version"]) + url = str(configuration["url"]) path = CIBW_CACHE_PATH / f"virtualenv-{version}.pyz" with FileLock(str(path) + ".lock"): if not path.exists(): @@ -587,10 +590,10 @@ def _parse_constraints_for_virtualenv( def virtualenv( - python: Path, venv_path: Path, dependency_constraint_flags: Sequence[PathOrStr] + version: str, python: Path, venv_path: Path, dependency_constraint_flags: Sequence[PathOrStr] ) -> dict[str, str]: assert python.exists() - virtualenv_app = _ensure_virtualenv() + virtualenv_app = _ensure_virtualenv(version) allowed_seed_packages = ["pip", "setuptools", "wheel"] constraints = _parse_constraints_for_virtualenv( allowed_seed_packages, dependency_constraint_flags diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 13d3a1857..e661716d4 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -246,7 +246,9 @@ def setup_python( log.step("Setting up build environment...") venv_path = tmp / "venv" - env = virtualenv(base_python, venv_path, dependency_constraint_flags) + env = virtualenv( + python_configuration.version, base_python, venv_path, dependency_constraint_flags + ) # set up environment variables for run_with_env env["PYTHON_VERSION"] = python_configuration.version diff --git a/test/test_dependency_versions.py b/test/test_dependency_versions.py index 760675d74..17edd10f3 100644 --- a/test/test_dependency_versions.py +++ b/test/test_dependency_versions.py @@ -111,7 +111,6 @@ def test_dependency_constraints_file(tmp_path, build_frontend_env): """ pip=={pip} delocate=={delocate} - importlib-metadata<3,>=0.12; python_version < "3.8" """.format(**tool_versions) ) )