5
0
mirror of https://github.com/astral-sh/setup-uv.git synced 2025-12-25 11:04:24 +00:00

Cache python installs (#621)

This pull request introduces support for caching Python installs in the
GitHub Action, allowing users to cache not only dependencies but also
the Python interpreter itself.

This works by setting the `UV_PYTHON_INSTALL_DIR` to a subdirectory of
the dependency cache path so that Python installs are directed there.

Fixes #135

---------

Co-authored-by: Kevin Stillhammer <kevin.stillhammer@gmail.com>
This commit is contained in:
Merlin
2025-10-09 16:47:24 -04:00
committed by GitHub
parent 3495667518
commit 6d2eb15b49
8 changed files with 197 additions and 23 deletions

View File

@@ -26,6 +26,7 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
- [Save cache](#save-cache)
- [Local cache path](#local-cache-path)
- [Disable cache pruning](#disable-cache-pruning)
- [Cache Python installs](#cache-python-installs)
- [Ignore nothing to cache](#ignore-nothing-to-cache)
- [GitHub authentication token](#github-authentication-token)
- [UV_TOOL_DIR](#uv_tool_dir)
@@ -355,6 +356,20 @@ input.
prune-cache: false
```
### Cache Python installs
By default, the Python install dir (`uv python dir` / `UV_PYTHON_INSTALL_DIR`) is not cached,
for the same reason that the dependency cache is pruned.
If you want to cache Python installs along with your dependencies, set the `cache-python` input to `true`.
```yaml
- name: Cache Python installs
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-python: true
```
### Ignore nothing to cache
By default, the action will fail if caching is enabled but there is nothing to upload (the uv cache directory does not exist).