Skip to content

Commit 1365cd5

Browse files
committed
Use /proc/cpuinfo to detect hard-float support
Signed-off-by: Kemal Akkoyun <[email protected]>
1 parent df45b9a commit 1365cd5

File tree

6 files changed

+115
-1
lines changed

6 files changed

+115
-1
lines changed

Cargo.lock

+86
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ path-slash = { version = "0.2.1" }
120120
pathdiff = { version = "0.2.1" }
121121
petgraph = { version = "0.6.5" }
122122
platform-info = { version = "2.0.3" }
123+
procfs = { version = "0.16.0" }
123124
proc-macro2 = { version = "1.0.86" }
124125
pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "388685a8711092971930986644cfed152d1a1f6c" }
125126
pyo3 = { version = "0.21.2" }

crates/uv-python/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ futures = { workspace = true }
3636
goblin = { workspace = true }
3737
itertools = { workspace = true }
3838
owo-colors = { workspace = true }
39+
procfs = { workspace = true }
3940
regex = { workspace = true }
4041
reqwest = { workspace = true }
4142
reqwest-middleware = { workspace = true }

crates/uv-python/src/cpuinfo.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! Fetches CPU information.
2+
3+
use anyhow::Error;
4+
use procfs::{CpuInfo, Current};
5+
6+
pub(crate) fn detect_hardware_floating_point_support() -> Result<bool, Error> {
7+
let cpu_info = CpuInfo::current()?;
8+
for num in 0..cpu_info.num_cores() {
9+
if let Some(flags) = cpu_info.flags(num) {
10+
if flags.contains(&"vfp") {
11+
return Ok(true);
12+
}
13+
}
14+
}
15+
Ok(false)
16+
}

crates/uv-python/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub use crate::version_files::{
1818
};
1919
pub use crate::virtualenv::{Error as VirtualEnvError, PyVenvConfiguration, VirtualEnvironment};
2020

21+
mod cpuinfo;
2122
mod discovery;
2223
pub mod downloads;
2324
mod environment;

crates/uv-python/src/platform.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::cpuinfo::detect_hardware_floating_point_support;
12
use crate::libc::{detect_linux_libc, LibcDetectionError, LibcVersion};
23
use std::fmt::Display;
34
use std::ops::Deref;
@@ -30,7 +31,15 @@ impl Libc {
3031
pub(crate) fn from_env() -> Result<Self, LibcDetectionError> {
3132
match std::env::consts::OS {
3233
"linux" => Ok(Self::Some(match detect_linux_libc()? {
33-
LibcVersion::Manylinux { .. } => target_lexicon::Environment::Gnu,
34+
LibcVersion::Manylinux { .. } => match std::env::consts::ARCH {
35+
// download-metadata.json only includes armv7.
36+
"arm" | "armv7" => match detect_hardware_floating_point_support() {
37+
Ok(true) => target_lexicon::Environment::Gnueabihf,
38+
Ok(false) => target_lexicon::Environment::Gnueabi,
39+
Err(_) => target_lexicon::Environment::Gnu,
40+
},
41+
_ => target_lexicon::Environment::Gnu,
42+
},
3443
LibcVersion::Musllinux { .. } => target_lexicon::Environment::Musl,
3544
})),
3645
"windows" | "macos" => Ok(Self::None),

0 commit comments

Comments
 (0)