Skip to content

Conversation

@juntyr
Copy link
Contributor

@juntyr juntyr commented Jan 22, 2026

This adds recipes and CI to check that numpy-quaddtype works in Pyodide.

Pyodide currently uses an old version of numpy, and building libsleef requires some Pyodide-specific patches (we could upstream them into meson in the future), so we cannot use the simpler https://github.com/numpy/numpy/blob/main/.github/workflows/emscripten.yml yet, so instead, this is my own home-cooked, more verbose one.

@juntyr
Copy link
Contributor Author

juntyr commented Jan 22, 2026

@SwayamInSync Maybe it would be even better to upstream the SLEEF patches for Pyodide? That way, the Pyodide recipe would be patch-free (something that Pyodide is working towards as it will transition from a centralised distribution towards package authors building Pyodide wheels themselves), and this repo could have full control over the patches

@SwayamInSync
Copy link
Member

upstream the SLEEF patches for Pyodide?

Means incorporate in quaddtype's build?

@juntyr
Copy link
Contributor Author

juntyr commented Jan 22, 2026

upstream the SLEEF patches for Pyodide?

Means incorporate in quaddtype's build?

Yes, exactly! I already copied over your patch (now in the 0003-... file), so something similar but so that the patches are only applied when building for Pyodide (if that's possible)?

@SwayamInSync
Copy link
Member

In principle it is possible, but will require good work, as similar dispatching mechanism as in #62 and modifying all the patches to include a conditional flag that turns those patches ON/OFF. Also I am not sure, but there might be an ordering to apply patches.

But these all can be figured out. Once get sometime to look through the details.

diff --git a/src/libm/dispavx.c.org b/src/libm/dispavx.c.org
index 86a0148..e309af7 100644
--- a/src/libm/dispavx.c.org
+++ b/src/libm/dispavx.c.org
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, I wonder 0003 patch and SLEEF's own autodetection should be enough to not dispatch these SIMD functions

Copy link
Member

Choose a reason for hiding this comment

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

Oh maybe its because of cross-compilation, autodetection might fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Auto detection doesn't exist at all in Emscripten (the instruction doesn't exist), so we need to fully patch them out, unfortunately

Copy link
Member

Choose a reason for hiding this comment

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

Autodetection is in SLEEF, it detects the properties by compiling code via the assigned compiler (very similar to what we do)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, we were talking about different detections then (compile time vs runtime). You can try it again without the patch - from what I remember, there was a link error with sleef's runtime detection, so some dispatch code must still be linked in

@SwayamInSync
Copy link
Member

Lets keep this, I'll see if I can update it post v1 release

@SwayamInSync SwayamInSync changed the title Add CI for Pyodide BUILD: Add Pyodide CI and build recipes Jan 22, 2026
@juntyr
Copy link
Contributor Author

juntyr commented Jan 22, 2026

Lets keep this, I'll see if I can update it post v1 release

That sounds like a good plan to me!

@juntyr
Copy link
Contributor Author

juntyr commented Jan 23, 2026

@SwayamInSync Do we need anything else for this PR?

@SwayamInSync
Copy link
Member

I think this is good, if anything is needed I'll take care of it later

Copy link

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

Thanks, @juntyr!

FYI, you can use https://github.com/pyodide/pyodide-build-environment-nightly/releases/tag/20260120 for the xbuildenv as it comes with numpy==2.2.6, which should avoid needing to add a recipe for NumPy, and hopefully using cibuildwheel will become a bit easier.

python-version: 3.13.2

- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v14

Choose a reason for hiding this comment

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

Suggested change
uses: mymindstorm/setup-emsdk@v14
uses: pyodide/setup-emsdk@v15

This action is not actively maintained and is waiting on mymindstorm/setup-emsdk#48. In the meantime, you can use our fork to save 2-3 minutes per run.

Comment on lines +56 to +57
- name: Install the Pyodide build env
run: pyodide xbuildenv install 0.29.2

Choose a reason for hiding this comment

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

Why not use the cibuildwheel action with platform: pyodide (cibuildwheel --platform pyodide if using the CLI)?

@juntyr
Copy link
Contributor Author

juntyr commented Jan 25, 2026

@agriyakhetarpal we need numpy >=2.4, which Pyodide doesn't support yet (I think it's blocked on the scipy upgrade)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants