Skip to content

Clear Python installation scratch space with uv cache clean - #20754

Closed
woodruffw wants to merge 2 commits into
mainfrom
ww/better-clean
Closed

Clear Python installation scratch space with uv cache clean#20754
woodruffw wants to merge 2 commits into
mainfrom
ww/better-clean

Conversation

@woodruffw

Copy link
Copy Markdown
Member

Summary

Fixes #20675.

There are two distinct parts here:

  • uv python itself now has a provision to attempt to clear the scratch directory
  • uv cache clean now tries to clear the scratch directory by default

I'm not 100% sure whether either/both is best -- I think clearing as part of uv python is arguably superfluous (IIUC there will functionally never be anything to clear, since the only way clear_scratch will be reachable is if an installation/download wasn't interrupted). Arguably therefore we should maybe only do this as part of uv cache clean.

Curious if @geofft has strong opinions on that as well 🙂

Test Plan

Added tests for various scenarios with uv cache clean + different states for the Python installation scratch directory.

Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw woodruffw self-assigned this Jul 27, 2026
@woodruffw woodruffw added cache Caching of packages and metadata uv python Related to the uv python interface labels Jul 27, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the main base revision.

  • Added tests: 7
  • Removed tests: 0
  • Changed suites: 2
uv::build: +5 / -0

Added:

  • uv::build::cache_clean::clean_all_does_not_report_empty_python_temporary_directories
  • uv::build::cache_clean::clean_all_python_temporary_directories
  • uv::build::cache_clean::clean_package_preserves_python_temporary_directories
  • uv::build::cache_clean::clean_python_temporary_directories_waits_for_installation_lock
  • uv::build::cache_clean::clean_python_temporary_directories_without_cache

Removed: none

uv::python: +2 / -0

Added:

  • uv::python::python_install::python_install_automatic_cleans_stale_temporary_directories
  • uv::python::python_install::python_install_cleans_stale_temporary_directories

Removed: none

@zanieb zanieb changed the title Clear Python installation scratch space with uv clean Clear Python installation scratch space with uv cache clean Jul 27, 2026
@woodruffw

Copy link
Copy Markdown
Member Author

#20752 addresses the main root cause of this. We could still do the things here, but IMO only the uv cache clean half is probably worthwhile. Closing for now until we have more evidence that interrupts (rather than network errors) are the root cause.

@woodruffw woodruffw closed this Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cache Caching of packages and metadata uv python Related to the uv python interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up ~/.local/share/uv/python/.temp

1 participant