From d178e453684437889a30b3ffd17e56d695fba60d Mon Sep 17 00:00:00 2001
From: timrid <6593626+timrid@users.noreply.github.com>
Date: Wed, 3 Sep 2025 16:24:33 +0200
Subject: [PATCH] Support Android platform tags (#15646)
## Summary
This implements the Android part of
https://github.com/astral-sh/uv/issues/8029
FYI: @freakboy3742 @mhsmith
## Test Plan
Create a venv with uv and run `cargo run pip install --python-platform
aarch64-linux-android pybase64`. Then the Android binary of pybase64
should be installed inside the venv.
---
crates/uv-cli/src/lib.rs | 27 +++++
crates/uv-configuration/src/target_triple.rs | 54 +++++++++
crates/uv-platform-tags/src/platform.rs | 2 +
crates/uv-platform-tags/src/platform_tag.rs | 47 ++++++--
crates/uv-platform-tags/src/tags.rs | 114 ++++++++++++++++++-
crates/uv-static/src/env_vars.rs | 6 +
docs/reference/cli.md | 29 +++++
docs/reference/environment.md | 7 ++
uv.schema.json | 10 ++
9 files changed, 283 insertions(+), 13 deletions(-)
diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs
index d0727d3d9..8ed260aca 100644
--- a/crates/uv-cli/src/lib.rs
+++ b/crates/uv-cli/src/lib.rs
@@ -1448,6 +1448,9 @@ pub struct PipCompileArgs {
///
/// When targeting macOS (Darwin), the default minimum version is `12.0`. Use
/// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `13.0`.
+ ///
+ /// When targeting Android, the default minimum Android API level is `24`. Use
+ /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`.
#[arg(long)]
pub python_platform: Option
May also be set with the UV_PYTHON environment variable.
--python-platform python-platformThe platform for which requirements should be installed.
Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aarch64-apple-darwin.
When targeting macOS (Darwin), the default minimum version is 12.0. Use MACOSX_DEPLOYMENT_TARGET to specify a different minimum version, e.g., 13.0.
When targeting Android, the default minimum Android API level is 24. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.
WARNING: When specified, uv will select wheels that are compatible with the target platform; as a result, the installed distributions may not be compatible with the current platform. Conversely, any distributions that are built from source may be incompatible with the target platform, as they will be built for the current platform. The --python-platform option is intended for advanced use cases.
Possible values:
aarch64-manylinux_2_38: An ARM64 target for the manylinux_2_38 platformaarch64-manylinux_2_39: An ARM64 target for the manylinux_2_39 platformaarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platformaarch64-linux-android: An ARM64 Android targetx86_64-linux-android: An x86_64 Android targetwasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12--quiet, -qUse quiet output.
Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.
May also be set with the UV_PYTHON environment variable.
--python-platform python-platformThe platform for which requirements should be installed.
Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aarch64-apple-darwin.
When targeting macOS (Darwin), the default minimum version is 12.0. Use MACOSX_DEPLOYMENT_TARGET to specify a different minimum version, e.g., 13.0.
When targeting Android, the default minimum Android API level is 24. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.
WARNING: When specified, uv will select wheels that are compatible with the target platform; as a result, the installed distributions may not be compatible with the current platform. Conversely, any distributions that are built from source may be incompatible with the target platform, as they will be built for the current platform. The --python-platform option is intended for advanced use cases.
Possible values:
aarch64-manylinux_2_38: An ARM64 target for the manylinux_2_38 platformaarch64-manylinux_2_39: An ARM64 target for the manylinux_2_39 platformaarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platformaarch64-linux-android: An ARM64 Android targetx86_64-linux-android: An x86_64 Android targetwasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12--quiet, -qUse quiet output.
Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.
--universal to display the tree for all platforms,
aarch64-manylinux_2_38: An ARM64 target for the manylinux_2_38 platformaarch64-manylinux_2_39: An ARM64 target for the manylinux_2_39 platformaarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platformaarch64-linux-android: An ARM64 Android targetx86_64-linux-android: An x86_64 Android targetwasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12--python-version python-versionThe Python version to use when filtering the tree.
For example, pass --python-version 3.10 to display the dependencies that would be included when installing on Python 3.10.
May also be set with the UV_PYTHON environment variable.
--python-platform python-platformThe platform for which requirements should be installed.
Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aarch64-apple-darwin.
When targeting macOS (Darwin), the default minimum version is 12.0. Use MACOSX_DEPLOYMENT_TARGET to specify a different minimum version, e.g., 13.0.
When targeting Android, the default minimum Android API level is 24. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.
WARNING: When specified, uv will select wheels that are compatible with the target platform; as a result, the installed distributions may not be compatible with the current platform. Conversely, any distributions that are built from source may be incompatible with the target platform, as they will be built for the current platform. The --python-platform option is intended for advanced use cases.
Possible values:
aarch64-manylinux_2_38: An ARM64 target for the manylinux_2_38 platformaarch64-manylinux_2_39: An ARM64 target for the manylinux_2_39 platformaarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platformaarch64-linux-android: An ARM64 Android targetx86_64-linux-android: An x86_64 Android targetwasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12--quiet, -qUse quiet output.
Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.
May also be set with the UV_PYTHON environment variable.
--python-platform python-platformThe platform for which requirements should be installed.
Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aarch64-apple-darwin.
When targeting macOS (Darwin), the default minimum version is 12.0. Use MACOSX_DEPLOYMENT_TARGET to specify a different minimum version, e.g., 13.0.
When targeting Android, the default minimum Android API level is 24. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.
WARNING: When specified, uv will select wheels that are compatible with the target platform; as a result, the installed distributions may not be compatible with the current platform. Conversely, any distributions that are built from source may be incompatible with the target platform, as they will be built for the current platform. The --python-platform option is intended for advanced use cases.
Possible values:
aarch64-manylinux_2_38: An ARM64 target for the manylinux_2_38 platformaarch64-manylinux_2_39: An ARM64 target for the manylinux_2_39 platformaarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platformaarch64-linux-android: An ARM64 Android targetx86_64-linux-android: An x86_64 Android targetwasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12--quiet, -qUse quiet output.
Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.
--all to apply to all tools.
May also be set with the UV_PYTHON environment variable.
--python-platform python-platformThe platform for which requirements should be installed.
Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aarch64-apple-darwin.
When targeting macOS (Darwin), the default minimum version is 12.0. Use MACOSX_DEPLOYMENT_TARGET to specify a different minimum version, e.g., 13.0.
When targeting Android, the default minimum Android API level is 24. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.
WARNING: When specified, uv will select wheels that are compatible with the target platform; as a result, the installed distributions may not be compatible with the current platform. Conversely, any distributions that are built from source may be incompatible with the target platform, as they will be built for the current platform. The --python-platform option is intended for advanced use cases.
Possible values:
--all to apply to all tools.
aarch64-manylinux_2_38: An ARM64 target for the manylinux_2_38 platformaarch64-manylinux_2_39: An ARM64 target for the manylinux_2_39 platformaarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platformaarch64-linux-android: An ARM64 Android targetx86_64-linux-android: An x86_64 Android targetwasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12--quiet, -qUse quiet output.
Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.
--python-version.
--python-platform python-platformThe platform for which requirements should be resolved.
Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aarch64-apple-darwin.
When targeting macOS (Darwin), the default minimum version is 12.0. Use MACOSX_DEPLOYMENT_TARGET to specify a different minimum version, e.g., 13.0.
When targeting Android, the default minimum Android API level is 24. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.
Possible values:
windows: An alias for x86_64-pc-windows-msvc, the default target for Windows--python-version.
aarch64-manylinux_2_38: An ARM64 target for the manylinux_2_38 platformaarch64-manylinux_2_39: An ARM64 target for the manylinux_2_39 platformaarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platformaarch64-linux-android: An ARM64 Android targetx86_64-linux-android: An x86_64 Android targetwasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12--python-version python-versionThe Python version to use for resolution.
For example, 3.8 or 3.8.17.
May also be set with the UV_PYTHON environment variable.
--python-platform python-platformThe platform for which requirements should be installed.
Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aarch64-apple-darwin.
When targeting macOS (Darwin), the default minimum version is 12.0. Use MACOSX_DEPLOYMENT_TARGET to specify a different minimum version, e.g., 13.0.
When targeting Android, the default minimum Android API level is 24. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.
WARNING: When specified, uv will select wheels that are compatible with the target platform; as a result, the installed distributions may not be compatible with the current platform. Conversely, any distributions that are built from source may be incompatible with the target platform, as they will be built for the current platform. The --python-platform option is intended for advanced use cases.
Possible values:
aarch64-manylinux_2_38: An ARM64 target for the manylinux_2_38 platformaarch64-manylinux_2_39: An ARM64 target for the manylinux_2_39 platformaarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platformaarch64-linux-android: An ARM64 Android targetx86_64-linux-android: An x86_64 Android targetwasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12--python-version python-versionThe minimum Python version that should be supported by the requirements (e.g., 3.7 or 3.7.9).
If a patch version is omitted, the minimum patch version is assumed. For example, 3.7 is mapped to 3.7.0.
UV_PYTHON environment variable.--python-platform python-platformThe platform for which requirements should be installed.
Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aarch64-apple-darwin.
When targeting macOS (Darwin), the default minimum version is 12.0. Use MACOSX_DEPLOYMENT_TARGET to specify a different minimum version, e.g., 13.0.
When targeting Android, the default minimum Android API level is 24. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.
WARNING: When specified, uv will select wheels that are compatible with the target platform; as a result, the installed distributions may not be compatible with the current platform. Conversely, any distributions that are built from source may be incompatible with the target platform, as they will be built for the current platform. The --python-platform option is intended for advanced use cases.
Possible values:
aarch64-manylinux_2_38: An ARM64 target for the manylinux_2_38 platform
aarch64-manylinux_2_39: An ARM64 target for the manylinux_2_39 platformaarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platformaarch64-linux-android: An ARM64 Android targetx86_64-linux-android: An x86_64 Android targetwasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12--python-version python-versionThe minimum Python version that should be supported by the requirements (e.g., 3.7 or 3.7.9).
If a patch version is omitted, the minimum patch version is assumed. For example, 3.7 is mapped to 3.7.0.
By default, the installed packages are checked against the platform of the current interpreter.
Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aarch64-apple-darwin.
When targeting macOS (Darwin), the default minimum version is 12.0. Use MACOSX_DEPLOYMENT_TARGET to specify a different minimum version, e.g., 13.0.
When targeting Android, the default minimum Android API level is 24. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.
Possible values:
windows: An alias for x86_64-pc-windows-msvc, the default target for Windowsaarch64-manylinux_2_38: An ARM64 target for the manylinux_2_38 platformaarch64-manylinux_2_39: An ARM64 target for the manylinux_2_39 platformaarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platformaarch64-linux-android: An ARM64 Android targetx86_64-linux-android: An x86_64 Android targetwasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12--python-version python-versionThe Python version against which packages should be checked.
By default, the installed packages are checked against the version of the current interpreter.
diff --git a/docs/reference/environment.md b/docs/reference/environment.md index 47c82562e..1364175f3 100644 --- a/docs/reference/environment.md +++ b/docs/reference/environment.md @@ -565,6 +565,13 @@ Used for trusted publishing via `uv publish`. Contains the oidc token url. General proxy for all network requests. +### `ANDROID_API_LEVEL` + +Used with `--python-platform aarch64-linux-android` and related variants to set the +Android API level. (i.e., the minimum supported Android API level). + +Defaults to `24`. + ### `APPDATA` Path to user-level configuration directory on Windows systems. diff --git a/uv.schema.json b/uv.schema.json index 655ce6a84..d87b50480 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -2426,6 +2426,16 @@ "type": "string", "const": "aarch64-manylinux_2_40" }, + { + "description": "An ARM64 Android target.\n\nBy default uses Android API level 24, but respects\nthe `ANDROID_API_LEVEL` environment variable if set.", + "type": "string", + "const": "aarch64-linux-android" + }, + { + "description": "An `x86_64` Android target.\n\nBy default uses Android API level 24, but respects\nthe `ANDROID_API_LEVEL` environment variable if set.", + "type": "string", + "const": "x86_64-linux-android" + }, { "description": "A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12.", "type": "string",