Skip to content

Commit d1a4c9c

Browse files
authored
chore: un-pin virtualenv update (#1830)
1 parent 78bca57 commit d1a4c9c

File tree

6 files changed

+26
-19
lines changed

6 files changed

+26
-19
lines changed

bin/update_virtualenv.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ def git_ls_remote_versions(url) -> list[VersionTuple]:
5353
if version.is_prerelease:
5454
log.info("Ignoring pre-release %r", str(version))
5555
continue
56-
# Do not upgrade past 20.22.0 to keep python 3.6 compat
57-
if version >= Version("20.22.0"):
58-
log.info("Ignoring %r which is not compatible with python 3.6", str(version))
59-
continue
6056
versions.append(VersionTuple(version, version_string))
6157
except InvalidVersion:
6258
log.warning("Ignoring ref %r", ref)
@@ -82,15 +78,20 @@ def update_virtualenv(force: bool, level: str) -> None:
8278

8379
original_toml = toml_file_path.read_text()
8480
with toml_file_path.open("rb") as f:
85-
loaded_file = tomllib.load(f)
86-
version = str(loaded_file["version"])
81+
configurations = tomllib.load(f)
82+
default = configurations.pop("default")
83+
version = str(default["version"])
8784
versions = git_ls_remote_versions(GET_VIRTUALENV_GITHUB)
8885
if versions[0].version > Version(version):
8986
version = versions[0].version_string
9087

91-
result_toml = (
92-
f'version = "{version}"\n'
93-
f'url = "{GET_VIRTUALENV_URL_TEMPLATE.format(version=version)}"\n'
88+
configurations["default"] = {
89+
"version": version,
90+
"url": GET_VIRTUALENV_URL_TEMPLATE.format(version=version),
91+
}
92+
result_toml = "".join(
93+
f'{key} = {{ version = "{value["version"]}", url = "{value["url"]}" }}\n'
94+
for key, value in configurations.items()
9495
)
9596

9697
rich.print() # spacer

cibuildwheel/macos.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ def setup_python(
181181

182182
log.step("Setting up build environment...")
183183
venv_path = tmp / "venv"
184-
env = virtualenv(base_python, venv_path, dependency_constraint_flags)
184+
env = virtualenv(
185+
python_configuration.version, base_python, venv_path, dependency_constraint_flags
186+
)
185187
venv_bin_path = venv_path / "bin"
186188
assert venv_bin_path.exists()
187189
# Fix issue with site.py setting the wrong `sys.prefix`, `sys.exec_prefix`,
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "20.21.1"
2-
url = "https://github.com/pypa/get-virtualenv/blob/20.21.1/public/virtualenv.pyz?raw=true"
1+
py36 = { version = "20.21.1", url = "https://github.com/pypa/get-virtualenv/blob/20.21.1/public/virtualenv.pyz?raw=true" }
2+
default = { version = "20.26.2", url = "https://github.com/pypa/get-virtualenv/blob/20.26.2/public/virtualenv.pyz?raw=true" }

cibuildwheel/util.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,15 @@ def get_pip_version(env: Mapping[str, str]) -> str:
526526

527527

528528
@lru_cache(maxsize=None)
529-
def _ensure_virtualenv() -> Path:
529+
def _ensure_virtualenv(version: str) -> Path:
530+
version_parts = version.split(".")
531+
key = f"py{version_parts[0]}{version_parts[1]}"
530532
input_file = resources_dir / "virtualenv.toml"
531533
with input_file.open("rb") as f:
532534
loaded_file = tomllib.load(f)
533-
version = str(loaded_file["version"])
534-
url = str(loaded_file["url"])
535+
configuration = loaded_file.get(key, loaded_file["default"])
536+
version = str(configuration["version"])
537+
url = str(configuration["url"])
535538
path = CIBW_CACHE_PATH / f"virtualenv-{version}.pyz"
536539
with FileLock(str(path) + ".lock"):
537540
if not path.exists():
@@ -587,10 +590,10 @@ def _parse_constraints_for_virtualenv(
587590

588591

589592
def virtualenv(
590-
python: Path, venv_path: Path, dependency_constraint_flags: Sequence[PathOrStr]
593+
version: str, python: Path, venv_path: Path, dependency_constraint_flags: Sequence[PathOrStr]
591594
) -> dict[str, str]:
592595
assert python.exists()
593-
virtualenv_app = _ensure_virtualenv()
596+
virtualenv_app = _ensure_virtualenv(version)
594597
allowed_seed_packages = ["pip", "setuptools", "wheel"]
595598
constraints = _parse_constraints_for_virtualenv(
596599
allowed_seed_packages, dependency_constraint_flags

cibuildwheel/windows.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ def setup_python(
246246

247247
log.step("Setting up build environment...")
248248
venv_path = tmp / "venv"
249-
env = virtualenv(base_python, venv_path, dependency_constraint_flags)
249+
env = virtualenv(
250+
python_configuration.version, base_python, venv_path, dependency_constraint_flags
251+
)
250252

251253
# set up environment variables for run_with_env
252254
env["PYTHON_VERSION"] = python_configuration.version

test/test_dependency_versions.py

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def test_dependency_constraints_file(tmp_path, build_frontend_env):
111111
"""
112112
pip=={pip}
113113
delocate=={delocate}
114-
importlib-metadata<3,>=0.12; python_version < "3.8"
115114
""".format(**tool_versions)
116115
)
117116
)

0 commit comments

Comments
 (0)