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, @@ -1775,6 +1778,9 @@ pub struct PipSyncArgs { /// 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 @@ -2078,6 +2084,9 @@ pub struct PipInstallArgs { /// 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 @@ -2400,6 +2409,9 @@ pub struct PipCheckArgs { /// /// 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, } @@ -3326,6 +3338,9 @@ pub struct RunArgs { /// 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 @@ -3603,6 +3618,9 @@ pub struct SyncArgs { /// 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 @@ -4626,6 +4644,9 @@ pub struct ToolRunArgs { /// 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 @@ -4748,6 +4769,9 @@ pub struct ToolInstallArgs { /// 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 @@ -4845,6 +4869,9 @@ pub struct ToolUpgradeArgs { /// 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 diff --git a/crates/uv-configuration/src/target_triple.rs b/crates/uv-configuration/src/target_triple.rs index 851ca125a..1fd01c1a7 100644 --- a/crates/uv-configuration/src/target_triple.rs +++ b/crates/uv-configuration/src/target_triple.rs @@ -238,6 +238,22 @@ pub enum TargetTriple { #[serde(alias = "aarch64-manylinux240")] Aarch64Manylinux240, + /// An ARM64 Android target. + /// + /// By default uses Android API level 24, but respects + /// the `ANDROID_API_LEVEL` environment variable if set. + #[cfg_attr(feature = "clap", value(name = "aarch64-linux-android"))] + #[serde(rename = "aarch64-linux-android")] + Aarch64LinuxAndroid, + + /// An `x86_64` Android target. + /// + /// By default uses Android API level 24, but respects + /// the `ANDROID_API_LEVEL` environment variable if set. + #[cfg_attr(feature = "clap", value(name = "x86_64-linux-android"))] + #[serde(rename = "x86_64-linux-android")] + X8664LinuxAndroid, + /// A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12. #[cfg_attr(feature = "clap", value(name = "wasm32-pyodide2024"))] Wasm32Pyodide2024, @@ -480,6 +496,20 @@ impl TargetTriple { }, Arch::Wasm32, ), + Self::Aarch64LinuxAndroid => { + let api_level = android_api_level().map_or(24, |api_level| { + debug!("Found Android API level: {}", api_level); + api_level + }); + Platform::new(Os::Android { api_level }, Arch::Aarch64) + } + Self::X8664LinuxAndroid => { + let api_level = android_api_level().map_or(24, |api_level| { + debug!("Found Android API level: {}", api_level); + api_level + }); + Platform::new(Os::Android { api_level }, Arch::X86_64) + } } } @@ -522,6 +552,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => "aarch64", Self::Aarch64Manylinux239 => "aarch64", Self::Aarch64Manylinux240 => "aarch64", + Self::Aarch64LinuxAndroid => "aarch64", + Self::X8664LinuxAndroid => "x86_64", Self::Wasm32Pyodide2024 => "wasm32", } } @@ -565,6 +597,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => "Linux", Self::Aarch64Manylinux239 => "Linux", Self::Aarch64Manylinux240 => "Linux", + Self::Aarch64LinuxAndroid => "Android", + Self::X8664LinuxAndroid => "Android", Self::Wasm32Pyodide2024 => "Emscripten", } } @@ -608,6 +642,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => "", Self::Aarch64Manylinux239 => "", Self::Aarch64Manylinux240 => "", + Self::Aarch64LinuxAndroid => "", + Self::X8664LinuxAndroid => "", // This is the value Emscripten gives for its version: // https://github.com/emscripten-core/emscripten/blob/4.0.8/system/lib/libc/emscripten_syscall_stubs.c#L63 // It doesn't really seem to mean anything? But for completeness we include it here. @@ -654,6 +690,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => "", Self::Aarch64Manylinux239 => "", Self::Aarch64Manylinux240 => "", + Self::Aarch64LinuxAndroid => "", + Self::X8664LinuxAndroid => "", // This is the Emscripten compiler version for Pyodide 2024. // See https://pyodide.org/en/stable/development/abi.html#pyodide-2024-0 Self::Wasm32Pyodide2024 => "3.1.58", @@ -699,6 +737,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => "posix", Self::Aarch64Manylinux239 => "posix", Self::Aarch64Manylinux240 => "posix", + Self::Aarch64LinuxAndroid => "posix", + Self::X8664LinuxAndroid => "posix", Self::Wasm32Pyodide2024 => "posix", } } @@ -742,6 +782,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => "linux", Self::Aarch64Manylinux239 => "linux", Self::Aarch64Manylinux240 => "linux", + Self::Aarch64LinuxAndroid => "android", + Self::X8664LinuxAndroid => "android", Self::Wasm32Pyodide2024 => "emscripten", } } @@ -785,6 +827,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => true, Self::Aarch64Manylinux239 => true, Self::Aarch64Manylinux240 => true, + Self::Aarch64LinuxAndroid => false, + Self::X8664LinuxAndroid => false, Self::Wasm32Pyodide2024 => false, } } @@ -818,3 +862,13 @@ fn macos_deployment_target() -> Option<(u16, u16)> { Some((major, minor)) } + +/// Return the Android API level as parsed from the environment. +fn android_api_level() -> Option { + let api_level_str = std::env::var(EnvVars::ANDROID_API_LEVEL).ok()?; + + // Parse the api level. + let api_level = api_level_str.parse::().ok()?; + + Some(api_level) +} diff --git a/crates/uv-platform-tags/src/platform.rs b/crates/uv-platform-tags/src/platform.rs index 406facd5d..62b05afe9 100644 --- a/crates/uv-platform-tags/src/platform.rs +++ b/crates/uv-platform-tags/src/platform.rs @@ -11,6 +11,8 @@ pub enum PlatformError { IOError(#[from] io::Error), #[error("Failed to detect the operating system version: {0}")] OsVersionDetectionError(String), + #[error("Failed to detect the arch: {0}")] + ArchDetectionError(String), } #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] diff --git a/crates/uv-platform-tags/src/platform_tag.rs b/crates/uv-platform-tags/src/platform_tag.rs index b970a248c..bb043b2ff 100644 --- a/crates/uv-platform-tags/src/platform_tag.rs +++ b/crates/uv-platform-tags/src/platform_tag.rs @@ -3,6 +3,7 @@ use std::str::FromStr; use uv_small_str::SmallString; +use crate::tags::AndroidAbi; use crate::{Arch, BinaryFormat}; /// A tag to represent the platform compatibility of a Python distribution. @@ -56,7 +57,7 @@ pub enum PlatformTag { /// Ex) `win_ia64` WinIa64, /// Ex) `android_21_x86_64` - Android { api_level: u16, arch: Arch }, + Android { api_level: u16, abi: AndroidAbi }, /// Ex) `freebsd_12_x86_64` FreeBsd { release_arch: SmallString }, /// Ex) `netbsd_9_x86_64` @@ -179,7 +180,7 @@ impl PlatformTag { .. } | Self::WinArm64 | Self::Android { - arch: Arch::Aarch64, + abi: AndroidAbi::Arm64V8a, .. } ) @@ -267,7 +268,7 @@ impl std::fmt::Display for PlatformTag { Self::WinAmd64 => write!(f, "win_amd64"), Self::WinArm64 => write!(f, "win_arm64"), Self::WinIa64 => write!(f, "win_ia64"), - Self::Android { api_level, arch } => write!(f, "android_{api_level}_{arch}"), + Self::Android { api_level, abi } => write!(f, "android_{api_level}_{abi}"), Self::FreeBsd { release_arch } => write!(f, "freebsd_{release_arch}"), Self::NetBsd { release_arch } => write!(f, "netbsd_{release_arch}"), Self::OpenBsd { release_arch } => write!(f, "openbsd_{release_arch}"), @@ -489,7 +490,7 @@ impl FromStr for PlatformTag { } if let Some(rest) = s.strip_prefix("android_") { - // Ex) android_21_arm64 + // Ex) android_21_arm64_v8a let underscore = memchr::memchr(b'_', rest.as_bytes()).ok_or_else(|| { ParsePlatformTagError::InvalidFormat { platform: "android", @@ -505,22 +506,22 @@ impl FromStr for PlatformTag { tag: s.to_string(), })?; - let arch_str = &rest[underscore + 1..]; - if arch_str.is_empty() { + let abi_str = &rest[underscore + 1..]; + if abi_str.is_empty() { return Err(ParsePlatformTagError::InvalidFormat { platform: "android", tag: s.to_string(), }); } - let arch = arch_str + let abi = abi_str .parse() .map_err(|_| ParsePlatformTagError::InvalidArch { platform: "android", tag: s.to_string(), })?; - return Ok(Self::Android { api_level, arch }); + return Ok(Self::Android { api_level, abi }); } if let Some(rest) = s.strip_prefix("freebsd_") { @@ -684,6 +685,7 @@ mod tests { use std::str::FromStr; use crate::platform_tag::{ParsePlatformTagError, PlatformTag}; + use crate::tags::AndroidAbi; use crate::{Arch, BinaryFormat}; #[test] @@ -964,6 +966,35 @@ mod tests { ); } + #[test] + fn android_platform() { + let tag = PlatformTag::Android { + api_level: 21, + abi: AndroidAbi::Arm64V8a, + }; + assert_eq!( + PlatformTag::from_str("android_21_arm64_v8a").as_ref(), + Ok(&tag) + ); + assert_eq!(tag.to_string(), "android_21_arm64_v8a"); + + assert_eq!( + PlatformTag::from_str("android_X_arm64_v8a"), + Err(ParsePlatformTagError::InvalidApiLevel { + platform: "android", + tag: "android_X_arm64_v8a".to_string() + }) + ); + + assert_eq!( + PlatformTag::from_str("android_21_aarch64"), + Err(ParsePlatformTagError::InvalidArch { + platform: "android", + tag: "android_21_aarch64".to_string() + }) + ); + } + #[test] fn unknown_platform() { assert_eq!( diff --git a/crates/uv-platform-tags/src/tags.rs b/crates/uv-platform-tags/src/tags.rs index b321d1d85..531b3c782 100644 --- a/crates/uv-platform-tags/src/tags.rs +++ b/crates/uv-platform-tags/src/tags.rs @@ -611,11 +611,21 @@ fn compatible_tags(platform: &Platform) -> Result, PlatformErro release_arch: SmallString::from(release_arch), }] } - (Os::Android { api_level }, _) => { - vec![PlatformTag::Android { - api_level: *api_level, - arch, - }] + (Os::Android { api_level }, arch) => { + // Source: https://github.com/pypa/packaging/blob/e5470c1854e352f68fa3f83df9cbb0af59558c49/src/packaging/tags.py#L541 + let mut platform_tags = vec![]; + + // 16 is the minimum API level known to have enough features to support CPython + // without major patching. Yield every API level from the maximum down to the + // minimum, inclusive. + for ver in (16..=*api_level).rev() { + platform_tags.push(PlatformTag::Android { + api_level: ver, + abi: AndroidAbi::from_arch(arch).map_err(PlatformError::ArchDetectionError)?, + }); + } + + platform_tags } (Os::Pyodide { major, minor }, Arch::Wasm32) => { vec![PlatformTag::Pyodide { @@ -759,6 +769,71 @@ impl BinaryFormat { } } +#[derive( + Debug, + Copy, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + Hash, + rkyv::Archive, + rkyv::Deserialize, + rkyv::Serialize, +)] +#[rkyv(derive(Debug))] +pub enum AndroidAbi { + // Source: https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/#android + ArmeabiV7a, + Arm64V8a, + X86, + X86_64, +} + +impl std::fmt::Display for AndroidAbi { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.name()) + } +} + +impl FromStr for AndroidAbi { + type Err = String; + + fn from_str(s: &str) -> Result { + match s { + "armeabi_v7a" => Ok(Self::ArmeabiV7a), + "arm64_v8a" => Ok(Self::Arm64V8a), + "x86" => Ok(Self::X86), + "x86_64" => Ok(Self::X86_64), + _ => Err(format!("Invalid Android arch format: {s}")), + } + } +} + +impl AndroidAbi { + /// Determine the appropriate Android arch. + pub fn from_arch(arch: Arch) -> Result { + match arch { + Arch::Aarch64 => Ok(Self::Arm64V8a), + Arch::Armv7L => Ok(Self::ArmeabiV7a), + Arch::X86 => Ok(Self::X86), + Arch::X86_64 => Ok(Self::X86_64), + _ => Err(format!("Invalid Android arch format: {arch}")), + } + } + + /// Return the canonical name of the binary format. + pub fn name(self) -> &'static str { + match self { + Self::ArmeabiV7a => "armeabi_v7a", + Self::Arm64V8a => "arm64_v8a", + Self::X86 => "x86", + Self::X86_64 => "x86_64", + } + } +} + #[cfg(test)] mod tests { use insta::{assert_debug_snapshot, assert_snapshot}; @@ -1130,6 +1205,35 @@ mod tests { ); } + #[test] + fn test_platform_tags_android() { + let tags = + compatible_tags(&Platform::new(Os::Android { api_level: 14 }, Arch::Aarch64)).unwrap(); + let tags = tags.iter().map(ToString::to_string).collect::>(); + assert_debug_snapshot!( + tags, + @r###" + [] + "### + ); + + let tags = + compatible_tags(&Platform::new(Os::Android { api_level: 20 }, Arch::Aarch64)).unwrap(); + let tags = tags.iter().map(ToString::to_string).collect::>(); + assert_debug_snapshot!( + tags, + @r###" + [ + "android_20_arm64_v8a", + "android_19_arm64_v8a", + "android_18_arm64_v8a", + "android_17_arm64_v8a", + "android_16_arm64_v8a", + ] + "### + ); + } + /// Ensure the tags returned do not include the `manylinux` tags /// when `manylinux_incompatible` is set to `false`. #[test] diff --git a/crates/uv-static/src/env_vars.rs b/crates/uv-static/src/env_vars.rs index cae0fd06f..e57cce0ef 100644 --- a/crates/uv-static/src/env_vars.rs +++ b/crates/uv-static/src/env_vars.rs @@ -531,6 +531,12 @@ impl EnvVars { /// Defaults to `13.0`, the least-recent non-EOL macOS version at time of writing. pub const MACOSX_DEPLOYMENT_TARGET: &'static str = "MACOSX_DEPLOYMENT_TARGET"; + /// 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`. + pub const ANDROID_API_LEVEL: &'static str = "ANDROID_API_LEVEL"; + /// Disables colored output (takes precedence over `FORCE_COLOR`). /// /// See [no-color.org](https://no-color.org). diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 27aa00f8c..601edb742 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -538,6 +538,7 @@ used.

May also be set with the UV_PYTHON environment variable.

--python-platform python-platform

The 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:

    @@ -580,6 +581,8 @@ used.

  • 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 platform
  • aarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platform
  • +
  • aarch64-linux-android: An ARM64 Android target
  • +
  • x86_64-linux-android: An x86_64 Android target
  • wasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12
--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -1531,6 +1534,7 @@ environment in the project.

May also be set with the UV_PYTHON environment variable.

--python-platform python-platform

The 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:

    @@ -1573,6 +1577,8 @@ environment in the project.

  • 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 platform
  • aarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platform
  • +
  • aarch64-linux-android: An ARM64 Android target
  • +
  • x86_64-linux-android: An x86_64 Android target
  • wasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12
--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -2174,6 +2180,8 @@ interpreter. Use --universal to display the tree for all platforms,
  • 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 platform
  • aarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platform
  • +
  • aarch64-linux-android: An ARM64 Android target
  • +
  • x86_64-linux-android: An x86_64 Android target
  • wasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12
  • --python-version python-version

    The 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.

    @@ -2457,6 +2465,7 @@ uv tool run [OPTIONS] [COMMAND]

    May also be set with the UV_PYTHON environment variable.

    --python-platform python-platform

    The 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:

      @@ -2499,6 +2508,8 @@ uv tool run [OPTIONS] [COMMAND]
    • 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 platform
    • aarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platform
    • +
    • aarch64-linux-android: An ARM64 Android target
    • +
    • x86_64-linux-android: An x86_64 Android target
    • wasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12
    --quiet, -q

    Use quiet output.

    Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

    @@ -2677,6 +2688,7 @@ uv tool install [OPTIONS]

    May also be set with the UV_PYTHON environment variable.

    --python-platform python-platform

    The 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:

      @@ -2719,6 +2731,8 @@ uv tool install [OPTIONS]
    • 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 platform
    • aarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platform
    • +
    • aarch64-linux-android: An ARM64 Android target
    • +
    • x86_64-linux-android: An x86_64 Android target
    • wasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12
    --quiet, -q

    Use quiet output.

    Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

    @@ -2888,6 +2902,7 @@ Use with --all to apply to all tools.

    May also be set with the UV_PYTHON environment variable.

    --python-platform python-platform

    The 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:

      @@ -2930,6 +2945,8 @@ Use with --all to apply to all tools.

    • 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 platform
    • aarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platform
    • +
    • aarch64-linux-android: An ARM64 Android target
    • +
    • x86_64-linux-android: An x86_64 Android target
    • wasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12
    --quiet, -q

    Use quiet output.

    Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

    @@ -4128,6 +4145,7 @@ by --python-version.

    --python-platform python-platform

    The 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
    • @@ -4169,6 +4187,8 @@ by --python-version.

    • 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 platform
    • aarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platform
    • +
    • aarch64-linux-android: An ARM64 Android target
    • +
    • x86_64-linux-android: An x86_64 Android target
    • wasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12
    --python-version python-version

    The Python version to use for resolution.

    For example, 3.8 or 3.8.17.

    @@ -4399,6 +4419,7 @@ be used with caution, as it can modify the system Python installation.

    May also be set with the UV_PYTHON environment variable.

    --python-platform python-platform

    The 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:

      @@ -4441,6 +4462,8 @@ be used with caution, as it can modify the system Python installation.

    • 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 platform
    • aarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platform
    • +
    • aarch64-linux-android: An ARM64 Android target
    • +
    • x86_64-linux-android: An x86_64 Android target
    • wasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12
    --python-version python-version

    The 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.

    @@ -4689,6 +4712,7 @@ should be used with caution, as it can modify the system Python installation.

    May also be set with the UV_PYTHON environment variable.

    --python-platform python-platform

    The 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:

      @@ -4731,6 +4755,8 @@ should be used with caution, as it can modify the system Python installation.

      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 platform
    • aarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platform
    • +
    • aarch64-linux-android: An ARM64 Android target
    • +
    • x86_64-linux-android: An x86_64 Android target
    • wasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12
    --python-version python-version

    The 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.

    @@ -5320,6 +5346,7 @@ Python environment if no virtual environment is found.

    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 Windows
    • @@ -5361,6 +5388,8 @@ Python environment if no virtual environment is found.

    • 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 platform
    • aarch64-manylinux_2_40: An ARM64 target for the manylinux_2_40 platform
    • +
    • aarch64-linux-android: An ARM64 Android target
    • +
    • x86_64-linux-android: An x86_64 Android target
    • wasm32-pyodide2024: A wasm32 target using the Pyodide 2024 platform. Meant for use with Python 3.12
    --python-version python-version

    The 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",