Skip to content

Commit

Permalink
fix clippy, pull manylinux compatible var out up the stack so as to m…
Browse files Browse the repository at this point in the history
…ake the change more minimal
  • Loading branch information
ChannyClaus committed Aug 12, 2024
1 parent ee33c04 commit 2b57d6c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
5 changes: 3 additions & 2 deletions crates/bench/benches/uv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ mod resolver {
Arch::Aarch64,
);

static TAGS: LazyLock<Tags> =
LazyLock::new(|| Tags::from_env(&PLATFORM, (3, 11), "cpython", (3, 11), false).unwrap());
static TAGS: LazyLock<Tags> = LazyLock::new(|| {
Tags::from_env(&PLATFORM, (3, 11), "cpython", (3, 11), false, false).unwrap()
});

pub(crate) async fn resolve(
manifest: Manifest,
Expand Down
26 changes: 14 additions & 12 deletions crates/platform-tags/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,17 @@ impl Tags {
gil_disabled: bool,
) -> Result<Self, TagsError> {
let implementation = Implementation::parse(implementation_name, gil_disabled)?;
let platform_tags = compatible_tags(platform, manylinux_compatible)?;

// If the interpreter is manylinux incompatible, we return an empty vector.
// This is the path that gets hit when user overrides the manylinux compatibility
// via adding `_manylinux` module to their standard library.
// See https://github.com/astral-sh/uv/issues/5915 for more details.
let platform_tags =
if matches!(platform.os(), Os::Manylinux { .. }) && !manylinux_compatible {
Vec::new()
} else {
compatible_tags(platform)?
};

let mut tags = Vec::with_capacity(5 * platform_tags.len());
// 1. This exact c api version
Expand Down Expand Up @@ -393,24 +403,14 @@ impl Implementation {
/// and "any".
///
/// Bit of a mess, needs to be cleaned up.
fn compatible_tags(
platform: &Platform,
manylinux_compatible: bool,
) -> Result<Vec<String>, PlatformError> {
fn compatible_tags(platform: &Platform) -> Result<Vec<String>, PlatformError> {
let os = platform.os();
let arch = platform.arch();

let platform_tags = match (&os, arch) {
(Os::Manylinux { major, minor }, _) => {
let mut platform_tags = Vec::new();

// If the interpreter is manylinux incompatible, we return an empty vector.
// This is the path that gets hit when user overrides the manylinux compatibility
// via adding `_manylinux` module to their standard library.
// See https://github.com/astral-sh/uv/issues/5915 for more details.
if !manylinux_compatible {
return Ok(platform_tags);
}
if let Some(min_minor) = arch.get_minimum_manylinux_minor() {
for minor in (min_minor..=*minor).rev() {
platform_tags.push(format!("manylinux_{major}_{minor}_{arch}"));
Expand Down Expand Up @@ -962,6 +962,7 @@ mod tests {
(3, 9),
"cpython",
(3, 9),
true,
false,
)
.unwrap();
Expand Down Expand Up @@ -1586,6 +1587,7 @@ mod tests {
"cpython",
(3, 9),
false,
false,
)
.unwrap();
assert_snapshot!(
Expand Down

0 comments on commit 2b57d6c

Please sign in to comment.