fix: support uv on android (#2733)
This commit is contained in:
@@ -190,7 +190,7 @@ def setup_env(
|
|||||||
"""
|
"""
|
||||||
log.step("Setting up build environment...")
|
log.step("Setting up build environment...")
|
||||||
build_frontend = build_options.build_frontend.name
|
build_frontend = build_options.build_frontend.name
|
||||||
use_uv = build_frontend == "build[uv]"
|
use_uv = build_frontend in {"build[uv]", "uv"}
|
||||||
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"
|
||||||
@@ -228,8 +228,8 @@ def setup_env(
|
|||||||
android_env = setup_android_env(config, python_dir, venv_dir, build_env)
|
android_env = setup_android_env(config, python_dir, venv_dir, build_env)
|
||||||
|
|
||||||
# Install build tools
|
# Install build tools
|
||||||
if build_frontend not in {"build", "build[uv]"}:
|
if build_frontend not in {"build", "build[uv]", "uv"}:
|
||||||
msg = "Android requires the build frontend to be 'build'"
|
msg = "Android requires the build frontend to be 'build' or 'uv'"
|
||||||
raise errors.FatalError(msg)
|
raise errors.FatalError(msg)
|
||||||
call(*pip, "install", "build", *constraint_flags(dependency_constraint), env=build_env)
|
call(*pip, "install", "build", *constraint_flags(dependency_constraint), env=build_env)
|
||||||
|
|
||||||
@@ -442,22 +442,44 @@ def before_build(state: BuildState) -> None:
|
|||||||
def build_wheel(state: BuildState) -> Path:
|
def build_wheel(state: BuildState) -> Path:
|
||||||
log.step("Building wheel...")
|
log.step("Building wheel...")
|
||||||
built_wheel_dir = state.build_path / "built_wheel"
|
built_wheel_dir = state.build_path / "built_wheel"
|
||||||
call(
|
match state.options.build_frontend.name:
|
||||||
"python",
|
case "build" | "build[uv]":
|
||||||
"-m",
|
call(
|
||||||
"build",
|
"python",
|
||||||
state.options.package_dir,
|
"-m",
|
||||||
"--wheel",
|
"build",
|
||||||
"--no-isolation",
|
state.options.package_dir,
|
||||||
"--skip-dependency-check",
|
"--wheel",
|
||||||
f"--outdir={built_wheel_dir}",
|
"--no-isolation",
|
||||||
*get_build_frontend_extra_flags(
|
"--skip-dependency-check",
|
||||||
state.options.build_frontend,
|
f"--outdir={built_wheel_dir}",
|
||||||
state.options.build_verbosity,
|
*get_build_frontend_extra_flags(
|
||||||
state.options.config_settings,
|
state.options.build_frontend,
|
||||||
),
|
state.options.build_verbosity,
|
||||||
env=state.android_env,
|
state.options.config_settings,
|
||||||
)
|
),
|
||||||
|
env=state.android_env,
|
||||||
|
)
|
||||||
|
case "uv":
|
||||||
|
uv_path = find_uv()
|
||||||
|
assert uv_path is not None
|
||||||
|
call(
|
||||||
|
uv_path,
|
||||||
|
"build",
|
||||||
|
state.options.package_dir,
|
||||||
|
"--wheel",
|
||||||
|
"--no-build-isolation",
|
||||||
|
f"--out-dir={built_wheel_dir}",
|
||||||
|
*get_build_frontend_extra_flags(
|
||||||
|
state.options.build_frontend,
|
||||||
|
state.options.build_verbosity,
|
||||||
|
state.options.config_settings,
|
||||||
|
),
|
||||||
|
env=state.android_env,
|
||||||
|
)
|
||||||
|
case x:
|
||||||
|
msg = f"Invalid build backend {x!r}"
|
||||||
|
raise AssertionError(msg)
|
||||||
|
|
||||||
built_wheels = list(built_wheel_dir.glob("*.whl"))
|
built_wheels = list(built_wheel_dir.glob("*.whl"))
|
||||||
if len(built_wheels) != 1:
|
if len(built_wheels) != 1:
|
||||||
|
|||||||
@@ -178,8 +178,6 @@ def build_frontend_env(request: pytest.FixtureRequest) -> dict[str, str]:
|
|||||||
|
|
||||||
if platform in {"pyodide", "ios", "android"} and frontend == "pip":
|
if platform in {"pyodide", "ios", "android"} and frontend == "pip":
|
||||||
pytest.skip(f"Can't use pip as build frontend for {platform}")
|
pytest.skip(f"Can't use pip as build frontend for {platform}")
|
||||||
if platform == "android" and frontend == "uv":
|
|
||||||
pytest.skip(f"Can't use uv as build frontend for {platform}")
|
|
||||||
if platform == "pyodide" and frontend in {"build[uv]", "uv"}:
|
if platform == "pyodide" and frontend in {"build[uv]", "uv"}:
|
||||||
pytest.skip("Can't use uv with pyodide yet")
|
pytest.skip("Can't use uv with pyodide yet")
|
||||||
uv_path = find_uv()
|
uv_path = find_uv()
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ def test_frontend_good(tmp_path, build_frontend_env):
|
|||||||
assert wheels == [f"spam-0.1.0-cp313-cp313-android_21_{native_arch.android_abi}.whl"]
|
assert wheels == [f"spam-0.1.0-cp313-cp313-android_21_{native_arch.android_abi}.whl"]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("frontend", ["pip", "uv"])
|
@pytest.mark.parametrize("frontend", ["pip"])
|
||||||
def test_frontend_bad(frontend, tmp_path, capfd):
|
def test_frontend_bad(frontend, tmp_path, capfd):
|
||||||
new_c_project().generate(tmp_path)
|
new_c_project().generate(tmp_path)
|
||||||
with pytest.raises(CalledProcessError):
|
with pytest.raises(CalledProcessError):
|
||||||
|
|||||||
Reference in New Issue
Block a user