From dbb6ac2feea3c93afdb68332c45439923e3333d7 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 18 Jul 2024 21:12:56 -0400 Subject: [PATCH] Use max rather than min to sort managed Pythons --- crates/uv-python/src/implementation.rs | 6 +++--- crates/uv-python/src/managed.rs | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/uv-python/src/implementation.rs b/crates/uv-python/src/implementation.rs index 3ce36fd15a76..cc87b56afc80 100644 --- a/crates/uv-python/src/implementation.rs +++ b/crates/uv-python/src/implementation.rs @@ -12,16 +12,16 @@ pub enum Error { #[derive(Debug, Eq, PartialEq, Clone, Copy, Default, PartialOrd, Ord, Hash)] pub enum ImplementationName { + GraalPy, + PyPy, #[default] CPython, - PyPy, - GraalPy, } #[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)] pub enum LenientImplementationName { - Known(ImplementationName), Unknown(String), + Known(ImplementationName), } impl ImplementationName { diff --git a/crates/uv-python/src/managed.rs b/crates/uv-python/src/managed.rs index 6c8a8041fa17..3f6139538ed5 100644 --- a/crates/uv-python/src/managed.rs +++ b/crates/uv-python/src/managed.rs @@ -1,6 +1,7 @@ use core::fmt; use fs_err as fs; use itertools::Itertools; +use std::cmp::Reverse; use std::ffi::OsStr; use std::io::{self, Write}; use std::path::{Path, PathBuf}; @@ -150,14 +151,14 @@ impl ManagedPythonInstallations { }, Err(err) => Some(Err(err)), }) - .collect::>() + .collect::>() .map_err(|err| Error::ReadError { dir: self.root.clone(), err, })?; directories } - Err(err) if err.kind() == std::io::ErrorKind::NotFound => vec![], + Err(err) if err.kind() == io::ErrorKind::NotFound => vec![], Err(err) => { return Err(Error::ReadError { dir: self.root.clone(), @@ -174,7 +175,7 @@ impl ManagedPythonInstallations { }) .ok() }) - .sorted_unstable_by_key(|installation| installation.key().clone())) + .sorted_unstable_by_key(|installation| Reverse(installation.key().clone()))) } /// Iterate over Python installations that support the current platform.