Action — setup-python
Installs Python with uv and restores the uv dependency cache.
Usage
yaml
steps:
- uses: actions/checkout@v7
- uses: KevinDeBenedetti/github-workflows/.github/actions/setup-python@main
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 |
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 self-hosted runners 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.