WHL: build WebAssembly (Pyodide) wheels - #20171
Draft
nstarman wants to merge 2 commits into
Draft
Conversation
PEP 776/783 are accepted and cibuildwheel >=4.0 builds pyemscripten wheels without an enable flag, so this is one more cibuildwheel target. Tests are skipped for it: the reusable workflow sets a single CIBW_TEST_COMMAND for every target and cibuildwheel env vars win over per-platform pyproject.toml overrides, so pyodide cannot be given a lighter command. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Member
|
Do we need what's new? |
Member
Author
|
Almost certainly! |
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.
AI prompts:
Description
This pull request is to address building WebAssembly wheels, so that
astropycan bepip installed under Pyodide/PyScript rather than relying on the copy vendored in thePyodide distribution. PEP 776 and PEP 783 are accepted, and cibuildwheel builds
pyemscripten_*_wasm32wheels out of the box — noenableflag needed — so this is justone more entry in
targets.Fixes #18898
Blocked on OpenAstronomy/github-actions-workflows#404
The pinned reusable workflow sets
CIBW_PLATFORMnowhere, and cibuildwheel infers theplatform from the runner OS —
linux, notpyodide— so the job would select no buildsand fail. The workarounds don't work here: setting it through the
env:input applies itto every target and would break the native wheels, and a second call to the reusable
workflow doesn't help either because our
uploadjob globsdist-*across the whole run,so both calls would try to publish the same files.
OpenAstronomy/github-actions-workflows#404 adds per-target
CIBW_PLATFORM(it absorbedOpenAstronomy/github-actions-workflows#345). Once it lands, the pin on line 29 of
publish.ymlneeds bumping to a release containing it — until then this PR is a draft.That PR also moves cibuildwheel 4.0.0 → 4.1.1, which enables
cp314-pyodide_wasm32alongside
cp313, so the glob above produces two wheels. They carry different EmscriptenABI years (
pyemscripten_2025_0andpyemscripten_2026_0) and do not collide.Testing
Locally, with cibuildwheel 4.1.1 on macOS:
cp313-pyodide_wasm32(Pyodide 0.29.4 / Emscripten 4.0.9) andcp314-pyodide_wasm32(Pyodide 314.0.2 / Emscripten 5.0.3) both build in ~2 min.
EXTENSION_HELPERS_PY_LIMITED_API=cp311applies to the wasm builds too, so each is a single
abi3wheel.numpy,pyerfa,pyyaml);astropy-iers-dataandpackagingcome from PyPI as pure-Python wheels.SkyCoord(10*u.deg, 20*u.deg).galactic→(119.26936774, -42.79039286),Time("2026-01-01").jd→2461041.5, andastropy.stats._fast_sigma_clipimports, so the compiled extensions andpyerfaarelive.
pytest --pyargs astropy.unitsunder Pyodide: 3671 passed, 58 skipped,3 xfailed.
End-to-end on a fork against the head of OpenAstronomy/github-actions-workflows#404, with a
targets list of one native target plus the pyodide glob —
https://github.com/nstarman/astropy/actions/runs/30555396042:
CIBW_PLATFORM: pyodide,skip_config: *-musllinux_x86_64 *-pyodide_wasm32,two wheels produced, no tests run.
cp313-manylinux_x86_64:CIBW_PLATFORMempty, i.e. behaviour unchanged. Full test suitegreen — 26957 passed, 3753 skipped, 84 deselected, 254 xfailed.
On not testing the wasm wheels
test-skipcovers pyodide for now. The reusable workflow sets a singleCIBW_TEST_COMMANDfor every target and cibuildwheel's environment variables win over per-platform
pyproject.tomloverrides, so pyodide can't be given a lighter test command while the othertargets keep the full suite.
astropy.unitspassing suggests wiring up a real test run isfeasible later, but chunks of the suite need threads, sockets and subprocesses that
WebAssembly doesn't have.