Ignore libc on other platforms (#3825)

Libc variants are only relevant on linux, we can ignore it on non
{linux, windows, mac}, e.g. BSDs.

Closes #3824
This commit is contained in:
konsti 2024-05-25 12:05:10 +02:00 committed by GitHub
parent c2931e806d
commit f4533c3a85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 7 deletions

View file

@ -125,7 +125,7 @@ impl PythonDownloadRequest {
self.os = Some(Os::from_env()?); self.os = Some(Os::from_env()?);
} }
if self.libc.is_none() { if self.libc.is_none() {
self.libc = Some(Libc::from_env()?); self.libc = Some(Libc::from_env());
} }
Ok(self) Ok(self)
} }

View file

@ -169,6 +169,6 @@ pub fn toolchains_for_version(version: &PythonVersion) -> Result<Vec<Toolchain>,
fn platform_key_from_env() -> Result<String, Error> { fn platform_key_from_env() -> Result<String, Error> {
let os = Os::from_env()?; let os = Os::from_env()?;
let arch = Arch::from_env()?; let arch = Arch::from_env()?;
let libc = Libc::from_env()?; let libc = Libc::from_env();
Ok(format!("{os}-{arch}-{libc}").to_lowercase()) Ok(format!("{os}-{arch}-{libc}").to_lowercase())
} }

View file

@ -63,7 +63,7 @@ impl Platform {
Ok(Self::new( Ok(Self::new(
Os::from_env()?, Os::from_env()?,
Arch::from_env()?, Arch::from_env()?,
Libc::from_env()?, Libc::from_env(),
)) ))
} }
} }
@ -149,12 +149,14 @@ impl Arch {
} }
impl Libc { impl Libc {
pub(crate) fn from_env() -> Result<Self, Error> { pub(crate) fn from_env() -> Self {
// TODO(zanieb): Perform this lookup // TODO(zanieb): Perform this lookup
match std::env::consts::OS { match std::env::consts::OS {
"linux" => Ok(Libc::Gnu), // Supported platforms.
"windows" | "macos" => Ok(Libc::None), "linux" => Libc::Gnu,
_ => Err(Error::LibcNotDetected()), "windows" | "macos" => Libc::None,
// Platforms without explicit support.
_ => Libc::None,
} }
} }
} }