From b3bdd30961099c9ba84f17ea18ad83888409bf34 Mon Sep 17 00:00:00 2001 From: timrid <6593626+timrid@users.noreply.github.com> Date: Wed, 3 Sep 2025 00:50:00 +0200 Subject: [PATCH 1/7] initial android support --- crates/uv-configuration/src/target_triple.rs | 48 ++++++++++++++ crates/uv-platform-tags/src/platform_tag.rs | 37 ++++++++++- crates/uv-platform-tags/src/tags.rs | 66 +++++++++++++++++++- crates/uv-static/src/env_vars.rs | 6 ++ docs/reference/cli.md | 20 ++++++ docs/reference/environment.md | 7 +++ uv.schema.json | 10 +++ 7 files changed, 190 insertions(+), 4 deletions(-) diff --git a/crates/uv-configuration/src/target_triple.rs b/crates/uv-configuration/src/target_triple.rs index d64fcf1b1eeba..837f5adbfaf40 100644 --- a/crates/uv-configuration/src/target_triple.rs +++ b/crates/uv-configuration/src/target_triple.rs @@ -233,6 +233,16 @@ pub enum TargetTriple { #[serde(alias = "aarch64-manylinux240")] Aarch64Manylinux240, + /// An ARM64 Android target. + #[cfg_attr(feature = "clap", value(name = "aarch64-linux-android"))] + #[serde(rename = "aarch64-linux-android")] + Aarch64LinuxAndroid, + + /// An `x86_64` Android target. + #[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, @@ -468,6 +478,20 @@ impl TargetTriple { }, Arch::Wasm32, ), + Self::Aarch64LinuxAndroid => { + let api_level = android_api_level().map_or(21, |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(21, |api_level| { + debug!("Found Android API level: {}", api_level); + api_level + }); + Platform::new(Os::Android { api_level }, Arch::X86_64) + } } } @@ -509,6 +533,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => "aarch64", Self::Aarch64Manylinux239 => "aarch64", Self::Aarch64Manylinux240 => "aarch64", + Self::Aarch64LinuxAndroid => "aarch64", + Self::X8664LinuxAndroid => "x86_64", Self::Wasm32Pyodide2024 => "wasm32", } } @@ -551,6 +577,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => "Linux", Self::Aarch64Manylinux239 => "Linux", Self::Aarch64Manylinux240 => "Linux", + Self::Aarch64LinuxAndroid => "Android", + Self::X8664LinuxAndroid => "Android", Self::Wasm32Pyodide2024 => "Emscripten", } } @@ -593,6 +621,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. @@ -638,6 +668,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", @@ -682,6 +714,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => "posix", Self::Aarch64Manylinux239 => "posix", Self::Aarch64Manylinux240 => "posix", + Self::Aarch64LinuxAndroid => "posix", + Self::X8664LinuxAndroid => "posix", Self::Wasm32Pyodide2024 => "posix", } } @@ -724,6 +758,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => "linux", Self::Aarch64Manylinux239 => "linux", Self::Aarch64Manylinux240 => "linux", + Self::Aarch64LinuxAndroid => "android", + Self::X8664LinuxAndroid => "android", Self::Wasm32Pyodide2024 => "emscripten", } } @@ -766,6 +802,8 @@ impl TargetTriple { Self::Aarch64Manylinux238 => true, Self::Aarch64Manylinux239 => true, Self::Aarch64Manylinux240 => true, + Self::Aarch64LinuxAndroid => false, + Self::X8664LinuxAndroid => false, Self::Wasm32Pyodide2024 => false, } } @@ -799,3 +837,13 @@ fn macos_deployment_target() -> Option<(u16, u16)> { Some((major, minor)) } + +/// Return the macOS deployment target 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_tag.rs b/crates/uv-platform-tags/src/platform_tag.rs index b970a248c7f71..18e5b1227dc9f 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::AndroidArch; 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, arch: AndroidArch }, /// 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, + arch: AndroidArch::Arm64V8a, .. } ) @@ -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", @@ -684,6 +685,7 @@ mod tests { use std::str::FromStr; use crate::platform_tag::{ParsePlatformTagError, PlatformTag}; + use crate::tags::AndroidArch; use crate::{Arch, BinaryFormat}; #[test] @@ -964,6 +966,35 @@ mod tests { ); } + #[test] + fn android_platform() { + let tag = PlatformTag::Android { + api_level: 21, + arch: AndroidArch::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 b321d1d85c732..cfd082fd9749d 100644 --- a/crates/uv-platform-tags/src/tags.rs +++ b/crates/uv-platform-tags/src/tags.rs @@ -614,7 +614,7 @@ fn compatible_tags(platform: &Platform) -> Result, PlatformErro (Os::Android { api_level }, _) => { vec![PlatformTag::Android { api_level: *api_level, - arch, + arch: AndroidArch::from_arch(arch), }] } (Os::Pyodide { major, minor }, Arch::Wasm32) => { @@ -759,6 +759,70 @@ impl BinaryFormat { } } +#[derive( + Debug, + Copy, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + Hash, + rkyv::Archive, + rkyv::Deserialize, + rkyv::Serialize, +)] +#[rkyv(derive(Debug))] +pub enum AndroidArch { + ArmeabiV7a, + Arm64V8a, + X86, + X86_64, +} + +impl std::fmt::Display for AndroidArch { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.name()) + } +} + +impl FromStr for AndroidArch { + 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 AndroidArch { + /// Determine the appropriate multiarch for a iOS version. + pub fn from_arch(arch: Arch) -> Self { + match arch { + Arch::Aarch64 => Self::Arm64V8a, + Arch::Armv7L => Self::ArmeabiV7a, + Arch::X86 => Self::X86, + Arch::X86_64 => Self::X86_64, + _ => unreachable!(), + } + } + + /// 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}; diff --git a/crates/uv-static/src/env_vars.rs b/crates/uv-static/src/env_vars.rs index e6427c0f37a68..f1cfafa2375e4 100644 --- a/crates/uv-static/src/env_vars.rs +++ b/crates/uv-static/src/env_vars.rs @@ -528,6 +528,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 `21`. + 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 ec8265f449624..63da31685f03a 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -277,6 +277,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.

    @@ -1269,6 +1271,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.

    @@ -1869,6 +1873,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.

    @@ -2193,6 +2199,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.

    @@ -2412,6 +2420,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.

    @@ -2622,6 +2632,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.

    @@ -3860,6 +3872,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.

    @@ -4131,6 +4145,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.

    @@ -4420,6 +4436,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.

    @@ -5049,6 +5067,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 3b017178d518c..eb4aacc63d9ff 100644 --- a/docs/reference/environment.md +++ b/docs/reference/environment.md @@ -561,6 +561,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 `21`. + ### `APPDATA` Path to user-level configuration directory on Windows systems. diff --git a/uv.schema.json b/uv.schema.json index 6deddd4be8442..cc21a5b878844 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -2421,6 +2421,16 @@ "type": "string", "const": "aarch64-manylinux_2_40" }, + { + "description": "An ARM64 Android target.", + "type": "string", + "const": "aarch64-linux-android" + }, + { + "description": "An `x86_64` Android target.", + "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", From a131fbb9aa771fc5d5839a1739745b934dd8a7ae Mon Sep 17 00:00:00 2001 From: timrid <6593626+timrid@users.noreply.github.com> Date: Wed, 3 Sep 2025 00:57:21 +0200 Subject: [PATCH 2/7] update docs --- crates/uv-cli/src/lib.rs | 27 ++++++++++++++++++++ crates/uv-configuration/src/target_triple.rs | 6 +++++ docs/reference/cli.md | 9 +++++++ uv.schema.json | 4 +-- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index b14b2a62a2f26..a8c8660672ca6 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -1440,6 +1440,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 `21`. Use + /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`. #[arg(long)] pub python_platform: Option, @@ -1767,6 +1770,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 `21`. 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 @@ -2070,6 +2076,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 `21`. 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 @@ -2392,6 +2401,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 `21`. Use + /// `ANDROID_API_LEVEL` to specify a different minimum version, e.g., `26`. #[arg(long)] pub python_platform: Option, } @@ -3318,6 +3330,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 `21`. 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 @@ -3595,6 +3610,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 `21`. 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 @@ -4591,6 +4609,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 `21`. 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 @@ -4713,6 +4734,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 `21`. 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 @@ -4810,6 +4834,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 `21`. 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 837f5adbfaf40..a9773b1c14c86 100644 --- a/crates/uv-configuration/src/target_triple.rs +++ b/crates/uv-configuration/src/target_triple.rs @@ -234,11 +234,17 @@ pub enum TargetTriple { Aarch64Manylinux240, /// An ARM64 Android target. + /// + /// By default uses Android API level 21, 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 21, 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, diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 63da31685f03a..ce8665a2c5ab2 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -236,6 +236,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 21. 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:

      @@ -1230,6 +1231,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 21. 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:

      @@ -2158,6 +2160,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 21. 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:

      @@ -2379,6 +2382,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 21. 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:

      @@ -2591,6 +2595,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 21. 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:

      @@ -3832,6 +3837,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 21. 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
    • @@ -4104,6 +4110,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 21. 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:

      @@ -4395,6 +4402,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 21. 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:

      @@ -5027,6 +5035,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 21. 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
      • diff --git a/uv.schema.json b/uv.schema.json index cc21a5b878844..d0215cd7de07d 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -2422,12 +2422,12 @@ "const": "aarch64-manylinux_2_40" }, { - "description": "An ARM64 Android target.", + "description": "An ARM64 Android target.\n\nBy default uses Android API level 21, but respects\nthe `ANDROID_API_LEVEL` environment variable if set.", "type": "string", "const": "aarch64-linux-android" }, { - "description": "An `x86_64` Android target.", + "description": "An `x86_64` Android target.\n\nBy default uses Android API level 21, but respects\nthe `ANDROID_API_LEVEL` environment variable if set.", "type": "string", "const": "x86_64-linux-android" }, From ea69b1860a2ac1d8ba48367a9c9443727b0fc3e7 Mon Sep 17 00:00:00 2001 From: timrid <6593626+timrid@users.noreply.github.com> Date: Wed, 3 Sep 2025 01:18:19 +0200 Subject: [PATCH 3/7] fixed "compatible_tags" for android --- crates/uv-platform-tags/src/tags.rs | 49 ++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/crates/uv-platform-tags/src/tags.rs b/crates/uv-platform-tags/src/tags.rs index cfd082fd9749d..4ead29aa4fd9c 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: AndroidArch::from_arch(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, + arch: AndroidArch::from_arch(arch), + }); + } + + platform_tags } (Os::Pyodide { major, minor }, Arch::Wasm32) => { vec![PlatformTag::Pyodide { @@ -1194,6 +1204,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] From 0ef3879c4bc7d80184a889b2d0c1e879c5516099 Mon Sep 17 00:00:00 2001 From: timrid <6593626+timrid@users.noreply.github.com> Date: Wed, 3 Sep 2025 09:47:34 +0200 Subject: [PATCH 4/7] add structured error and a link to the docs with all android archs --- crates/uv-platform-tags/src/platform.rs | 2 ++ crates/uv-platform-tags/src/tags.rs | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/uv-platform-tags/src/platform.rs b/crates/uv-platform-tags/src/platform.rs index 406facd5d1dde..62b05afe96f8c 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/tags.rs b/crates/uv-platform-tags/src/tags.rs index 4ead29aa4fd9c..df54c64fc118e 100644 --- a/crates/uv-platform-tags/src/tags.rs +++ b/crates/uv-platform-tags/src/tags.rs @@ -621,7 +621,8 @@ fn compatible_tags(platform: &Platform) -> Result, PlatformErro for ver in (16..=*api_level).rev() { platform_tags.push(PlatformTag::Android { api_level: ver, - arch: AndroidArch::from_arch(arch), + arch: AndroidArch::from_arch(arch) + .map_err(PlatformError::ArchDetectionError)?, }); } @@ -784,6 +785,7 @@ impl BinaryFormat { )] #[rkyv(derive(Debug))] pub enum AndroidArch { + // Source: https://peps.python.org/pep-0738/#architectures ArmeabiV7a, Arm64V8a, X86, @@ -811,14 +813,14 @@ impl FromStr for AndroidArch { } impl AndroidArch { - /// Determine the appropriate multiarch for a iOS version. - pub fn from_arch(arch: Arch) -> Self { + /// Determine the appropriate Android arch. + pub fn from_arch(arch: Arch) -> Result { match arch { - Arch::Aarch64 => Self::Arm64V8a, - Arch::Armv7L => Self::ArmeabiV7a, - Arch::X86 => Self::X86, - Arch::X86_64 => Self::X86_64, - _ => unreachable!(), + 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}")), } } From 6592ae0ee8656ad2a0948ce2cb3e0d8d9e2ec44a Mon Sep 17 00:00:00 2001 From: timrid <6593626+timrid@users.noreply.github.com> Date: Wed, 3 Sep 2025 11:37:05 +0200 Subject: [PATCH 5/7] rename AndroidArch to AndroidAbi --- crates/uv-platform-tags/src/platform_tag.rs | 20 ++++++++++---------- crates/uv-platform-tags/src/tags.rs | 13 ++++++------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/crates/uv-platform-tags/src/platform_tag.rs b/crates/uv-platform-tags/src/platform_tag.rs index 18e5b1227dc9f..bb043b2ff4bba 100644 --- a/crates/uv-platform-tags/src/platform_tag.rs +++ b/crates/uv-platform-tags/src/platform_tag.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use uv_small_str::SmallString; -use crate::tags::AndroidArch; +use crate::tags::AndroidAbi; use crate::{Arch, BinaryFormat}; /// A tag to represent the platform compatibility of a Python distribution. @@ -57,7 +57,7 @@ pub enum PlatformTag { /// Ex) `win_ia64` WinIa64, /// Ex) `android_21_x86_64` - Android { api_level: u16, arch: AndroidArch }, + Android { api_level: u16, abi: AndroidAbi }, /// Ex) `freebsd_12_x86_64` FreeBsd { release_arch: SmallString }, /// Ex) `netbsd_9_x86_64` @@ -180,7 +180,7 @@ impl PlatformTag { .. } | Self::WinArm64 | Self::Android { - arch: AndroidArch::Arm64V8a, + abi: AndroidAbi::Arm64V8a, .. } ) @@ -268,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}"), @@ -506,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_") { @@ -685,7 +685,7 @@ mod tests { use std::str::FromStr; use crate::platform_tag::{ParsePlatformTagError, PlatformTag}; - use crate::tags::AndroidArch; + use crate::tags::AndroidAbi; use crate::{Arch, BinaryFormat}; #[test] @@ -970,7 +970,7 @@ mod tests { fn android_platform() { let tag = PlatformTag::Android { api_level: 21, - arch: AndroidArch::Arm64V8a, + abi: AndroidAbi::Arm64V8a, }; assert_eq!( PlatformTag::from_str("android_21_arm64_v8a").as_ref(), diff --git a/crates/uv-platform-tags/src/tags.rs b/crates/uv-platform-tags/src/tags.rs index df54c64fc118e..531b3c782bb9b 100644 --- a/crates/uv-platform-tags/src/tags.rs +++ b/crates/uv-platform-tags/src/tags.rs @@ -621,8 +621,7 @@ fn compatible_tags(platform: &Platform) -> Result, PlatformErro for ver in (16..=*api_level).rev() { platform_tags.push(PlatformTag::Android { api_level: ver, - arch: AndroidArch::from_arch(arch) - .map_err(PlatformError::ArchDetectionError)?, + abi: AndroidAbi::from_arch(arch).map_err(PlatformError::ArchDetectionError)?, }); } @@ -784,21 +783,21 @@ impl BinaryFormat { rkyv::Serialize, )] #[rkyv(derive(Debug))] -pub enum AndroidArch { - // Source: https://peps.python.org/pep-0738/#architectures +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 AndroidArch { +impl std::fmt::Display for AndroidAbi { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.name()) } } -impl FromStr for AndroidArch { +impl FromStr for AndroidAbi { type Err = String; fn from_str(s: &str) -> Result { @@ -812,7 +811,7 @@ impl FromStr for AndroidArch { } } -impl AndroidArch { +impl AndroidAbi { /// Determine the appropriate Android arch. pub fn from_arch(arch: Arch) -> Result { match arch { From 7498f56e7f2bf417a28c82bd19b22bb80be26f7a Mon Sep 17 00:00:00 2001 From: timrid <6593626+timrid@users.noreply.github.com> Date: Wed, 3 Sep 2025 11:47:24 +0200 Subject: [PATCH 6/7] fix comment --- crates/uv-configuration/src/target_triple.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/uv-configuration/src/target_triple.rs b/crates/uv-configuration/src/target_triple.rs index a9773b1c14c86..9997b0c69e25d 100644 --- a/crates/uv-configuration/src/target_triple.rs +++ b/crates/uv-configuration/src/target_triple.rs @@ -844,7 +844,7 @@ fn macos_deployment_target() -> Option<(u16, u16)> { Some((major, minor)) } -/// Return the macOS deployment target as parsed from the environment. +/// 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()?; From a8b75b98d4aeb5635c263f07c9534bfb4db10dda Mon Sep 17 00:00:00 2001 From: timrid <6593626+timrid@users.noreply.github.com> Date: Wed, 3 Sep 2025 12:02:40 +0200 Subject: [PATCH 7/7] Use a default Android API level of 24 instead of 21. See: https://github.com/astral-sh/uv/pull/15646#discussion_r2318396183 --- crates/uv-cli/src/lib.rs | 18 +++++++++--------- crates/uv-configuration/src/target_triple.rs | 8 ++++---- crates/uv-static/src/env_vars.rs | 2 +- docs/reference/cli.md | 18 +++++++++--------- docs/reference/environment.md | 2 +- uv.schema.json | 4 ++-- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index a8c8660672ca6..c73277e7209f8 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -1441,7 +1441,7 @@ 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 `21`. Use + /// 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, @@ -1770,7 +1770,7 @@ 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 `21`. Use + /// 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_ @@ -2076,7 +2076,7 @@ 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 `21`. Use + /// 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_ @@ -2402,7 +2402,7 @@ 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 `21`. Use + /// 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, @@ -3330,7 +3330,7 @@ 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 `21`. Use + /// 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_ @@ -3610,7 +3610,7 @@ 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 `21`. Use + /// 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_ @@ -4609,7 +4609,7 @@ 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 `21`. Use + /// 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_ @@ -4734,7 +4734,7 @@ 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 `21`. Use + /// 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_ @@ -4834,7 +4834,7 @@ 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 `21`. Use + /// 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_ diff --git a/crates/uv-configuration/src/target_triple.rs b/crates/uv-configuration/src/target_triple.rs index 9997b0c69e25d..4b8a6129625c5 100644 --- a/crates/uv-configuration/src/target_triple.rs +++ b/crates/uv-configuration/src/target_triple.rs @@ -235,7 +235,7 @@ pub enum TargetTriple { /// An ARM64 Android target. /// - /// By default uses Android API level 21, but respects + /// 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")] @@ -243,7 +243,7 @@ pub enum TargetTriple { /// An `x86_64` Android target. /// - /// By default uses Android API level 21, but respects + /// 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")] @@ -485,14 +485,14 @@ impl TargetTriple { Arch::Wasm32, ), Self::Aarch64LinuxAndroid => { - let api_level = android_api_level().map_or(21, |api_level| { + 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(21, |api_level| { + let api_level = android_api_level().map_or(24, |api_level| { debug!("Found Android API level: {}", api_level); api_level }); diff --git a/crates/uv-static/src/env_vars.rs b/crates/uv-static/src/env_vars.rs index f1cfafa2375e4..1115f4bb98567 100644 --- a/crates/uv-static/src/env_vars.rs +++ b/crates/uv-static/src/env_vars.rs @@ -531,7 +531,7 @@ impl EnvVars { /// 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 `21`. + /// Defaults to `24`. pub const ANDROID_API_LEVEL: &'static str = "ANDROID_API_LEVEL"; /// Disables colored output (takes precedence over `FORCE_COLOR`). diff --git a/docs/reference/cli.md b/docs/reference/cli.md index ce8665a2c5ab2..d249cd2dade71 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -236,7 +236,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 21. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.

    +

    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:

      @@ -1231,7 +1231,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 21. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.

    +

    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:

      @@ -2160,7 +2160,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 21. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.

    +

    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:

      @@ -2382,7 +2382,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 21. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.

    +

    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:

      @@ -2595,7 +2595,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 21. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.

    +

    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:

      @@ -3837,7 +3837,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 21. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.

    +

    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
    • @@ -4110,7 +4110,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 21. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.

    +

    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:

      @@ -4402,7 +4402,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 21. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.

    +

    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:

      @@ -5035,7 +5035,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 21. Use ANDROID_API_LEVEL to specify a different minimum version, e.g., 26.

      +

      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
      • diff --git a/docs/reference/environment.md b/docs/reference/environment.md index eb4aacc63d9ff..c59b4915f58b0 100644 --- a/docs/reference/environment.md +++ b/docs/reference/environment.md @@ -566,7 +566,7 @@ General proxy for all network requests. 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 `21`. +Defaults to `24`. ### `APPDATA` diff --git a/uv.schema.json b/uv.schema.json index d0215cd7de07d..009e47475c576 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -2422,12 +2422,12 @@ "const": "aarch64-manylinux_2_40" }, { - "description": "An ARM64 Android target.\n\nBy default uses Android API level 21, but respects\nthe `ANDROID_API_LEVEL` environment variable if set.", + "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 21, but respects\nthe `ANDROID_API_LEVEL` environment variable if set.", + "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" },