Repository navigation
uv ignores python_version input, silently selects newest Python #151
Description
Summary
The python_version input is documented as "Python version to use for SBOM
generation", but it has no effect on which interpreter uv actually uses.
For uv-managed projects whose requires-python floor is above the action's
default, uv silently discards the configured interpreter, downloads the newest
Python that satisfies requires-python, and then builds dependencies from
source because no wheels exist yet for that brand-new version. This can run for
many minutes and hit the caller's job timeout.
Evidence (action source at ref a849d7190403165d437f2b8d29bc17a4894728f7)
- lines 13-16 — input
python_version,required: false,default: "3.12":
python_version:
description: "Python version to use for SBOM generation"
required: false
default: "3.12"- lines 214-216 —
actions/setup-python@v7is given that input:
- name: "Setup Python"
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ inputs.python_version }}- line 342 — dependency install:
install_cmd=(uv sync --locked)- line 517 — command prefix, later used as
uv run cyclonedx-py environment --pyproject pyproject.toml ...:
CMD_PREFIX="uv run"Nothing binds uv to the interpreter installed by setup-python. There is no
--python flag, no UV_PYTHON environment variable, and no uv python pin
anywhere in the action. uv therefore performs its own interpreter resolution
from the project's requires-python, and per the uv documentation it will
automatically download a Python version when none on the system satisfies the
request:
https://docs.astral.sh/uv/concepts/python-versions/
Observed failure
Repository tykeal/homeassistant-rental-control, release workflow run
38915340624, job Generate SBOM, 2026-10-16.
- The project declares
requires-python = ">=3.14.2"inpyproject.tomland
has auv.lock. - The caller did not pass
python_version, so the action's3.12default was
used forsetup-python. 3.12does not satisfy>=3.14.2, so uv ignored it. Log at 14:25:17:
Downloading cpython-3.15.0-linux-x86_64-gnu (download) (35.9MiB)
- Python 3.15.0 had only just been released, so C-extension dependencies had no
wheels. The job spent the remaining time compiling from source; the processes
reaped at kill time wereuv,python, and multiplec++/cc1plus. - The job ran 14:25:03 -> 14:35:21 (10m18s) and was terminated by the caller's
timeout-minutes: 10. GitHub reports a timed-out job ascancelled, which
obscured the real cause. The downstream Grype job was skipped vianeeds:.
Why this is likely to affect others
A default of 3.12 is below the requires-python floor of a growing number of
projects, so the silent-override path is the common case rather than an edge
case. When it triggers, uv selects the newest satisfying interpreter —
precisely the version least likely to have prebuilt wheels available.
Projects with an unbounded requires-python (very common) effectively get
"whatever Python was released most recently" on every run, so a green pipeline
can start failing with no change at all on the consumer side.
Suggested remedies
Offered as options, not as a decided design:
- Bind uv to the configured interpreter — e.g. export
UV_PYTHON: ${{ inputs.python_version }}for the uv steps, or pass
--python. - Alternatively/additionally, after resolution, detect that the interpreter uv
selected differs frominputs.python_versionand fail fast with a clear
message rather than silently proceeding into a long source build. - Consider documenting that
python_versionis advisory for uv projects until
(1) lands.
Happy to raise a PR for whichever approach the maintainers prefer.
Activity