Skip to content

greenify: Add version 0.5.0 - #3056

Draft
luhenry wants to merge 3 commits into
mainfrom
greenify
Draft

luhenry wants to merge 3 commits into
mainfrom
greenify

Conversation

@luhenry

@luhenry luhenry commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Compiles a small Cython/C extension that ELF-hooks a target .so's PLT/GOT entries to make its blocking syscalls gevent-cooperative. Upstream publishes no riscv64 wheel.

Mirrors upstream's publish.yml: one cp39-abi3 wheel via bdist_wheel --py-limited-api=cp39.

Differs from upstream

  • Patched elf_hook.c's 64-bit detection - it only matched __x86_64, so riscv64 (and every other non-x86_64 64-bit arch) read 64-bit ELF headers as 32-bit.
  • Dropped the test suite's public-site HTTP checks - no outbound internet access to third-party hosts from this runner.
  • CIBW_BEFORE_BUILD also installs setuptools, not just Cython - the first CI run failed with BackendUnavailable: Cannot import 'setuptools.build_meta', because --no-build-isolation means pip never fetches a build backend into an isolated env, and this image's interpreters don't ship setuptools pre-installed.

Matrix: cp312/cp313/cp314 only, no cp314t - upstream never builds or tests a free-threaded interpreter either.

Testing

  • upstream's own misc/test.sh (minus the public-site HEAD checks above): patches a real blocking C extension and asserts gevent cooperative concurrency.

License: OK, BSD-3-Clause.

Patches

  • 0001-elf_hook-detect-64-bit-ELF-by-__LP64__-not-just-__x8.patch - To upstream [not yet submitted]. Without it, greenify.patch_lib() silently fails on riscv64 (and would on aarch64 too - upstream ships no wheel for any arch but x86_64).
  • 0002-tests-http_head-drop-the-public-site-HEAD-checks.patch - Inappropriate [no general internet egress on this runner]. Test-infra only; reproduces off riscv64 too.

Built and tested locally on x86_64 (cp311/cp312) with both patches applied; riscv64 build left to CI per the disk-space note.

Upstream (douban/greenify) is actively maintained, not abandoned:
latest tag v0.5.0 (Dec 2025), tested across cp39-cp314 in its own
CI, no CPython-internal struct access anywhere in its C sources.

greenify's only architecture-specific code is elf_hook.c's choice of
Elf32 vs Elf64 struct types, keyed off __x86_64 alone, so every other
64-bit target (including riscv64) silently misreads 64-bit ELF
headers as 32-bit. Patch 0001 fixes that by also matching __LP64__.
Patch 0002 trims the test suite's public-site HTTP checks, which need
outbound internet access this runner isn't provisioned for; the
local-server case alone already exercises the patched code path.

The wheel builds exactly as upstream's own CI does it: a single
cp39-abi3 wheel via `bdist_wheel --py-limited-api=cp39`, reused across
cp312/cp313/cp314. No cp314t: upstream never builds or tests a
free-threaded interpreter either.
luhenry added a commit that referenced this pull request Oct 13, 2026
--no-build-isolation means pip never fetches a build backend into an
isolated env, so setuptools.build_meta must already be importable;
this image's interpreters don't ship setuptools pre-installed.
@luhenry
luhenry marked this pull request as draft October 14, 2026 11:34
misc/test.sh does a relative `cd tests/http_head`, assuming the cwd is
already the project root. cibuildwheel runs CIBW_TEST_COMMAND from a
fresh temporary directory instead of {project}, so the test step failed
with "cd: tests/http_head: No such file or directory" before even
starting the fake HTTP server. Moving the cd into CIBW_TEST_COMMAND
itself (same pattern already used by build-sqlglotc.yml/build-leidenalg.yml/
build-symusic.yml/etc.) fixes it without touching the upstream script.

This branch has not been deployed

No deployments
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.

1 participant