From f838a1bdd9bd815c9dbe3498dba213aef9d29d86 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sat, 8 Jun 2024 09:06:06 -0500 Subject: [PATCH] Add support for musl Python toolchain fetches --- Cargo.lock | 1 + Cargo.toml | 1 + crates/uv-toolchain/Cargo.toml | 1 + crates/uv-toolchain/src/platform.rs | 17 +++++++++++------ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f146c5ad535..744cb82168f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4922,6 +4922,7 @@ dependencies = [ "schemars", "serde", "serde_json", + "target-lexicon", "temp-env", "tempfile", "test-log", diff --git a/Cargo.toml b/Cargo.toml index e65ccd6d6a72..fbbfc31ee746 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -120,6 +120,7 @@ serde = { version = "1.0.197", features = ["derive"] } serde_json = { version = "1.0.114" } sha2 = { version = "0.10.8" } sys-info = { version = "0.9.1" } +target-lexicon = {version = "0.12.14" } tempfile = { version = "3.9.0" } textwrap = { version = "0.16.1" } thiserror = { version = "1.0.56" } diff --git a/crates/uv-toolchain/Cargo.toml b/crates/uv-toolchain/Cargo.toml index c64bab677893..4e870ccdc8c9 100644 --- a/crates/uv-toolchain/Cargo.toml +++ b/crates/uv-toolchain/Cargo.toml @@ -41,6 +41,7 @@ same-file = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } +target-lexicon = { workspace = true } tempfile = { workspace = true } thiserror = { workspace = true } tokio-util = { workspace = true, features = ["compat"] } diff --git a/crates/uv-toolchain/src/platform.rs b/crates/uv-toolchain/src/platform.rs index 2506ea9b02f2..dd116b652d28 100644 --- a/crates/uv-toolchain/src/platform.rs +++ b/crates/uv-toolchain/src/platform.rs @@ -1,7 +1,4 @@ -use std::{ - fmt::{self}, - str::FromStr, -}; +use std::{fmt, str::FromStr}; use thiserror::Error; /// All supported operating systems. @@ -130,10 +127,18 @@ impl Arch { impl Libc { pub(crate) fn from_env() -> Self { - // TODO(zanieb): Perform this lookup match std::env::consts::OS { // Supported platforms. - "linux" => Libc::Gnu, + "linux" => { + let environment = target_lexicon::HOST.environment.into_str(); + if environment.starts_with("gnu") || environment == "linuxkernel" { + Libc::Gnu + } else if environment.starts_with("musl") { + Libc::Musl + } else { + Libc::None + } + } "windows" | "macos" => Libc::None, // Platforms without explicit support. _ => Libc::None,