From 0d029bd2b6a9e735cdbd1194384da479dd365fa0 Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Mon, 4 Dec 2023 08:50:53 +0100 Subject: [PATCH] fix: issue 529 --- src/lock_file/python.rs | 13 ++++++++++--- src/project/manifest.rs | 12 ++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/lock_file/python.rs b/src/lock_file/python.rs index 3f616f784..a212fd533 100644 --- a/src/lock_file/python.rs +++ b/src/lock_file/python.rs @@ -219,9 +219,16 @@ fn project_platforms(platform: Platform, system_requirements: &SystemRequirement _ => unreachable!("not windows"), } } else if platform.is_linux() { - let max_glibc_version = match &system_requirements.libc { - Some(LibCSystemRequirement::GlibC(v)) => v.clone(), - Some(LibCSystemRequirement::OtherFamily(_)) => return Vec::new(), + let max_glibc_version = match system_requirements + .libc + .as_ref() + .map(LibCSystemRequirement::family_and_version) + { + Some((family, version)) if family.eq_ignore_ascii_case("glibc") => version.clone(), + Some(_) => { + // Another libc family is being target. + return Vec::new(); + } None => default_glibc_version(), }; linux_platform_tags(platform, &max_glibc_version) diff --git a/src/project/manifest.rs b/src/project/manifest.rs index 097bb49f3..6b7cd3184 100644 --- a/src/project/manifest.rs +++ b/src/project/manifest.rs @@ -378,6 +378,18 @@ pub enum LibCSystemRequirement { OtherFamily(LibCFamilyAndVersion), } +impl LibCSystemRequirement { + /// Returns the family and version of this libc requirement. + pub fn family_and_version(&self) -> (&str, &Version) { + match self { + LibCSystemRequirement::GlibC(version) => ("glibc", version), + LibCSystemRequirement::OtherFamily(LibCFamilyAndVersion { family, version: v }) => { + (family.as_deref().unwrap_or("glibc"), v) + } + } + } +} + #[serde_as] #[derive(Debug, Clone, Deserialize)] #[serde(deny_unknown_fields)]