Skip to content

Pyodide support#275

Merged
khaledhosny merged 4 commits intomainfrom
pyodide
Mar 17, 2026
Merged

Pyodide support#275
khaledhosny merged 4 commits intomainfrom
pyodide

Conversation

@anthrotype
Copy link
Member

@anthrotype anthrotype commented Jan 2, 2026

Fixes #270

- Detect Emscripten cross-compilation in setup.py, skipping
  platform-specific sources (CoreText, DirectWrite, Uniscribe)
- Add build-pyodide job to CI workflow
- Upload Pyodide wheel to GitHub releases only (PyPI doesn't
  accept wasm32 wheels yet, see pypi/warehouse#10416)

Fixes #270
@anthrotype anthrotype changed the title Pyodide Pyodide support Jan 2, 2026
define_macros.append(("HAVE_DIRECTWRITE", "1"))
define_macros.append(("HAVE_UNISCRIBE", "1"))
libraries += ["usp10", "gdi32", "user32", "rpcrt4", "dwrite"]
sources += [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think harfbuzz.cc has all these files automatically included.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but harfbuzz.cc lacks the subset module..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. That's annoying.

@anthrotype anthrotype mentioned this pull request Jan 2, 2026
Pyodide doesn't support Python 3.14 yet, so we need to use 3.13
explicitly instead of '3.x' which resolves to the latest.
Remove redundant test step - cibuildwheel already runs tests via
test-command for each wheel it builds.
@anthrotype
Copy link
Member Author

anthrotype commented Jan 5, 2026

@Vipitis the CI finally built some pyodide wheels for uharfbuzz here: https://github.com/harfbuzz/uharfbuzz/actions/runs/20712353445/artifacts/5023130791

Would you like to give them a go? The uharfuzz own tests do pass when run inside a pyodide venv, like cibuildwheel does.

@Vipitis
Copy link

Vipitis commented Jan 5, 2026

hey @anthrotype thanks a lot for figuring this out.

I obtained the wheel yesterday already from your branch and now also from the ci artifacts. The latter has the wrong version number (0.1) which could be a problem for others.
Both wheels work, but I can't test much functionality at the moment since I found additional hurdles apart from uharfbuzz that I will need to look into before our examples run in the browser.

@anthrotype
Copy link
Member Author

thanks for checking. the version number is expected, only when we push a tagged commit to do an actual release we do a full clone and "unshallow" the repository so the correnct version string is obtained from git. The 0.1 is setuptools-scm failing to get a proper tag.

@khaledhosny
Copy link
Collaborator

Is there anything blocking this?

@anthrotype
Copy link
Member Author

I was waiting for them to test if these actually work.. the tests pass, so feel free to merge

@khaledhosny khaledhosny merged commit 9c2d0f7 into main Mar 17, 2026
7 checks passed
@khaledhosny khaledhosny deleted the pyodide branch March 17, 2026 13:33
@khaledhosny
Copy link
Collaborator

khaledhosny commented Mar 19, 2026

Uploading the Pyodide wheels seems to fail: https://github.com/harfbuzz/uharfbuzz/actions/runs/23300214344/job/67760947291

Run if [ -d dist-pyodide ] && [ "$(ls -A dist-pyodide)" ]; then
  if [ -d dist-pyodide ] && [ "$(ls -A dist-pyodide)" ]; then
    gh release upload refs/tags/v0.53.4 dist-pyodide/*.whl
  fi
  shell: /usr/bin/bash -e {0}
  env:
    GH_TOKEN: ***
    pythonLocation: /opt/hostedtoolcache/Python/3.14.3/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.14.3/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.14.3/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.14.3/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.14.3/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.14.3/x64/lib
    RELEASE_NAME: 0.53.4
    IS_PRERELEASE: false
release not found

@anthrotype
Copy link
Member Author

You can't upload to PyPI yet I think, they aren't sufficiently standardised IIRC. I am at a conference right now and can't check, but I believe the path forward for now would be to disable the automatic upload for those and perhaps make them available only as GitHub Release downloadable assets

@anthrotype
Copy link
Member Author

Oh now I remember I had written about that (see above here)

Upload Pyodide wheel to GitHub releases only (PyPI doesn't accept wasm32 wheels yet, see Add support for wasm32 platform pypi/warehouse#10416 and https://discuss.python.org/t/pep-783-emscripten-packaging)

@anthrotype
Copy link
Member Author

Oh! It's the GH assets upload that it's failing (not PyPI), sorry I hadn't read it carefully. Ok not sure. Next thing to check, is the GitHub token used enabled for "write"?

- name: Upload Pyodide wheel to GitHub release
run: |
if [ -d dist-pyodide ] && [ "$(ls -A dist-pyodide)" ]; then
gh release upload ${{ github.ref }} dist-pyodide/*.whl
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khaledhosny i think the issue is this is supposed to be github.ref_name ("v0.53.4") instead of github.ref ("refs/tags/v0.53.4").
And for consistency also the gh release create call right above this (which somehow normalises ref to ref_name internally, whereas upload command doesn't).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we'll have to re-tag, the release that was created will have to be deleted as well

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.

Pyodide compatibility?

4 participants