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
This commit is contained in:
@@ -193,6 +193,11 @@ def install_pypy(tmp: Path, url: str) -> Path:
|
|||||||
return installation_path / "bin" / "pypy3"
|
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(
|
def setup_python(
|
||||||
tmp: Path,
|
tmp: Path,
|
||||||
python_configuration: PythonConfiguration,
|
python_configuration: PythonConfiguration,
|
||||||
@@ -200,13 +205,11 @@ def setup_python(
|
|||||||
environment: ParsedEnvironment,
|
environment: ParsedEnvironment,
|
||||||
build_frontend: BuildFrontendName,
|
build_frontend: BuildFrontendName,
|
||||||
) -> tuple[Path, dict[str, str]]:
|
) -> 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"
|
build_frontend = "build"
|
||||||
|
|
||||||
uv_path = find_uv()
|
uv_path = find_uv()
|
||||||
use_uv = build_frontend == "build[uv]" and Version(python_configuration.version) >= Version(
|
use_uv = build_frontend == "build[uv]"
|
||||||
"3.8"
|
|
||||||
)
|
|
||||||
|
|
||||||
tmp.mkdir()
|
tmp.mkdir()
|
||||||
implementation_id = python_configuration.identifier.split("-")[0]
|
implementation_id = python_configuration.identifier.split("-")[0]
|
||||||
@@ -415,9 +418,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
for config in python_configurations:
|
for config in python_configurations:
|
||||||
build_options = options.build_options(config.identifier)
|
build_options = options.build_options(config.identifier)
|
||||||
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
|
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
|
||||||
use_uv = build_frontend.name == "build[uv]" and Version(config.version) >= Version(
|
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
|
||||||
"3.8"
|
|
||||||
)
|
|
||||||
uv_path = find_uv()
|
uv_path = find_uv()
|
||||||
if use_uv and uv_path is None:
|
if use_uv and uv_path is None:
|
||||||
msg = "uv not found"
|
msg = "uv not found"
|
||||||
|
|||||||
+13
-10
@@ -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(
|
def setup_python(
|
||||||
tmp: Path,
|
tmp: Path,
|
||||||
python_configuration: PythonConfiguration,
|
python_configuration: PythonConfiguration,
|
||||||
@@ -254,11 +262,10 @@ def setup_python(
|
|||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
assert base_python.exists()
|
assert base_python.exists()
|
||||||
|
|
||||||
use_uv = (
|
if build_frontend == "build[uv]" and not can_use_uv(python_configuration):
|
||||||
build_frontend == "build[uv]"
|
build_frontend = "build"
|
||||||
and Version(python_configuration.version) >= Version("3.8")
|
|
||||||
and not python_configuration.identifier.startswith("pp38-")
|
use_uv = build_frontend == "build[uv]"
|
||||||
)
|
|
||||||
uv_path = find_uv()
|
uv_path = find_uv()
|
||||||
|
|
||||||
log.step("Setting up build environment...")
|
log.step("Setting up build environment...")
|
||||||
@@ -368,11 +375,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
|||||||
for config in python_configurations:
|
for config in python_configurations:
|
||||||
build_options = options.build_options(config.identifier)
|
build_options = options.build_options(config.identifier)
|
||||||
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
|
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
|
||||||
use_uv = (
|
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
|
||||||
build_frontend.name == "build[uv]"
|
|
||||||
and Version(config.version) >= Version("3.8")
|
|
||||||
and not config.identifier.startswith("pp38-")
|
|
||||||
)
|
|
||||||
log.build_start(config.identifier)
|
log.build_start(config.identifier)
|
||||||
|
|
||||||
identifier_tmp_dir = tmp_path / config.identifier
|
identifier_tmp_dir = tmp_path / config.identifier
|
||||||
|
|||||||
Reference in New Issue
Block a user