Skip to content

WHL: build WebAssembly (Pyodide) wheels - #20171

Draft
nstarman wants to merge 2 commits into
astropy:mainfrom
nstarman:claude/pyodide-wheels
Draft

WHL: build WebAssembly (Pyodide) wheels#20171
nstarman wants to merge 2 commits into
astropy:mainfrom
nstarman:claude/pyodide-wheels

Conversation

@nstarman

@nstarman nstarman commented Jul 30, 2026

Copy link
Copy Markdown
Member

AI prompts:

Can you test locally, on nstarman/astropy, and then opening a PR to astropy to address #18898. Don't actually open the PRs without asking me first. Let me review the changes and the PR text.

Does OpenAstronomy/github-actions-workflows#404 make me opening a PR to OpenAstronomy unnecessary ?

Ok. Open a draft PR to astropy using OpenAstronomy/github-actions-workflows#404 and commenting that the Astropy PR requires that to land first.
Reference that this closes the #18898 issue.

Description

This pull request is to address building WebAssembly wheels, so that astropy can be
pip installed under Pyodide/PyScript rather than relying on the copy vendored in the
Pyodide distribution. PEP 776 and PEP 783 are accepted, and cibuildwheel builds
pyemscripten_*_wasm32 wheels out of the box — no enable flag needed — so this is just
one more entry in targets.

Fixes #18898

Blocked on OpenAstronomy/github-actions-workflows#404

The pinned reusable workflow sets CIBW_PLATFORM nowhere, and cibuildwheel infers the
platform from the runner OS — linux, not pyodide — so the job would select no builds
and fail. The workarounds don't work here: setting it through the env: input applies it
to every target and would break the native wheels, and a second call to the reusable
workflow doesn't help either because our upload job globs dist-* 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 absorbed
OpenAstronomy/github-actions-workflows#345). Once it lands, the pin on line 29 of
publish.yml needs 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_wasm32
alongside cp313, so the glob above produces two wheels. They carry different Emscripten
ABI years (pyemscripten_2025_0 and pyemscripten_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) and cp314-pyodide_wasm32
    (Pyodide 314.0.2 / Emscripten 5.0.3) both build in ~2 min. EXTENSION_HELPERS_PY_LIMITED_API=cp311
    applies to the wasm builds too, so each is a single abi3 wheel.
  • Runtime dependencies resolve from the Pyodide CDN (numpy, pyerfa, pyyaml);
    astropy-iers-data and packaging come from PyPI as pure-Python wheels.
  • Smoke test under node on both: SkyCoord(10*u.deg, 20*u.deg).galactic
    (119.26936774, -42.79039286), Time("2026-01-01").jd2461041.5, and
    astropy.stats._fast_sigma_clip imports, so the compiled extensions and pyerfa are
    live.
  • Out of curiosity, pytest --pyargs astropy.units under 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:

  • pyodide job: CIBW_PLATFORM: pyodide, skip_config: *-musllinux_x86_64 *-pyodide_wasm32,
    two wheels produced, no tests run.
  • cp313-manylinux_x86_64: CIBW_PLATFORM empty, i.e. behaviour unchanged. Full test suite
    green — 26957 passed, 3753 skipped, 84 deselected, 254 xfailed.

On not testing the wasm wheels

test-skip covers pyodide for now. The reusable workflow sets a single CIBW_TEST_COMMAND
for every target and cibuildwheel's environment variables win over per-platform
pyproject.toml overrides, so pyodide can't be given a lighter test command while the other
targets keep the full suite. astropy.units passing suggests wiring up a real test run is
feasible later, but chunks of the suite need threads, sockets and subprocesses that
WebAssembly doesn't have.

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>
@github-actions

Copy link
Copy Markdown
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.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@nstarman nstarman added this to the v8.1.0 milestone Jul 30, 2026
@pllim

pllim commented Jul 30, 2026

Copy link
Copy Markdown
Member

Do we need what's new?

@pllim
pllim requested a review from astrofrog July 30, 2026 19:03
@nstarman

Copy link
Copy Markdown
Member Author

Almost certainly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pyodide to CIBuildWheels (when available)

2 participants