Stabilize Python upgrades (#17766)

Includes a few things...

- Drops preview warnings for use of `uv python upgrade` and `uv python
install --upgrade`
- Adds `--resolve-links` to `uv python find`, which I needed in test
cases to retain existing snapshots
- Fixes issues in our "Using environment ..." messages on Windows which
were incorrect
- Refactors `from_executable` for the `PythonMinorVersionLink` type
(https://github.com/astral-sh/uv/pull/17842/commits/28b2ed2525327d94fdf5372a29bbbc476d74680f)
to use the type system to prevent incorrect construction (for above)
- Removes special casing where we only upgrade links if they already
exist, which existed so preview wasn't needed on every invocation
- Fixes a bug with `PythonMinorVersionLink::exists` which returned
`true` even if the link pointed to the wrong Python installation leading
to discovery failures
This commit is contained in:
Zanie Blue
2026-02-05 11:26:54 -06:00
parent f3d50129c6
commit d2ab2d0208
35 changed files with 221 additions and 239 deletions
+1 -4
View File
@@ -356,7 +356,6 @@ fn python_executables_from_installed<'a>(
implementation: Option<&'a ImplementationName>,
platform: PlatformRequest,
preference: PythonPreference,
preview: Preview,
) -> Box<dyn Iterator<Item = Result<(PythonSource, PathBuf), Error>> + 'a> {
let from_managed_installations = iter::once_with(move || {
ManagedPythonInstallations::from_settings(None)
@@ -411,7 +410,6 @@ fn python_executables_from_installed<'a>(
.then(|| {
PythonMinorVersionLink::from_installation(
&installation,
preview,
)
.filter(PythonMinorVersionLink::exists)
.map(
@@ -547,7 +545,7 @@ fn python_executables<'a>(
let from_virtual_environments = python_executables_from_virtual_environments(preview);
let from_installed =
python_executables_from_installed(version, implementation, platform, preference, preview);
python_executables_from_installed(version, implementation, platform, preference);
// Limit the search to the relevant environment preference; this avoids unnecessary work like
// traversal of the file system. Subsequent filtering should be done by the caller with
@@ -1542,7 +1540,6 @@ pub(crate) async fn find_best_python_installation(
reporter,
python_install_mirror,
pypy_install_mirror,
preview,
)
.await
.map(Some),