Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uv python install: Detect hard-float support #7725

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ path-slash = { version = "0.2.1" }
pathdiff = { version = "0.2.1" }
petgraph = { version = "0.6.5" }
platform-info = { version = "2.0.3" }
procfs = { version = "0.16.0" }
proc-macro2 = { version = "1.0.86" }
pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "388685a8711092971930986644cfed152d1a1f6c" }
pyo3 = { version = "0.21.2" }
Expand Down
1 change: 1 addition & 0 deletions crates/uv-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ futures = { workspace = true }
goblin = { workspace = true }
itertools = { workspace = true }
owo-colors = { workspace = true }
procfs = { workspace = true }
regex = { workspace = true }
reqwest = { workspace = true }
reqwest-middleware = { workspace = true }
Expand Down
16 changes: 16 additions & 0 deletions crates/uv-python/src/cpuinfo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! Fetches CPU information.

use anyhow::Error;
use procfs::{CpuInfo, Current};

pub(crate) fn detect_hardware_floating_point_support() -> Result<bool, Error> {
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved
let cpu_info = CpuInfo::current()?;
for num in 0..cpu_info.num_cores() {
if let Some(flags) = cpu_info.flags(num) {
if flags.contains(&"vfp") {
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved
return Ok(true);
}
}
}
Ok(false)
}
1 change: 1 addition & 0 deletions crates/uv-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub use crate::version_files::{
};
pub use crate::virtualenv::{Error as VirtualEnvError, PyVenvConfiguration, VirtualEnvironment};

mod cpuinfo;
mod discovery;
pub mod downloads;
mod environment;
Expand Down
11 changes: 10 additions & 1 deletion crates/uv-python/src/platform.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::cpuinfo::detect_hardware_floating_point_support;
use crate::libc::{detect_linux_libc, LibcDetectionError, LibcVersion};
use std::fmt::Display;
use std::ops::Deref;
Expand Down Expand Up @@ -30,7 +31,15 @@ impl Libc {
pub(crate) fn from_env() -> Result<Self, LibcDetectionError> {
match std::env::consts::OS {
"linux" => Ok(Self::Some(match detect_linux_libc()? {
LibcVersion::Manylinux { .. } => target_lexicon::Environment::Gnu,
LibcVersion::Manylinux { .. } => match std::env::consts::ARCH {
// download-metadata.json only includes armv7.
"arm" | "armv7" => match detect_hardware_floating_point_support() {
Ok(true) => target_lexicon::Environment::Gnueabihf,
Ok(false) => target_lexicon::Environment::Gnueabi,
Err(_) => target_lexicon::Environment::Gnu,
},
_ => target_lexicon::Environment::Gnu,
},
LibcVersion::Musllinux { .. } => target_lexicon::Environment::Musl,
})),
"windows" | "macos" => Ok(Self::None),
Expand Down
Loading