From dec6f5aa022dae01b14d46ab3da4cb820061c591 Mon Sep 17 00:00:00 2001 From: Luca Leonardo Scorcia Date: Mon, 30 Dec 2024 17:49:57 +0100 Subject: [PATCH] Initial support for ARMv5TE platform via cross compilation (#10234) ## Summary Allows uv to recognize the ARMv5TE platform. This platform is currently supported on Debian distributions. It is an older 32 bit platform mostly used in embedded devices, currently in rust tier 2.5 so it requires cross compilation. Fixes #10157 . ## Test Plan Tested directly on device by applying a slightly different patch to tag 0.5.4 which is used by the current Home Assistant version (2024.12.5). After the patch Home Assistant is able to recognize the Python venv and setup its dependencies. Patched uv was built with ``` $ CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_GNUEABI_LINKER="/usr/bin/arm-linux-gnueabi-gcc" maturin build --release --target armv5te-unknown-linux-gnueabi --manylinux off ``` The target wheel was then moved on the device and installed via pip install. --- Cargo.toml | 2 +- crates/uv-platform-tags/src/platform.rs | 4 +++- crates/uv-python/src/platform.rs | 6 +++++- crates/uv-python/template-download-metadata.py | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 706789b11..f1b73bd65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,7 +80,7 @@ axoupdater = { version = "0.9.0", default-features = false } backoff = { version = "0.4.0" } base64 = { version = "0.22.1" } bitflags = { version = "2.6.0" } -boxcar = { version = "0.2.5" } +boxcar = { version = "0.2.8" } bytecheck = { version = "0.8.0" } cachedir = { version = "0.3.1" } cargo-util = { version = "0.2.14" } diff --git a/crates/uv-platform-tags/src/platform.rs b/crates/uv-platform-tags/src/platform.rs index 12876bb08..e3418a17d 100644 --- a/crates/uv-platform-tags/src/platform.rs +++ b/crates/uv-platform-tags/src/platform.rs @@ -77,6 +77,7 @@ impl fmt::Display for Os { pub enum Arch { #[serde(alias = "arm64")] Aarch64, + Armv5TEL, Armv6L, #[serde(alias = "armv8l")] Armv7L, @@ -96,6 +97,7 @@ impl fmt::Display for Arch { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Self::Aarch64 => write!(f, "aarch64"), + Self::Armv5TEL => write!(f, "armv5tel"), Self::Armv6L => write!(f, "armv6l"), Self::Armv7L => write!(f, "armv7l"), Self::Powerpc64Le => write!(f, "ppc64le"), @@ -122,7 +124,7 @@ impl Arch { // manylinux_2_31 Self::Riscv64 => Some(31), // unsupported - Self::Armv6L => None, + Self::Armv5TEL | Self::Armv6L => None, } } } diff --git a/crates/uv-python/src/platform.rs b/crates/uv-python/src/platform.rs index 9f933633d..67342ae1a 100644 --- a/crates/uv-python/src/platform.rs +++ b/crates/uv-python/src/platform.rs @@ -54,7 +54,7 @@ impl Libc { // Checks if the CPU supports hardware floating-point operations. // Depending on the result, it selects either the `gnueabihf` (hard-float) or `gnueabi` (soft-float) environment. // download-metadata.json only includes armv7. - "arm" | "armv7" => match detect_hardware_floating_point_support() { + "arm" | "armv5te" | "armv7" => match detect_hardware_floating_point_support() { Ok(true) => target_lexicon::Environment::Gnueabihf, Ok(false) => target_lexicon::Environment::Gnueabi, Err(_) => target_lexicon::Environment::Gnu, @@ -240,6 +240,10 @@ impl From<&uv_platform_tags::Arch> for Arch { ), variant: None, }, + uv_platform_tags::Arch::Armv5TEL => Self { + family: target_lexicon::Architecture::Arm(target_lexicon::ArmArchitecture::Armv5te), + variant: None, + }, uv_platform_tags::Arch::Armv6L => Self { family: target_lexicon::Architecture::Arm(target_lexicon::ArmArchitecture::Armv6), variant: None, diff --git a/crates/uv-python/template-download-metadata.py b/crates/uv-python/template-download-metadata.py index 95313a699..4be2d0ef9 100755 --- a/crates/uv-python/template-download-metadata.py +++ b/crates/uv-python/template-download-metadata.py @@ -69,6 +69,8 @@ def prepare_arch(arch: dict) -> tuple[str, str]: family = "X86_32(target_lexicon::X86_32Architecture::I686)" case "aarch64": family = "Aarch64(target_lexicon::Aarch64Architecture::Aarch64)" + case "armv5tel": + family = "Arm(target_lexicon::ArmArchitecture::Armv5te)" case "armv7": family = "Arm(target_lexicon::ArmArchitecture::Armv7)" case value: