Skip to content

Install Python via astral-sh/setup-uv in test/autobahn jobs#12629

Merged
bdraco merged 6 commits into
aio-libs:masterfrom
bdraco:ci-setup-uv
May 18, 2026
Merged

Install Python via astral-sh/setup-uv in test/autobahn jobs#12629
bdraco merged 6 commits into
aio-libs:masterfrom
bdraco:ci-setup-uv

Conversation

@bdraco

@bdraco bdraco commented May 18, 2026

Copy link
Copy Markdown
Member

What do these changes do?

Swap actions/setup-python@v6 for astral-sh/setup-uv@v8.1.0 in
the two CI matrix jobs that install a Python interpreter — test
and autobahn. activate-environment: true keeps python/pip
on PATH so the subsequent uv pip install ... invocations target
the seeded venv. enable-cache: true subsumes the previous
actions/cache pip-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 aiohttp is unaffected.

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.

Is it a substantial burden for the maintainers to support this?

No. astral-sh/setup-uv is widely used across aio-libs and the
broader Python ecosystem; activate-environment: true reproduces
the 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

  • I think the code is well written
  • Unit tests for the changes exist — N/A (CI configuration)
  • Documentation reflects the changes — N/A (no user-visible change)
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt — already listed
  • Add a new news fragment into the CHANGES/ folder — to be added in a follow-up commit once the PR number is assigned
Agent run details (optional, for reviewers)

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. Motivation transferred from the yarl PR's own
measurements.

Drafted with Claude Code (Opus 4.7); reviewed by @bdraco.

bdraco added 2 commits May 18, 2026 11:24
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.
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label May 18, 2026
@bdraco bdraco added backport-3.13 backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot labels May 18, 2026
@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.94%. Comparing base (3ef0965) to head (976f256).
⚠️ Report is 5 commits behind head on master.
✅ All tests successful. No failed tests found.

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     
Flag Coverage Δ
Autobahn 22.43% <ø> (-0.02%) ⬇️
CI-GHA 98.92% <ø> (+<0.01%) ⬆️
OS-Linux 98.66% <ø> (+<0.01%) ⬆️
OS-Windows 97.02% <ø> (-0.01%) ⬇️
OS-macOS 97.92% <ø> (-0.01%) ⬇️
Py-3.10 98.14% <ø> (?)
Py-3.10.11 ?
Py-3.10.20 ?
Py-3.11 98.41% <ø> (?)
Py-3.11.15 ?
Py-3.11.9 ?
Py-3.12 98.49% <ø> (?)
Py-3.12.10 ?
Py-3.12.13 ?
Py-3.13 98.46% <ø> (?)
Py-3.13.13 ?
Py-3.14 98.48% <ø> (?)
Py-3.14.4 ?
Py-3.14.5 ?
Py-3.14.5t ?
Py-3.14t 97.54% <ø> (?)
Py-pypy-3.11 97.41% <ø> (?)
Py-pypy3.11.15-7.3.22 ?
VM-macos 97.92% <ø> (-0.01%) ⬇️
VM-ubuntu 98.66% <ø> (+<0.01%) ⬆️
VM-windows 97.02% <ø> (-0.01%) ⬇️
cython-coverage 37.74% <ø> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codspeed-hq

codspeed-hq Bot commented May 18, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 68 untouched benchmarks
⏩ 72 skipped benchmarks1


Comparing bdraco:ci-setup-uv (976f256) with master (247b323)

Open in CodSpeed

Footnotes

  1. 72 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@bdraco

bdraco commented May 18, 2026

Copy link
Copy Markdown
Member Author

its using system python for 3.12 since its in the path first

@bdraco

bdraco commented May 18, 2026

Copy link
Copy Markdown
Member Author

needs python-preference: only-managed

@bdraco

bdraco commented May 18, 2026

Copy link
Copy Markdown
Member Author

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

@bdraco

bdraco commented May 18, 2026

Copy link
Copy Markdown
Member Author

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

@bdraco

bdraco commented May 18, 2026

Copy link
Copy Markdown
Member Author

UV_PYTHON_PREFERENCE=only-managed

trying that

@bdraco

bdraco commented May 18, 2026

Copy link
Copy Markdown
Member Author

haha .. long week need some sleep

@bdraco bdraco marked this pull request as ready for review May 18, 2026 22:30
@bdraco bdraco requested review from asvetlov and webknjaz as code owners May 18, 2026 22:30
@bdraco bdraco enabled auto-merge (squash) May 18, 2026 22:30
@bdraco bdraco merged commit 66cc7b6 into aio-libs:master May 18, 2026
47 checks passed
@bdraco

bdraco commented May 18, 2026

Copy link
Copy Markdown
Member Author

UV_PYTHON_PREFERENCE=only-managed

was the key to getting this working

@patchback

patchback Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

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

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.13/66cc7b68aad1ca084d210a466d4970de9619f10e/pr-12629 upstream/3.13
  4. Now, cherry-pick PR Install Python via astral-sh/setup-uv in test/autobahn jobs #12629 contents into that branch:
    $ git cherry-pick -x 66cc7b68aad1ca084d210a466d4970de9619f10e
    If it'll yell at you with something like fatal: Commit 66cc7b68aad1ca084d210a466d4970de9619f10e is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x 66cc7b68aad1ca084d210a466d4970de9619f10e
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Install Python via astral-sh/setup-uv in test/autobahn jobs #12629 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.13/66cc7b68aad1ca084d210a466d4970de9619f10e/pr-12629
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback

patchback Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Backport to 3.14: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.14/66cc7b68aad1ca084d210a466d4970de9619f10e/pr-12629

Backported as #12637

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@bdraco

bdraco commented May 18, 2026

Copy link
Copy Markdown
Member Author

thats another 12 runner minutes we get back in a lot of cases

@bdraco bdraco deleted the ci-setup-uv branch May 18, 2026 22:32
bdraco added a commit that referenced this pull request May 18, 2026
…p-uv in test/autobahn jobs (#12637)

Co-authored-by: J. Nick Koston <nick@koston.org>
@tarasko

tarasko commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants