From 136ebaca2ad3e3bf24affdb693b9335ff1a8124b Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 21 Feb 2024 20:08:34 -0500 Subject: [PATCH 1/2] Treat ARM wheels as higher-priority than universal --- crates/platform-tags/src/lib.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/platform-tags/src/lib.rs b/crates/platform-tags/src/lib.rs index e444864d2d9f..baa94ea3faed 100644 --- a/crates/platform-tags/src/lib.rs +++ b/crates/platform-tags/src/lib.rs @@ -236,14 +236,14 @@ impl Tags { /// The priority of a platform tag. /// -/// A wrapper around [`NonZeroU32`]. Higher values indicate higher priority. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +/// A wrapper around [`NonZeroU32`]. Lower values indicate higher priority. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct TagPriority(NonZeroU32); impl TryFrom for TagPriority { type Error = TagsError; - /// Create a [`TagPriority`] from a `usize`, where higher `usize` values are given higher + /// Create a [`TagPriority`] from a `usize`, where lower `usize` values are given higher /// priority. fn try_from(priority: usize) -> Result { match u32::try_from(priority).and_then(|priority| NonZeroU32::try_from(1 + priority)) { @@ -253,6 +253,18 @@ impl TryFrom for TagPriority { } } +impl Ord for TagPriority { + fn cmp(&self, other: &Self) -> cmp::Ordering { + self.0.cmp(&other.0).reverse() + } +} + +impl PartialOrd for TagPriority { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + #[derive(Debug, Clone, Copy)] pub enum Implementation { CPython, From f6a639d0ec518d36e7effeaf9d21f83735746282 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 21 Feb 2024 20:34:39 -0500 Subject: [PATCH 2/2] Remove sort --- crates/platform-tags/src/lib.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/crates/platform-tags/src/lib.rs b/crates/platform-tags/src/lib.rs index baa94ea3faed..2d9f3492d451 100644 --- a/crates/platform-tags/src/lib.rs +++ b/crates/platform-tags/src/lib.rs @@ -154,7 +154,6 @@ impl Tags { "none".to_string(), "any".to_string(), )); - tags.sort(); Ok(Self::new(tags)) } @@ -236,14 +235,14 @@ impl Tags { /// The priority of a platform tag. /// -/// A wrapper around [`NonZeroU32`]. Lower values indicate higher priority. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +/// A wrapper around [`NonZeroU32`]. Higher values indicate higher priority. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct TagPriority(NonZeroU32); impl TryFrom for TagPriority { type Error = TagsError; - /// Create a [`TagPriority`] from a `usize`, where lower `usize` values are given higher + /// Create a [`TagPriority`] from a `usize`, where higher `usize` values are given higher /// priority. fn try_from(priority: usize) -> Result { match u32::try_from(priority).and_then(|priority| NonZeroU32::try_from(1 + priority)) { @@ -253,18 +252,6 @@ impl TryFrom for TagPriority { } } -impl Ord for TagPriority { - fn cmp(&self, other: &Self) -> cmp::Ordering { - self.0.cmp(&other.0).reverse() - } -} - -impl PartialOrd for TagPriority { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - #[derive(Debug, Clone, Copy)] pub enum Implementation { CPython,