Install Python via astral-sh/setup-uv to skip 40-58s downloads#1704
Conversation
The macOS and Windows hosted runners don't keep pre-release or free-threaded CPython variants in the tool-cache, so `actions/setup-python` falls back to downloading them from the `python-versions` repo on each run. For `3.14t` that took 40s on macOS and 58s on Windows, dominating jobs whose pytest run is only 9-18s. `astral-sh/setup-uv` fetches python-build-standalone from a CDN and creates a seeded venv, which completes in a few seconds for the same matrix entries. `activate-environment: true` keeps `python`/`pip` on PATH so the rest of the pipeline (`re-actors/cache-python-deps`, `py-actions/py-dependency-install`, the inline `pip install` steps) is unchanged. The `allow-prereleases` input has no equivalent on setup-uv because uv treats prereleases as first-class. The codecov flag derived from `steps.python-install.outputs.python-version` now reports the matrix spec (`3.14t`) rather than the resolved patch (`3.14.5t`); coarser but easier to group across patch releases. Closes #1703.
Symlink CHANGES/1704.contrib.rst -> 1703.contrib.rst so towncrier picks up both the issue and the PR cross-reference.
Coverage Report for CI Build 26050613112Coverage remained the same at 98.724%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
The floating `v8` major tag does not exist; setup-uv switched to immutable releases at v8.0.0 and only publishes per-version tags from then on. Use the exact `v8.1.0` tag (same style as the existing `sigstore/gh-action-sigstore-python@v3.3.0` pin).
When `actions/setup-python` was the interpreter source, the companion `re-actors/cache-python-deps` action sped up the pip HTTP cache across runs. With `astral-sh/setup-uv` and `activate-environment: true` the venv is created without `--seed`, so pip is missing and the cache wrapper's `python -Im pip cache dir` probe crashes the job. Rather than seed pip back in just to keep the wrapper working, go uv-native: * Drop the `Calculate cache key` + `Set up pip cache` pair from both the build-sdist and test-matrix jobs. * Set `enable-cache: true` on the two `setup-uv` invocations so uv's own wheel cache ($UV_CACHE_DIR) is persisted across runs. * Replace `py-actions/py-dependency-install` with a one-line `uv pip install -r requirements/test.txt`. * Collapse the `pip --dry-run --report=-` + `jq` wheel-discovery trick and the follow-up `pip install <url>` into a single `uv pip install --find-links=./dist --no-index --no-deps --force-reinstall --only-binary=:all: yarl`. uv resolves the matching wheel for the active interpreter directly, so the intermediate JSON parse is unnecessary. * Swap the remaining inline `pip install build` and `pip install expandvars` calls for `uv pip install` so the whole pipeline uses one cache. Net: -53 lines, no more pip dependency in the venv, and every install benefits from uv's resolver and cache. Verified locally: `uv venv --python 3.12` (unseeded) + `uv pip install -r requirements/test.txt` succeeds against the real requirements file (resolves through to `pygments==2.20.0`, `pytest==9.0.3`, etc.) without needing pip in the venv.
|
@aiolibsbot review |
PR Review — ci: install Python via astral-sh/setup-uv to skip 40-58s downloadsClean CI swap, well motivated by the runtime numbers in the PR body. The replacement is local to the two action invocations: 🟢 Suggestions1. Version pin style inconsistent with the rest of the workflow (`.github/workflows/ci-cd.yml`, L80)The rest of this file pins third-party actions to a major version ( 2. `allow-prereleases: true` dropped — confirm 3.14t still resolves (`.github/workflows/ci-cd.yml`, L268-270)The old Checklist
SummaryClean CI swap, well motivated by the runtime numbers in the PR body. The replacement is local to the two action invocations: |
webknjaz
left a comment
There was a problem hiding this comment.
If there's uv already, I imagine it might be able to produce dists w/o pypa/build, eh?
What do these changes do?
Swap
actions/setup-python@v6forastral-sh/setup-uv@v8in thetwo CI jobs that install a Python interpreter: the
build-pure-python-distsstep and the matrixteststep.activate-environment: truekeepspython/pipon PATH so therest of the pipeline (
re-actors/cache-python-deps,py-actions/py-dependency-install, inlinepip installcalls)is unchanged.
Are there changes in behavior for the user?
No. This only affects CI runner provisioning. End-user-visible
behavior of
yarlis unaffected.The Codecov flag derived from
steps.python-install.outputs.python-versionnow reports thematrix spec (
3.14t) rather than the resolved patch(
3.14.5t); coarser, but easier to group across patch releases.Is it a substantial burden for the maintainer to support this?
No.
astral-sh/setup-uvis widely used across aio-libs and thebroader Python ecosystem;
activate-environment: truereproducesthe behavior the existing pipeline already relies on, so the swap
is local to the action invocation.
Related issue number
Closes #1703.
Checklist
CONTRIBUTORS.txtCHANGES/folder (1703.contrib.rst)Agent run details (optional, for reviewers)
Drafted with Claude Code (Opus 4.7); reviewed by @bdraco.
Motivation pulled from PR #1682 run
https://github.com/aio-libs/yarl/actions/runs/26049305898, where
Setup Python 3.14ttook 40s onmacos-latestand 58s onwindows-latestfor a test step that ran in 9-18s. Per-jobbreakdown (setup vs. tests, all in seconds):
Linux has the slow variants in
hostedtoolcache; macOS/Windowsdo not.
astral-sh/setup-uvfetches python-build-standalone froma CDN, which is consistently a few seconds across all three OSes.
Local verification: ran
uv python install 3.14t,uv venv --python 3.14t --seed, activated, and confirmedpython -Im pip install buildworks exactly as before. That isthe same sequence
setup-uvruns withactivate-environment: true.