Sort by implementation in `uv python list` (#6918)

## Summary

With #6917, there are a lot more PyPy downloads in `uv python list
--all-versions`. I find it clearer to have all the CPython downloads
listed, then all the PyPy downloads, rather than interspersing them. But
this is subjective, feel free to push back!
This commit is contained in:
Charlie Marsh 2024-09-04 17:35:51 -04:00 committed by GitHub
parent ff39950545
commit 20c666c10d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 15 deletions

View File

@ -59,13 +59,7 @@ pub(crate) async fn list(
.flatten();
for download in downloads {
output.insert((
download.python_version().version().clone(),
download.os().to_string(),
download.key().clone(),
Kind::Download,
None,
));
output.insert((download.key().clone(), Kind::Download, None));
}
};
@ -94,9 +88,7 @@ pub(crate) async fn list(
Kind::System
};
output.insert((
installation.python_version().clone(),
installation.os().to_string(),
installation.key().clone(),
installation.key(),
kind,
Some(installation.interpreter().sys_executable().to_path_buf()),
));
@ -106,7 +98,7 @@ pub(crate) async fn list(
let mut seen_patch = FxHashSet::default();
let mut seen_paths = FxHashSet::default();
let mut include = Vec::new();
for (version, os, key, kind, path) in output.iter().rev() {
for (key, kind, path) in output.iter().rev() {
// Do not show the same path more than once
if let Some(path) = path {
if !seen_paths.insert(path) {
@ -116,9 +108,9 @@ pub(crate) async fn list(
// Only show the latest patch version for each download unless all were requested
if !matches!(kind, Kind::System) {
if let [major, minor, ..] = version.release() {
if let [major, minor, ..] = key.version().release() {
if !seen_minor.insert((
os.clone(),
*key.os(),
*major,
*minor,
key.implementation(),
@ -130,9 +122,9 @@ pub(crate) async fn list(
}
}
}
if let [major, minor, patch] = version.release() {
if let [major, minor, patch] = key.version().release() {
if !seen_patch.insert((
os.clone(),
*key.os(),
*major,
*minor,
*patch,