astral-sh/uv

uv cache management strategies for always-growing caches?

Open

#9,790 opened on Dec 10, 2024

View on GitHub
 (6 comments) (17 reactions) (0 assignees)Rust (84,934 stars) (3,111 forks)batch import
cacheenhancementhelp wantedneeds-design

Description

Hello uv folks! Thanks again for making such an awesome tool; it's optimized and streamlined so many parts our Python workflow.

We have a helpful little CI robot that builds our code from scratch every week without using our constraints files, to get the latest versions of various third-party Python packages we depend on. It then freezes these constraints files and opens a PR that updates them in the repository. This technique allows us to go "back in time" and get a set of first- and third-party packages that were used at the time of that historical build.

This strategy works great, but because we're constantly upgrading to the latest versions of all of these packages, our local uv caches end up getting huge- mine was multiple GB when I last looked!

We can remember to clear the cache at regular intervals (or not, and just let it grow), but I was wondering if we're missing a workflow that would keep our cache sizes reasonable, or if there's a way to tell uv something persistent like:

  • Only cache the latest version of a package by default
  • Delete the earliest versions of packages when the cache exceeds a size threshold (LRU eviction)
  • ?

Thanks for reading!

Contributor guide