Install Python via astral-sh/setup-uv in test/autobahn jobs#12629
Conversation
actions/setup-python downloads non-cached interpreter variants from its release index, which takes ~40s on macos-latest and ~58s on windows-latest for 3.14t (the free-threaded build is not in the hosted-tool-cache). astral-sh/setup-uv pulls python-build-standalone from a CDN, which is a few seconds across all three OSes. Swap actions/setup-python@v6 for astral-sh/setup-uv@v8.1.0 in the matrix test job and the autobahn job. activate-environment: true seeds a venv with python and pip on PATH so the subsequent 'uv pip install ...' invocations target it directly. The action's own enable-cache: true subsumes the previous actions/cache pip cache step, which is dropped. 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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12629 +/- ##
========================================
Coverage 98.94% 98.94%
========================================
Files 131 131
Lines 46726 46475 -251
Branches 2424 2410 -14
========================================
- Hits 46232 45987 -245
+ Misses 369 366 -3
+ Partials 125 122 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Merging this PR will not alter performance
Comparing Footnotes
|
|
its using system python for 3.12 since its in the path first |
|
needs python-preference: only-managed |
|
at some point we want to move to reusable tox but thats a lot more involved for this repo so this is still a good step in between |
|
it still used system python instead of managed python https://docs.astral.sh/uv/concepts/python-versions/#adjusting-python-version-preferences maybe I'm reading docs wrong |
|
UV_PYTHON_PREFERENCE=only-managed trying that |
|
haha .. long week need some sleep |
|
UV_PYTHON_PREFERENCE=only-managed was the key to getting this working |
Backport to 3.13: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 66cc7b6 on top of patchback/backports/3.13/66cc7b68aad1ca084d210a466d4970de9619f10e/pr-12629 Backporting merged PR #12629 into master
🤖 @patchback |
Backport to 3.14: 💚 backport PR created✅ Backport PR branch: Backported as #12637 🤖 @patchback |
|
thats another 12 runner minutes we get back in a lot of cases |
…p-uv in test/autobahn jobs (#12637) Co-authored-by: J. Nick Koston <nick@koston.org>
|
Hi @bdraco I see you put some effort to make sure uv will always use managed python, not the system one for virtual envs. I'm curious what was the reason to insist on that? Is it just faster imports, or there were some issues with system python? One of the distinctive features of uv managed python builds is that they statically link all extension modules and OpenSSL. I'm working on aiofastnet PR , and aiofastnet can only work if OpenSSL is linked dynamically to python ssl module. Otherwise aiofastnet is not able to locate and use functions like SSL_read, SSL_write, etc. It will refuse to import with ImportError exception. This makes the code in my PR to fall back to asyncio, but it would be nice if I could run aiohttp tests with aiofastnet working at least for a single python version. I can add a separate job for that, but maybe we can just allow system python when it matches the requested version? |
What do these changes do?
Swap
actions/setup-python@v6forastral-sh/setup-uv@v8.1.0inthe two CI matrix jobs that install a Python interpreter —
testand
autobahn.activate-environment: truekeepspython/pipon PATH so the subsequent
uv pip install ...invocations targetthe seeded venv.
enable-cache: truesubsumes the previousactions/cachepip-cache step, which is dropped.Are there changes in behavior for the user?
No. This only affects CI runner provisioning. End-user-visible
behavior of
aiohttpis 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 maintainers 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.
This mirrors aio-libs/yarl#1704, which made the same swap.
Related issue number
N/A.
Checklist
CONTRIBUTORS.txt— already listedCHANGES/folder — to be added in a follow-up commit once the PR number is assignedAgent run details (optional, for reviewers)
actions/setup-pythondownloads non-cached interpreter variantsfrom its release index, which takes ~40s on macos-latest and ~58s
on windows-latest for
3.14t(the free-threaded build is not inthe hosted-tool-cache).
astral-sh/setup-uvpullspython-build-standalone from a CDN, which is a few seconds across
all three OSes. Motivation transferred from the yarl PR's own
measurements.
Drafted with Claude Code (Opus 4.7); reviewed by @bdraco.