66 python-version :
77 description : " Python version (e.g. '3.7', '3.8.13', '3.11.0-alpha.1', '3.x')."
88 required : true
9- install-seed-packages :
10- description : >
11- Set to 'true' to install and/or upgrade seed packages (pip, setuptools, and wheel)
12- before installing other packages.
13- required : false
14- default : " false"
159 requirements :
1610 description : " Optional list of arguments passed to `uv pip install` (e.g. 'numpy==1.19.5', '-r requirements.txt')."
1711 required : false
@@ -23,37 +17,19 @@ runs:
2317 with :
2418 python-version : " ${{ inputs.python-version }}"
2519
20+ # Install uv and enable its built-in cache. The cache key takes the
21+ # platform, the uv version, and a hash of the files below into account.
22+ # See https://docs.astral.sh/uv/guides/integration/github/ for details.
23+ # NOTE: setup-uv publishes immutable releases only (no
24+ # floating major tags), so we pin the full version
2625 - name : Install uv
27- shell : bash
28- run : pip install --upgrade uv
29-
30- # >>>>>>>> Caching uv packages >>>>>>>>
31-
32- - name : Get uv cache dir
33- id : uv-cache
34- shell : bash
35- run : echo "dir=$(uv cache dir)" >> $GITHUB_OUTPUT
36-
37- - name : Get the current date in format YYYYWW (year and week-of-year)
38- id : get-date
39- shell : bash
40- run : echo "date=$(/bin/date -u "+%Y%U")" >> $GITHUB_OUTPUT
41-
42- - name : uv cache
43- uses : actions/cache@v4
26+ uses : astral-sh/setup-uv@v9.0.0
4427 with :
45- path : ${{ steps.uv-cache.outputs.dir }}
46- # The cache's TTL is 7 days (one week)
47- key : uv-${{ runner.os }}-${{ inputs.python-version }}-${{ steps.get-date.outputs.date }}
48- # Fall back to the previous week's cache
49- restore-keys : uv-${{ runner.os }}-${{ inputs.python-version }}-
50-
51- # <<<<<<<< Caching uv packages <<<<<<<<
52-
53- - name : Install and/or upgrade seed packages
54- if : ${{ inputs.install-seed-packages == 'true' }}
55- shell : bash
56- run : uv pip install --verbose --system --upgrade pip setuptools wheel
28+ enable-cache : true
29+ cache-suffix : " py${{ inputs.python-version }}"
30+ cache-dependency-glob : |
31+ pyproject.toml
32+ requirements/*.txt
5733
5834 - name : Install requirements
5935 if : ${{ inputs.requirements != '' }}
0 commit comments