Skip to content

Commit 33da1f7

Browse files
authored
fix: do not use uv to setup python on windows when conditions are not met (#2005)
* fix: do not use `uv` to setup python on windows when conditions are not met * add `can_use_uv` on macOS
1 parent 79b0dd3 commit 33da1f7

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

cibuildwheel/macos.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,23 @@ def install_pypy(tmp: Path, url: str) -> Path:
193193
return installation_path / "bin" / "pypy3"
194194

195195

196+
def can_use_uv(python_configuration: PythonConfiguration) -> bool:
197+
conditions = (Version(python_configuration.version) >= Version("3.8"),)
198+
return all(conditions)
199+
200+
196201
def setup_python(
197202
tmp: Path,
198203
python_configuration: PythonConfiguration,
199204
dependency_constraint_flags: Sequence[PathOrStr],
200205
environment: ParsedEnvironment,
201206
build_frontend: BuildFrontendName,
202207
) -> tuple[Path, dict[str, str]]:
203-
if build_frontend == "build[uv]" and Version(python_configuration.version) < Version("3.8"):
208+
if build_frontend == "build[uv]" and not can_use_uv(python_configuration):
204209
build_frontend = "build"
205210

206211
uv_path = find_uv()
207-
use_uv = build_frontend == "build[uv]" and Version(python_configuration.version) >= Version(
208-
"3.8"
209-
)
212+
use_uv = build_frontend == "build[uv]"
210213

211214
tmp.mkdir()
212215
implementation_id = python_configuration.identifier.split("-")[0]
@@ -415,9 +418,7 @@ def build(options: Options, tmp_path: Path) -> None:
415418
for config in python_configurations:
416419
build_options = options.build_options(config.identifier)
417420
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
418-
use_uv = build_frontend.name == "build[uv]" and Version(config.version) >= Version(
419-
"3.8"
420-
)
421+
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
421422
uv_path = find_uv()
422423
if use_uv and uv_path is None:
423424
msg = "uv not found"

cibuildwheel/windows.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ def setup_rust_cross_compile(
225225
)
226226

227227

228+
def can_use_uv(python_configuration: PythonConfiguration) -> bool:
229+
conditions = (
230+
Version(python_configuration.version) >= Version("3.8"),
231+
not python_configuration.identifier.startswith("pp38-"),
232+
)
233+
return all(conditions)
234+
235+
228236
def setup_python(
229237
tmp: Path,
230238
python_configuration: PythonConfiguration,
@@ -254,11 +262,10 @@ def setup_python(
254262
raise ValueError(msg)
255263
assert base_python.exists()
256264

257-
use_uv = (
258-
build_frontend == "build[uv]"
259-
and Version(python_configuration.version) >= Version("3.8")
260-
and not python_configuration.identifier.startswith("pp38-")
261-
)
265+
if build_frontend == "build[uv]" and not can_use_uv(python_configuration):
266+
build_frontend = "build"
267+
268+
use_uv = build_frontend == "build[uv]"
262269
uv_path = find_uv()
263270

264271
log.step("Setting up build environment...")
@@ -368,11 +375,7 @@ def build(options: Options, tmp_path: Path) -> None:
368375
for config in python_configurations:
369376
build_options = options.build_options(config.identifier)
370377
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
371-
use_uv = (
372-
build_frontend.name == "build[uv]"
373-
and Version(config.version) >= Version("3.8")
374-
and not config.identifier.startswith("pp38-")
375-
)
378+
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
376379
log.build_start(config.identifier)
377380

378381
identifier_tmp_dir = tmp_path / config.identifier

0 commit comments

Comments
 (0)