Optional managed Python archive download cache (#12175)

Part of #11834

Currently, all Python installation are a streaming download-and-extract.
With this PR, we add the `UV_PYTHON_CACHE_DIR` variable. When set, the
installation is split into downloading the interpreter into
`UV_PYTHON_CACHE_DIR` and extracting it there from a second step. If the
archive is already present in `UV_PYTHON_CACHE_DIR`, we skip the
download.

The feature can be used to speed up tests and CI. Locally for me, `cargo
test -p uv -- python_install` goes from 43s to 7s (1,7s in release mode)
when setting `UV_PYTHON_CACHE_DIR`. It can also be used for offline
installation of Python interpreter, by copying the archives to a
directory in the offline machine, while the path rewriting is still
performed on the target machine on installation.
This commit is contained in:
konsti 2025-04-28 12:09:09 +02:00 committed by GitHub
parent cfe82dc22a
commit b33a19689c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 371 additions and 96 deletions

View file

@ -339,6 +339,11 @@ this Python interpreter for all operations.
Specifies the directory to place links to installed, managed Python executables.
### `UV_PYTHON_CACHE_DIR`
Specifies the directory for caching the archives of managed Python installations before
installation.
### `UV_PYTHON_DOWNLOADS`
Equivalent to the