Skip to content

Commit

Permalink
fix: do not use uv to setup python on windows when conditions are n…
Browse files Browse the repository at this point in the history
…ot met (#2005)

* fix: do not use `uv` to setup python on windows when conditions are not met

* add `can_use_uv` on macOS
  • Loading branch information
mayeut authored Sep 16, 2024
1 parent 79b0dd3 commit 33da1f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
15 changes: 8 additions & 7 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,23 @@ def install_pypy(tmp: Path, url: str) -> Path:
return installation_path / "bin" / "pypy3"


def can_use_uv(python_configuration: PythonConfiguration) -> bool:
conditions = (Version(python_configuration.version) >= Version("3.8"),)
return all(conditions)


def setup_python(
tmp: Path,
python_configuration: PythonConfiguration,
dependency_constraint_flags: Sequence[PathOrStr],
environment: ParsedEnvironment,
build_frontend: BuildFrontendName,
) -> tuple[Path, dict[str, str]]:
if build_frontend == "build[uv]" and Version(python_configuration.version) < Version("3.8"):
if build_frontend == "build[uv]" and not can_use_uv(python_configuration):
build_frontend = "build"

uv_path = find_uv()
use_uv = build_frontend == "build[uv]" and Version(python_configuration.version) >= Version(
"3.8"
)
use_uv = build_frontend == "build[uv]"

tmp.mkdir()
implementation_id = python_configuration.identifier.split("-")[0]
Expand Down Expand Up @@ -415,9 +418,7 @@ def build(options: Options, tmp_path: Path) -> None:
for config in python_configurations:
build_options = options.build_options(config.identifier)
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
use_uv = build_frontend.name == "build[uv]" and Version(config.version) >= Version(
"3.8"
)
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
uv_path = find_uv()
if use_uv and uv_path is None:
msg = "uv not found"
Expand Down
23 changes: 13 additions & 10 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ def setup_rust_cross_compile(
)


def can_use_uv(python_configuration: PythonConfiguration) -> bool:
conditions = (
Version(python_configuration.version) >= Version("3.8"),
not python_configuration.identifier.startswith("pp38-"),
)
return all(conditions)


def setup_python(
tmp: Path,
python_configuration: PythonConfiguration,
Expand Down Expand Up @@ -254,11 +262,10 @@ def setup_python(
raise ValueError(msg)
assert base_python.exists()

use_uv = (
build_frontend == "build[uv]"
and Version(python_configuration.version) >= Version("3.8")
and not python_configuration.identifier.startswith("pp38-")
)
if build_frontend == "build[uv]" and not can_use_uv(python_configuration):
build_frontend = "build"

use_uv = build_frontend == "build[uv]"
uv_path = find_uv()

log.step("Setting up build environment...")
Expand Down Expand Up @@ -368,11 +375,7 @@ def build(options: Options, tmp_path: Path) -> None:
for config in python_configurations:
build_options = options.build_options(config.identifier)
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
use_uv = (
build_frontend.name == "build[uv]"
and Version(config.version) >= Version("3.8")
and not config.identifier.startswith("pp38-")
)
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
log.build_start(config.identifier)

identifier_tmp_dir = tmp_path / config.identifier
Expand Down

0 comments on commit 33da1f7

Please # to comment.