Refactor uv python install (#8701)

Pulling out of https://github.com/astral-sh/uv/pull/8650 for
readability.

Trying to clean this up to simplify extensions in the future. This is
not a strict refactor, there are behavioral changes here.

- Adds some structs for managing state.
- Addresses some likely inconsistent behavior for weird edge-cases. 
- We fill platform information before checking if a request is
satisfied.
- We error earlier if we can't find a download for the request, i.e.,
even if you somehow have it installed.
- Only reports versions as uninstalled if a download actually replaces
them.
- Moves some of the default output to tracing messages.
- Even if an installation was already satisfied, we'll check that it is
setup properly
This commit is contained in:
Zanie Blue 2024-10-30 16:28:08 -05:00 committed by GitHub
parent bed47d512a
commit 893257bb0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 261 additions and 177 deletions

View file

@ -423,7 +423,7 @@ pub enum DownloadResult {
}
impl ManagedPythonDownload {
/// Return the first [`PythonDownload`] matching a request, if any.
/// Return the first [`ManagedPythonDownload`] matching a request, if any.
pub fn from_request(
request: &PythonDownloadRequest,
) -> Result<&'static ManagedPythonDownload, Error> {
@ -433,7 +433,7 @@ impl ManagedPythonDownload {
.ok_or(Error::NoDownloadFound(request.clone()))
}
/// Iterate over all [`PythonDownload`]'s.
/// Iterate over all [`ManagedPythonDownload`]s.
pub fn iter_all() -> impl Iterator<Item = &'static ManagedPythonDownload> {
PYTHON_DOWNLOADS
.iter()