sqlalchemy: add build-sqlalchemy.yml for riscv64 wheels - #310
Open
luhenry wants to merge 2 commits into
Open
Conversation
SQLAlchemy is pure-Python with *optional* Cython speedups (5 .pyx modules
under lib/sqlalchemy/cyextension/). PyPI ships the py3-none-any wheel plus a
per-interpreter compiled wheel for every arch except riscv64 - so the value
we add here is exactly those compiled riscv64 wheels.
Build shape (sdist -> bdist):
- build_sdist (ubuntu-latest): build the sdist ourselves from the upstream
rel_2_0_52 checkout. SQLAlchemy keeps `tag_build = dev` in setup.cfg on
release branches, so a plain `python -m build` yields sqlalchemy-2.0.52.dev0
and every wheel built from it inherits the .dev0 suffix. Upstream's release
job strips that line before building (the released PyPI sdist has it blank);
we do the same, or the wheel version stops matching PyPI and the docs
YAML / patches path. The sdist bundles the .pyx sources, the whole test/
tree, and upstream's [tool.cibuildwheel] config.
- build_wheels (ubuntu-24.04-riscv): one cibuildwheel run per interpreter
(cp312/cp313/cp314/cp314t - the cyextension is a plain per-interpreter C
extension, not abi3). cibuildwheel consumes the sdist tarball directly, so
{project} in the inherited test-command resolves to the extracted tree that
bundles both pyproject.toml and test/. We inherit upstream's exact
test-requires + test-command and add only the riscv overrides.
Two package-specific subtleties, both phase-scoped env vars:
- REQUIRE_SQLALCHEMY_CEXT=1 (build phase): the extensions are declared
optional=not REQUIRE_SQLALCHEMY_CEXT, so a Cython/compile failure would be
swallowed and setuptools would ship a *pure-Python* wheel still tagged
manylinux_riscv64 - a broken artifact that looks fine. REQUIRE turns any
extension-build failure into a hard failure.
- PYTHONNOUSERSITE=1 (test phase only): upstream's test-command uses
`python -s` so test/conftest.py doesn't inject {project}/lib ahead of the
installed wheel (which would import the pure-Python source, not the compiled
extension). But the -s *flag* does not propagate to pytest-xdist (-n4)
workers - they respawn with no_user_site=0 and import the source tree anyway,
and SQLAlchemy's own __ensure_cext plugin (active under REQUIRE) then
hard-fails every worker. Setting no-user-site as the PYTHONNOUSERSITE env
var, which xdist inherits into workers, makes each worker test the installed
compiled wheel.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Per repo guidance (PR #308 review): workflows are read as reference, so reserve comments for the non-obvious and cut per-step narration. The full rationale lives in the commit message and CLAUDE.md gotchas 20-22. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
threexc
approved these changes
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
.github/workflows/build-sqlalchemy.ymlto build riscv64 wheels for SQLAlchemy 2.0.52 and publish them topypi.riseproject.dev.SQLAlchemy is pure-Python with optional Cython speedups (5
.pyxmodules underlib/sqlalchemy/cyextension/). PyPI already ships thepy3-none-anywheel plus a per-interpreter compiled wheel for every arch except riscv64 — so the value we add is exactly those compiled riscv64 wheels.How
Build shape: sdist → bdist, modelled on upstream's
create-wheels.yaml.build_sdist(ubuntu-latest): builds the sdist from the upstreamrel_2_0_52checkout. The sdist bundles the.pyxsources, the wholetest/tree, and upstream's[tool.cibuildwheel]config — so we inherit upstream's exacttest-requires+test-command(the "easy inverse" of CLAUDE.md gotcha 6).build_wheels(ubuntu-24.04-riscv): one cibuildwheel run per interpreter over the matrix[cp312, cp313, cp314, cp314t]. The cyextension is a plain per-interpreter C extension (not abi3), so each CPython needs its own wheel — same matrix as cffi/numpy/zstandard. cibuildwheel consumes the sdist tarball directly.publish: sharedpublish-wheelsaction (dry-runs offmain).Two package-specific subtleties (both phase-scoped env vars)
.dev0version trap — SQLAlchemy keepstag_build = devinsetup.cfgon release branches, so a plainpython -m buildyieldssqlalchemy-2.0.52.dev0. Upstream strips that line before building (the released PyPI sdist has it blank); we do the same viased -i '/tag_build = dev/d' setup.cfg, or the wheel version stops matching PyPI and the docs YAML / patches path (gotcha 18).REQUIRE_SQLALCHEMY_CEXT=1(build) +PYTHONNOUSERSITE=1(test) — the extensions areoptional=not REQUIRE_SQLALCHEMY_CEXT, so a Cython failure would silently ship a pure-Python wheel mislabeledmanylinux_riscv64;REQUIREmakes that a hard failure. Separately, upstream'spython -s(no-user-site) keepstest/conftest.pyfrom injecting the source tree ahead of the installed wheel — but the-sflag doesn't propagate to pytest-xdist (-n4) workers, which respawn withno_user_site=0and import the source tree anyway (crashing underREQUIREvia SQLAlchemy's__ensure_cextplugin). Setting no-user-site as thePYTHONNOUSERSITEenv var — which xdist inherits into workers — makes each worker test the installed compiled wheel. Test-phase-scoped so it can't affect the build (gotcha 12).Validation
actionlintclean (only the expectedubuntu-24.04-riscvunknown-label warning)..socyextension modules present, clean2.0.52version, tagcp312-cp312-manylinux_2_39_riscv64.CI on the native riscv64 runner is the final gate for all four interpreters.