Skip to content

Add --outdated to uv python uninstall and --uninstall to uv python upgrade#18770

Open
MoonMao42 wants to merge 2 commits intoastral-sh:mainfrom
MoonMao42:feat/python-uninstall-outdated
Open

Add --outdated to uv python uninstall and --uninstall to uv python upgrade#18770
MoonMao42 wants to merge 2 commits intoastral-sh:mainfrom
MoonMao42:feat/python-uninstall-outdated

Conversation

@MoonMao42
Copy link
Copy Markdown

Summary

Rebase of #16018 (by @yumeminami, with review changes from @zanieb) onto current main, plus uv python upgrade --uninstall per @konstin's suggestion in #15805.

Two ways to clean up old Python patch versions:

  • uv python uninstall --outdated — remove old patches standalone
  • uv python upgrade --uninstall — remove old patches after upgrading

Closes #15805.

Test Plan

  • python_uninstall_outdated: multiple minor versions, --outdated keeps only latest patch each
  • python_uninstall_outdated_with_target: --outdated 3.12 scoped to one minor
  • python_upgrade_with_uninstall: install 3.12.6 → upgrade 3.12 --uninstall → 3.12.6 gone

@MoonMao42 MoonMao42 force-pushed the feat/python-uninstall-outdated branch 2 times, most recently from b8d7bc7 to 26f4209 Compare March 30, 2026 16:12
Rebased from astral-sh#16018 by @yumeminami with review changes from @zanieb.

Adds `--outdated` to `uv python uninstall` to remove old patch versions
while keeping the latest for each minor version. Supports filtering by
target (e.g., `uv python uninstall 3.12 --outdated`) and ignores the
flag when a specific patch version is requested.
After upgrading Python to the latest patch version, `--uninstall`
removes old patch versions from the same minor-version group. Groups
are scoped by implementation, major.minor, platform, and variant so
freethreaded and standard builds are cleaned independently.

Cleanup runs after all upgrades complete and only affects groups that
were actually upgraded in the current invocation. Deletion failures
are logged as warnings and do not affect the exit code.
@MoonMao42 MoonMao42 force-pushed the feat/python-uninstall-outdated branch from 26f4209 to f0aa731 Compare March 30, 2026 16:15
@konstin konstin requested a review from zanieb March 31, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A way to remove old Python versions

1 participant