Action — setup-python
Installs Python with uv and restores the uv dependency cache.
Usage
yaml
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: KevinDeBenedetti/github-workflows/.github/actions/setup-python@v0.57.0 # x-release-please-version
with:
python-version: '3.12'Inputs
| Input | Type | Default | Description |
|---|---|---|---|
python-version | string | '3.12' | Python version to install |
working-directory | string | '.' | Directory containing pyproject.toml |
uv-version | string | pinned | uv version to install (bumped by Renovate) |
install | boolean | true | Run uv sync after setup |
Outputs
| Output | Description |
|---|---|
cache-hit | Whether the uv cache was restored |
Steps
- Install uv (latest), with uv's own dependency cache enabled
- Setup Python
python-version - Run
uv sync --frozen
Notes
install: 'false'skips theuv syncstep — useful when you only need the Python + uv toolchain.- Caching is handled by
setup-uvitself, not by a separateactions/cachestep.setup-uvexportsUV_CACHE_DIR, so caching the conventional~/.cache/uvpath by hand does nothing on GitHub-hosted runners — uv writes to$RUNNER_TEMP/setup-uv-cachethere. - Cache is enabled explicitly rather than left on
setup-uv'sautodefault:autoonly turns caching on for GitHub-hosted runners, and these workflows can be routed onto other runners (Ubicloud's) through theirrunnerinput. - The cache key covers
runner.os,python-version(viacache-suffix), and the hash of the dependency filessetup-uvtracks by default —uv.lock,pyproject.toml, andrequirements/constraintsfiles — so it is invalidated when dependencies change.