Update uv python install --reinstall to reinstall all previous versions (#11072)

Since we're shipping substantive updates to Python versions frequently,
I want to lower the bar for reinstalling with the latest distributions.

There's a follow-up task that's documented in a test case at
https://github.com/astral-sh/uv/pull/11072/files#diff-f499c776e1d8cc5e55d7620786e32e8732b675abd98e246c0971130f5de9ed50R157-R158
This commit is contained in:
Zanie Blue 2025-01-30 10:08:06 -06:00 committed by GitHub
parent d517b1ca26
commit 586bab32b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 164 additions and 23 deletions

View file

@ -28,6 +28,7 @@ use crate::implementation::{
};
use crate::installation::PythonInstallationKey;
use crate::libc::LibcDetectionError;
use crate::managed::ManagedPythonInstallation;
use crate::platform::{self, Arch, Libc, Os};
use crate::{Interpreter, PythonRequest, PythonVersion, VersionRequest};
@ -344,6 +345,23 @@ impl PythonDownloadRequest {
}
}
impl From<&ManagedPythonInstallation> for PythonDownloadRequest {
fn from(installation: &ManagedPythonInstallation) -> Self {
let key = installation.key();
Self::new(
Some(VersionRequest::from(&key.version())),
match &key.implementation {
LenientImplementationName::Known(implementation) => Some(*implementation),
LenientImplementationName::Unknown(name) => unreachable!("Managed Python installations are expected to always have known implementation names, found {name}"),
},
Some(key.arch),
Some(key.os),
Some(key.libc),
Some(key.prerelease.is_some()),
)
}
}
impl Display for PythonDownloadRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut parts = Vec::new();