Skip to content

Add a reference Dockerfile for building aiohttp from a git clone - #13347

Closed
ri1wik wants to merge 2 commits into
aio-libs:masterfrom
ri1wik:docker-build-fix-11290
Closed

Add a reference Dockerfile for building aiohttp from a git clone#13347
ri1wik wants to merge 2 commits into
aio-libs:masterfrom
ri1wik:docker-build-fix-11290

Conversation

@ri1wik

@ri1wik ri1wik commented Aug 7, 2026

Copy link
Copy Markdown

Name: Ritwik Ritu Parn
Email:

What it adds

  • fixed.Dockerfile — builds the repo from a clone with the C extensions enabled, and runs a smoke test that asserts the accelerated build actually loaded.
  • original-reconstructed.Dockerfile — the same build with the steps in the wrong order, kept as executable documentation of the failure mode.
  • .dockerignore — notably does not exclude .git, for reasons below.

Why it might be worth having

Building from a clone inside a container has three ordering constraints that aren't obvious from CONTRIBUTING.rst, and each one fails with an error that points somewhere unhelpful:

  1. Submodules before install. pip install -e . before git submodule update --init gives exit code: 2 / Install submodules when building from git clone from the guard at setup.py:24-31. Clear enough, but easy to get the ordering wrong in a Dockerfile where each RUN looks independent.

  2. Cython codegen before compile. setup.py lists aiohttp/_websocket/mask.c, _http_parser.c, _http_writer.c and _websocket/reader_c.c as Extension sources, but only the .pyx originals are tracked — the note at setup.py:34 says the makefile handles it. Miss make cythonize and you get cc1: fatal error: aiohttp/_websocket/mask.c: No such file or directory, which reads like a missing compiler dep rather than a missing build step.

  3. llhttp needs Node. vendor/llhttp/build/c/llhttp.c comes from npm ci && make generate in the submodule. Here that runs in a node:20 builder stage so npm never reaches the final image.

The .dockerignore keeps .git deliberately: setup.py branches on IS_GIT_REPO = (HERE / ".git").exists(), so dropping it silently disables the submodule guard and the build fails later and less legibly, inside gcc.

Installing requirements/test.txt rather than hand-listing packages also avoids rediscovering isal, zlib_ng, blockbuster, freezegun and pytest-mock one import error at a time.

Verified

$ docker run --rm assessment-fix
aiohttp version: 4.0.0a2.dev0
build          : c_extensions=yes mask=mask.cpython-311-aarch64-linux-gnu.so parser=aiohttp._http_parser
round-trip     : HTTP 200 {'pong': 'hello'}
SMOKE TEST PASSED
tests/test_payload.py             63 passed
tests/test_client_functional.py  278 passed, 1 skipped, 1 xfailed

parser=aiohttp._http_parser is the part that matters — that's the compiled parser, not the pure-Python fallback you get from AIOHTTP_NO_EXTENSIONS=1.

Built and tested on arm64 against 9b0153c. No changelog entry since nothing user-facing changes; happy to add one, adjust the layout, or drop original-reconstructed.Dockerfile if only the working one is of interest.

ri1wik added 2 commits August 7, 2026 20:39
The dockerization run for aio-libs#11290 died inside `pip install -e .` with
"Install submodules when building from git clone". setup.py exits 2 when
vendor/llhttp/README.md is missing, and the build ordered
`git submodule update --init --recursive` after the install that needs it,
so it never ran.

Reordering on its own isn't enough. setup.py lists the Cython-generated .c
files as Extension sources while the repo only ships the .pyx originals
("NOTE: makefile cythonizes all Cython modules"), so the next thing you hit
is gcc failing on a missing aiohttp/_websocket/mask.c. fixed.Dockerfile
generates the llhttp sources in a throwaway Node stage, runs
`make cythonize-nodeps`, and installs requirements/test.txt rather than
hand-listing packages - the lockfile already has isal, zlib_ng, blockbuster,
freezegun and pytest-mock, which the original run rediscovered one failed
attempt at a time.

original-reconstructed.Dockerfile is kept alongside it: it reproduces the
original error verbatim, so the before/after can be diffed.

Verified on the aio-libs#11290 tree - image builds, C extensions load, and
tests/test_payload.py plus tests/test_client_functional.py pass
(63 and 278 passed, 0 failures).
Says three changes, there are four. Also notes which of them are actually
about the recorded failure and which are not.
@ri1wik
ri1wik requested a review from asvetlov as a code owner August 7, 2026 15:19
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.88%. Comparing base (d9aaf69) to head (5cc9743).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13347      +/-   ##
==========================================
- Coverage   98.98%   98.88%   -0.11%     
==========================================
  Files         132      130       -2     
  Lines       49073    49029      -44     
  Branches     2553     2543      -10     
==========================================
- Hits        48576    48483      -93     
- Misses        373      421      +48     
- Partials      124      125       +1     
Flag Coverage Δ
Autobahn ?
CI-GHA 98.90% <ø> (+<0.01%) ⬆️
OS-Linux 98.67% <ø> (+<0.01%) ⬆️
OS-Windows 97.03% <ø> (ø)
OS-macOS 97.92% <ø> (-0.01%) ⬇️
Py-3.10 98.12% <ø> (ø)
Py-3.11 98.37% <ø> (+<0.01%) ⬆️
Py-3.12 98.46% <ø> (ø)
Py-3.13 98.45% <ø> (+<0.01%) ⬆️
Py-3.14 98.46% <ø> (+<0.01%) ⬆️
Py-3.14t 97.55% <ø> (ø)
Py-pypy-3.11 97.39% <ø> (-0.01%) ⬇️
VM-macos 97.92% <ø> (-0.01%) ⬇️
VM-ubuntu 98.67% <ø> (+<0.01%) ⬆️
VM-windows 97.03% <ø> (ø)
cython-coverage 37.96% <ø> (ø)

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

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

@webknjaz

webknjaz commented Aug 7, 2026

Copy link
Copy Markdown
Member

Duplicate of #13331

@webknjaz webknjaz marked this as a duplicate of #13331 Aug 7, 2026
@webknjaz webknjaz closed this Aug 7, 2026
@aio-libs aio-libs locked as spam and limited conversation to collaborators Aug 7, 2026
@webknjaz webknjaz moved this to 🤦‍♂️ LLM/“AI” slop 🤖 in 📅 Procrastinating in public 😵‍💫 Aug 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants