Skip to content

pact-python-ffi: add build-pact-python-ffi.yml for riscv64 wheels - #1683

Merged
luhenry merged 1 commit into
mainfrom
pact-python-ffi
Sep 10, 2026
Merged

pact-python-ffi: add build-pact-python-ffi.yml for riscv64 wheels#1683
luhenry merged 1 commit into
mainfrom
pact-python-ffi

Conversation

@luhenry

@luhenry luhenry commented Sep 10, 2026

Copy link
Copy Markdown
Member

Compiles the pact_ffi CFFI extension bound to libpact_ffi, the Rust core shared library published by pact-foundation/pact-reference. Upstream publishes no riscv64 wheel.

Mirrors upstream's release-ffi.yml.

Differs from upstream

  • Builds libpact_ffi from pact-reference source instead of downloading it - pact-reference ships no riscv64 release asset.
  • Drops musllinux - rustup.rs ships no riscv64 musl toolchain.

Matrix: cp312-abi3 only, matching upstream's own single-interpreter release job; abi3 covers cp313/cp314, and upstream ships no free-threaded wheel for this package.

Testing

  • same as upstream

License: OK

Patches

  • 0001-recognize-riscv64-in-the-hatch-build-hook.patch - To upstream [blocked: pact-reference has no riscv64 libpact_ffi release yet]. Without it, _lib_url raises UnsupportedPlatformError on every architecture once packaging>=26.3 reorders sys_tags(), and has no riscv64 case regardless. Reproduces on any architecture.

luhenry added a commit that referenced this pull request Sep 10, 2026
@luhenry
luhenry force-pushed the pact-python-ffi branch 2 times, most recently from 5b470a9 to 5966860 Compare September 10, 2026 08:03
hatch_build.py's build hook downloads a prebuilt libpact_ffi from
pact-foundation/pact-reference's GitHub releases and compiles a CFFI
extension against it. pact-reference publishes no riscv64 asset, so
CIBW_BEFORE_ALL_LINUX builds libpact_ffi from the pact-reference source at
the matching libpact_ffi-v tag and stages it at the path the build hook
already caches downloads to. A small patch teaches the hook's platform
detection to recognize riscv64.

Builds only cp312-abi3 (our registry's floor), matching upstream's own
release job which builds a single interpreter and relies on the abi3 tag
for forward compatibility; cp313/cp314 reuse that wheel via cibuildwheel's
find_compatible_wheel. musllinux is dropped: rustup.rs ships no riscv64
musl toolchain.

The first attempt at the platform-detection patch only widened the
`manylinux`-prefixed branch of `_lib_url`, which turned out to be
unreachable: `packaging` 26.3 (an unpinned build dependency, resolved
fresh in the isolated build env) reordered `sys_tags()` to yield the
generic `linux_<arch>` tag before any `manylinux_*`/`musllinux_*` tag,
so `_sys_tag_platform()` returns `linux_riscv64` and none of
`_lib_url`'s `startswith("manylinux")` branches ever match - confirmed
from CI job 102765101921's log (Rust build finishes in 39m24s, then
`python -m build` still raises `UnsupportedPlatformError: Unsupported
platform linux_riscv64`) and from packaging's own 26.3 changelog/source
(`_linux_platforms` in tags.py yields `linux_{arch}` before
`_manylinux.platform_tags(archs)`). The patch now also accepts the
generic `linux` prefix in that branch.

The CIBW_TEST_COMMAND smoke-check also needed a fix: `pact_ffi/__init__.py`
does `from pact_ffi.ffi import ffi, lib`, which - because the submodule and
the symbol it imports are both named `ffi` - shadows the `pact_ffi.ffi`
package attribute with the imported `ffi` object (a cffi.FFI instance with
no `__file__`) once `pact_ffi` finishes initializing. `import pact_ffi.ffi
as m` therefore binds `m` to that FFI instance, not the compiled extension
module, so `m.__file__` raised AttributeError (job 102778776915, run
34448554573). Go through `sys.modules['pact_ffi.ffi']` instead, which holds
the actual compiled module regardless of the attribute shadowing.

That fix then surfaced a second, independent test-step failure: upstream's
own pyproject.toml unconditionally enables coverage in pytest's addopts
(--cov-config, --cov-report, --cov=pact_ffi), which needs the pytest-cov
plugin - not installed by CIBW_TEST_REQUIRES: pytest alone (job
102793239322, run 34453121784). Add pytest-cov to CIBW_TEST_REQUIRES.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Az13NcXsVZzzxXmaxxUEy7
luhenry added a commit that referenced this pull request Sep 10, 2026
@luhenry
luhenry merged commit e7545ff into main Sep 10, 2026
7 checks passed
@luhenry
luhenry deleted the pact-python-ffi branch September 10, 2026 10:44
@luhenry luhenry linked an issue Sep 10, 2026 that may be closed by this pull request
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.

pact-python-ffi riscv64 support

1 participant