Debian Codegraph @

.github/actions/setup-uv-python/action.yml

raw
1 name: Set up uv and managed Python
2 description: >-
3 Pins uv and proactively installs the requested Python so cached venvs
4 resolve their interpreter symlinks in jobs that only restore the venv.
5 setup-uv alone only sets UV_PYTHON, it does not actually fetch the
6 interpreter until uv first uses it, so jobs that just activate a cached
7 venv blow up with broken symlinks on cache hit. setup-uv v8.1.0 also
8 fetches its version manifest from raw.githubusercontent.com on every run
9 even when version is pinned, so the setup step is retried a couple of
10 times to ride out raw.githubusercontent.com flakes.
11
12 inputs:
13 python-version:
14 description: The Python version uv should install and use.
15 required: true
16 uv-version:
17 description: The uv version setup-uv should install.
18 required: true
19
20 outputs:
21 python-version:
22 description: The Python version uv reports as installed.
23 value: ${{ steps.uv3.outputs.python-version || steps.uv2.outputs.python-version || steps.uv1.outputs.python-version }}
24
25 runs:
26 using: composite
27 steps:
28 - name: Set up uv (attempt 1)
29 id: uv1
30 continue-on-error: true
31 uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
32 with:
33 version: ${{ inputs.uv-version }}
34 python-version: ${{ inputs.python-version }}
35 # Persist astral's managed Python across jobs so 'uv venv' / poetry
36 # env use below is fast on the second job onwards.
37 cache-python: true
38 # Jobs that only configure the toolchain (no deps to cache) would
39 # otherwise abort with "Nothing to cache" on the post step.
40 ignore-nothing-to-cache: true
41 - name: Set up uv (attempt 2)
42 id: uv2
43 if: steps.uv1.outcome == 'failure'
44 continue-on-error: true
45 uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
46 with:
47 version: ${{ inputs.uv-version }}
48 python-version: ${{ inputs.python-version }}
49 cache-python: true
50 ignore-nothing-to-cache: true
51 - name: Set up uv (attempt 3)
52 id: uv3
53 if: steps.uv1.outcome == 'failure' && steps.uv2.outcome == 'failure'
54 uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
55 with:
56 version: ${{ inputs.uv-version }}
57 python-version: ${{ inputs.python-version }}
58 cache-python: true
59 ignore-nothing-to-cache: true
60 - name: Install Python interpreter
61 shell: bash
62 env:
63 PYTHON_VERSION: ${{ inputs.python-version }}
64 # 'uv python install' on Windows blows up with a reparse-point tag
65 # mismatch (os error 4394) when cache-python: true already restored
66 # the install dir, so only install when find says we have nothing yet.
67 run: |
68 if ! uv python find "${PYTHON_VERSION}" >/dev/null 2>&1; then
69 uv python install "${PYTHON_VERSION}"
70 fi