Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use max rather than min to sort managed Pythons #5205

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/uv-python/src/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Comment on lines 14 to 19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty unintuitive, hope it doesn't bite us later :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess but it's also the standard derive implementation!


#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)]
pub enum LenientImplementationName {
Known(ImplementationName),
Unknown(String),
Known(ImplementationName),
}

impl ImplementationName {
Expand Down
7 changes: 4 additions & 3 deletions crates/uv-python/src/managed.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -150,14 +151,14 @@ impl ManagedPythonInstallations {
},
Err(err) => Some(Err(err)),
})
.collect::<Result<_, std::io::Error>>()
.collect::<Result<_, io::Error>>()
.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(),
Expand All @@ -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.
Expand Down
Loading