Skip to content

Upgrade M2Crypto to 0.45.1 to build on Ubuntu 26.04 - #423

Merged
rtibbles merged 1 commit into
learningequality:release-v0.9.xfrom
bjester:fix-ubuntu-26-issues
Nov 12, 2026
Merged

rtibbles merged 1 commit into
learningequality:release-v0.9.xfrom
bjester:fix-ubuntu-26-issues

Conversation

@bjester

@bjester bjester commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Upgrades M2Crypto from 0.41.0 to 0.45.1 in the postgres and accelerated extras. With 0.41.0, M2Crypto doesn't build on Ubuntu 26.04, which GitHub now uses for ubuntu-latest. That breaks the "Python postgres unit tests" job (for example, on #421), and it breaks pip install morango[postgres] for users on 26.04.

M2Crypto has no Linux wheels, so it always builds from source with the system SWIG and glibc headers. The 26.04 runner has SWIG 4.4 and GCC 15. The 24.04 runner had SWIG 4.2 and GCC 13. During the build, SWIG can't evaluate some #if expressions in the newer glibc features.h. It then reads the wrong branch of fd_set in sys/select.h, and the generated wrapper doesn't compile:

src/SWIG/_m2crypto_wrap.c:12198:88: error: 'fd_set' has no member named '__fds_bits'; did you mean 'fds_bits'?

M2Crypto 0.45.0 added a workaround for this ("swig: Workaround for reading sys/select.h ending with wrong types"). The workaround gives SWIG an empty sys/types.h, so SWIG never parses fd_set. The 0.45.0 sdist left out that file, and 0.45.1 is the first sdist that includes it. I picked 0.45.1 because it's the smallest upgrade with the fix. Morango only uses M2Crypto.BIO and M2Crypto.RSA. 0.45.0 removed Engine support, which morango doesn't use. 0.45.1 still lists Python 3.6 to 3.12.

Pinning the postgres job to ubuntu-24.04 would also make CI pass, but users on 26.04 still couldn't install the extras.

TODO

  • Have tests been written for the new code?
    • N/A. No morango code changes. tests/testapp/tests/test_crypto.py already tests M2CryptoKey whenever M2Crypto is installed.
  • Has documentation been written/updated?
    • Added a line to the 0.9.0 notes in CHANGELOG.md.
  • New dependencies (if any) added to requirements file
    • No new dependencies. The M2Crypto pin changed in pyproject.toml, and I regenerated uv.lock.

Reviewer guidance

  • Not yet verified: When this description was written, CI hadn't run on this PR. The fix is confirmed only when "Python postgres unit tests" passes on ubuntu-26.04. That job also runs the M2Crypto tests in test_crypto.py against 0.45.1.
  • Lock file: I regenerated uv.lock with uv 0.13.7, the version that CI installs. An older uv (0.11.15) lowered the lock revision from 5 to 3 and rewrote markers across about 500 lines. With 0.13.7, the lock diff contains only the m2crypto entry.

Issues addressed

No tracking issue. This fixes the "Python postgres unit tests" failure on #421. #419 passed because it ran on ubuntu-24.04.

Documentation

N/A. The only documentation change is the CHANGELOG.md entry.

AI usage

I asked Claude Code to investigate the CI failure on #421. It read the job logs and compared the runner images and toolchains between #419 and #421. It then downloaded the M2Crypto 0.41.0, 0.45.1, and 0.51.0 sdists to find the upstream fix and the first release that includes it. Claude Code also made the change and regenerated uv.lock with the uv version that CI uses, after an older local uv produced a noisy lock diff. It drafted this description. It couldn't build M2Crypto in its sandbox, so CI on this PR is the verification step.

🤖 Generated with Claude Code

M2Crypto ships no Linux wheels, so the postgres and accelerated extras
build it from source with the system SWIG and glibc headers. On the
ubuntu-26.04 runner (SWIG 4.4, GCC 15), SWIG cannot evaluate the newer
feature-test expressions in glibc's features.h. It then picks the wrong
fd_set member name from sys/select.h, and the generated wrapper fails
to compile ("'fd_set' has no member named '__fds_bits'").

M2Crypto 0.45.0 added a workaround that shadows sys/types.h for SWIG,
and 0.45.1 is the first sdist that includes the shadow directory.
Morango only uses M2Crypto's BIO and RSA modules, which this upgrade
does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bjester
bjester marked this pull request as ready for review November 12, 2026 00:03
@bjester
bjester requested review from a team and leq-bot November 12, 2026 00:03

@bjesterbot bjesterbot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrading M2Crypto to 0.45.1 in the postgres and accelerated extras cleanly resolves the Ubuntu 26.04 SWIG 4.4 and glibc fd_set build failure without altering M2CryptoKey behavior. Diffing the 0.41.0 and 0.45.1 sdists confirms that M2Crypto.BIO and M2Crypto.RSA preserve all signatures and semantics used in morango/models/fields/crypto.py, and CI confirms that "Python postgres unit tests" builds and passes on ubuntu-latest.

  • Inline Comments: 1 ❓ Question
  • ✅ Positive Highlight: Pinning 0.45.1 hits the exact compatibility window for Morango's >=3.6,<3.15 floor. It is the first sdist that packages system_shadowing/sys/types.h for SWIG 4.4, and the last release before 0.46.0 through 0.51.0 dropped Python 3.7 and 3.8 from [build-system].requires in pyproject.toml. Regenerating uv.lock with uv 0.13.7 also keeps the lockfile diff isolated to m2crypto.

Verification Status

  • Crypto unit suite: Passing (PYTHONPATH=.:./tests/testapp .venv/bin/python -O -m pytest tests/testapp/tests/test_crypto.py -v, 39 passed, 0 skipped against M2Crypto 0.45.1)
  • Lint and lockfile verification: Clean (.venv/bin/prek run --all-files --show-diff-on-failure, including ruff, ruff-format, uv-lock, yamlfmt, and actionlint)
  • GitHub Actions CI: "Python postgres unit tests", "All file linting", "SQLite migration tests", "Python unit tests on Windows Server (3.8)", and all "Python unit tests + cryptography" jobs (3.6 through 3.14) passed (4 pure-Python SQLite matrix jobs still running at review time)

Generated by Antigravity using model Gemini 4 Carbon (Medium)

Comment thread pyproject.toml Resolved
@rtibbles
rtibbles merged commit 3b6d9d3 into learningequality:release-v0.9.x Nov 12, 2026
87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants