-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: CI: switch Emscripten job to Meson #24603
Conversation
[skip ci]
endian = 'little' | ||
|
||
[properties] | ||
longdouble_format = 'IEEE_QUAD_LE' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only addition compared to the upstream emscripten.meson.cross
file in Pyodide - necessary for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this file can be removed, only this is needed:
[properties]
longdouble_format = 'IEEE_QUAD_LE'
I decided that it's easier to finish this only after upgrading the build of numpy that Pyodide does in-tree to Meson and 1.26.x first. I've made a start on that, but I need to do some more digging. There was also a Next steps I plan to take (not necessarily in this order):
|
Thanks for working on this @rgommers ! I don't have useful suggestions about the errors you are facing but I agree it would probably be easier to do this in the in-tree build first. Also cc @lesteve who worked on the scikit-image meson build.
I think overall we could be happy to accept any changes needed to make numpy with meson work. But since |
That should be fine for |
Currently |
Thank you @ryanking13, that's exactly what I needed. |
Initial inspiration was taken from numpy/numpy#24603.
Moving it to Meson is going to take a bit of time, and in the meantime we have to disable it, because it's the only job that still needs the `setup.py` based build and we'd like to remove support for building with `setup.py`.
@ryanking13 Do you know what the status of this is? It would be good if we could look into this again. I would look into it myself but so far I don't know much about meson... |
I've been meaning to get back to this PR. I believe with @ryanking13's changes for improved Meson/meson-python support in Pyodide, this should be unblocked. Timing wise I realistically won't revisit it before the NumPy 2.0 release settles down though (any week now ...). |
Yes, now that we're building numpy with meson in-tree, I don't think it's going to be hard to make it work in out-of-tree too. We've recently added a patch for python-meson >= 0.15 so I think we need to release pyodide-build (0.25.1).
Maybe emscripten CI should also wait for numpy 2.0 to be released? I've seen Pyodide builds break in many cases when packages do major releases, so it might be better to wait and see if the numpy 2.0 build works in-tree before applying it. |
That seems reasonable to me. EDIT: no real reason not to do it now though, it's just not a priority compared to 2.0-critical tasks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comments to this file about what is still relevant. @agriyakhetarpal is going to have a fresh attempt at a new/updated CI job.
@@ -52,14 +52,23 @@ jobs: | |||
actions-cache-folder: emsdk-cache | |||
|
|||
- name: Install pyodide-build | |||
run: pip install "pydantic<2" pyodide-build==$PYODIDE_VERSION | |||
run: pip install "pydantic<2" build pyodide-build==$PYODIDE_VERSION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build
isn't needed anymore, I think pyodide-build
will do fine.
cp pyproject.toml.setuppy pyproject.toml | ||
CFLAGS=-g2 LDFLAGS=-g2 pyodide build | ||
# Note that we need to cross-compile here. Using `pyodide build` | ||
# fails on not having a cross file. The `source() function in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer true, the cross file is shipped by pyodide now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: still true actually, the cross file won't get applied as long as we have vendored-meson
.
We also need the fix from pyodide/pyodide#4502 to actually pick up vendored-meson
. With that, an out of tree build should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am on it – I shall be adding a patch file to port the above PR into vendored-meson
, as discussed on Slack.
# tl;dr this needs some work, and it seems like cross-compilation is | ||
# hard because Pyodide doesn't ship its own Python interpreter that | ||
# we can actually target during a direct cross build. | ||
python -m build --wheel -Csetup-args=--cross-file=$PWD/tools/ci/emscripten.meson.cross -Csetup-args=-Dallow-noblas=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -Dallow-noblas=true
is no longer needed, the fallback to internal code when BLAS is missing is automatic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -Csetup-args=--cross-file=$PWD/tools/ci/emscripten.meson.cross
will still be needed I think, only to add the longdouble format, just in slightly different format. From this comment I think it should be:
pyodide build setup-args="--cross-file=$PWD/tools/ci/emscripten.meson.cross"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pyodide bundles emscripten.meson.cross used in in-tree build, so probably you can try that one too.
PYODIDE_MESON_CROSS_FILE=`pyodide config get meson_cross_file`
pyodide build -C "setup-args=\"${PYODIDE_MESON_CROSS_FILE}\""
@@ -77,4 +86,4 @@ jobs: | |||
run: | | |||
source .venv-pyodide/bin/activate | |||
cd .. | |||
python numpy/runtests.py -n -vv | |||
pytest --pyargs numpy -m "not slow" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is still needed.
@@ -106,6 +107,7 @@ max_features_dict = { | |||
's390x': S390X_FEATURES, | |||
'arm': ARM_FEATURES, | |||
'aarch64': ARM_FEATURES, | |||
'wasm32': {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the changes in this file will still be needed.
endian = 'little' | ||
|
||
[properties] | ||
longdouble_format = 'IEEE_QUAD_LE' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this file can be removed, only this is needed:
[properties]
longdouble_format = 'IEEE_QUAD_LE'
Copied with updates and suggestions received from numpy#24603 on 23/02/2024.
Copied with updates and suggestions received from numpy#24603 on 23/02/2024.
This commit performs the following actions: 1. Adds WASM builds to the CPU family for Meson configurations, but without SSE or SIMD instructions. 2. Removes CPU feature detection message for an unsupported architecture. 3. Enables `IEEE_QUAD_LE` longdouble format for the wasm32 target (cross-builds). 4. Enables run for Emscripten/Pyodide wheels by setting the `if:` condition to `true`. 5. Uses recursive submodules to ensure that vendored-meson is received. 6. Moves the Meson cross file to `tools/ci/emscripten/` (i.e., creates a separate Emscripten folder to store relevant files) 7. Adds a patch for vendored-meson detection for Pyodide and applies this Pyodide-meson patch in the Emscripten CI jobs 8. Builds wasm32 wheels without BLAS and LAPACK support (see numpy#24750 (comment)) 9. Forces coloured and prettified outputs for test runs Some of these changes have been copied with updates and suggestions received from numpy#24603 on 23/02/2024 and authorship is preserved with this commit. Co-Authored-By: Ralf Gommers <[email protected]>
This commit performs the following actions: 1. Adds WASM builds to the CPU family for Meson configurations, but without SSE or SIMD instructions. 2. Removes CPU feature detection message for an unsupported architecture. 3. Enables `IEEE_QUAD_LE` longdouble format for the wasm32 target (cross-builds). 4. Enables run for Emscripten/Pyodide wheels by setting the `if:` condition to `true`. 5. Uses recursive submodules to ensure that vendored-meson is received. 6. Moves the Meson cross file to `tools/ci/emscripten/` (i.e., creates a separate Emscripten folder to store relevant files) 7. Adds a patch for vendored-meson detection for Pyodide and applies this Pyodide-meson patch in the Emscripten CI jobs 8. Builds wasm32 wheels without BLAS and LAPACK support (see numpy#24750 (comment)) 9. Forces coloured and prettified outputs for test runs Some of these changes have been copied with updates and suggestions received from numpy#24603 on 23/02/2024 and authorship is preserved with this commit. Co-Authored-By: Ralf Gommers <[email protected]>
This commit performs the following actions: 1. Adds WASM builds to the CPU family for Meson configurations, but without SSE or SIMD instructions. 2. Removes CPU feature detection message for an unsupported architecture. 3. Enables `IEEE_QUAD_LE` longdouble format for the wasm32 target (cross-builds). 4. Enables run for Emscripten/Pyodide wheels by setting the `if:` condition to `true`. 5. Uses recursive submodules to ensure that vendored-meson is received. 6. Moves the Meson cross file to `tools/ci/emscripten/` (i.e., creates a separate Emscripten folder to store relevant files) 7. Adds a patch for vendored-meson detection for Pyodide and applies this Pyodide-meson patch in the Emscripten CI jobs 8. Builds wasm32 wheels without BLAS and LAPACK support (see numpy#24750 (comment)) 9. Forces coloured and prettified outputs for test runs Some of these changes have been copied with updates and suggestions received from numpy#24603 on 23/02/2024 and authorship is preserved with this commit. [skip cirrus] [skip circle] [skip azp] Co-Authored-By: Ralf Gommers <[email protected]>
This commit performs the following actions: 1. Adds WASM builds to the CPU family for Meson configurations, but without SSE or SIMD instructions. 2. Removes CPU feature detection message for an unsupported architecture. 3. Enables `IEEE_QUAD_LE` longdouble format for the wasm32 target (cross-builds). 4. Enables run for Emscripten/Pyodide wheels by setting the `if:` condition to `true`. 5. Uses recursive submodules to ensure that vendored-meson is received. 6. Moves the Meson cross file to `tools/ci/emscripten/` (i.e., creates a separate Emscripten folder to store relevant files) 7. Adds a patch for vendored-meson detection for Pyodide and applies this Pyodide-meson patch in the Emscripten CI jobs 8. Builds wasm32 wheels without BLAS and LAPACK support (see numpy#24750 (comment)) 9. Forces coloured and prettified outputs for test runs Some of these changes have been copied with updates and suggestions received from numpy#24603 on 23/02/2024 and authorship is preserved with this commit. [skip cirrus] [skip circle] [skip azp] Co-Authored-By: Ralf Gommers <[email protected]>
This PR is superseded by gh-25894, things seem to work there. So I'll close this PR. Thanks for the help everyone! |
Thanks for working on this @rgommers and @agriyakhetarpal! |
This commit performs the following actions: 1. Adds WASM builds to the CPU family for Meson configurations, but without SSE or SIMD instructions. 2. Enables `IEEE_QUAD_LE` longdouble format for the wasm32 target (cross-builds). 3. Enables run for Emscripten/Pyodide wheels by setting the `if:` condition to `true`. 4. Uses recursive submodules to ensure that vendored-meson is received. 5. Moves the Meson cross file to `tools/ci/emscripten/` (i.e., creates a separate Emscripten folder to store relevant files) 6. Adds a patch for vendored-meson detection for Pyodide and applies this Pyodide-meson patch in the Emscripten CI jobs 7. Builds wasm32 wheels without BLAS and LAPACK support (see numpy#24750 (comment)) 8. Forces coloured and prettified outputs for test runs Some of these changes have been copied with updates and suggestions received from numpy#24603 on 23/02/2024 and authorship is preserved with this commit. [skip cirrus] [skip circle] [skip azp] Co-Authored-By: Ralf Gommers <[email protected]> Co-authored-by: Hood Chatham <[email protected]>
Initial inspiration was taken from numpy/numpy#24603.
* Test emscripten workflow inspired by NumPy Adds a CI job to build and test scikit-image in a Pyodide virtual environment through WASM wheels. Following this, it would be possible to include JupyterLite notebooks in the documentation in order to run scikit-image's code snippets which come with docstring-based examples. Initial inspiration was taken from numpy/numpy#24603. Co-authored-by: Lars Grüter <[email protected]> Co-authored-by: Stefan van der Walt <[email protected]>
This is one of the last CI jobs to be converted to Meson. Still a work in progress.
Note that we need to cross-compile here. Using
pyodide build
fails on not having a cross file. Thesource()
function inpyodide_build/cli/build.py
needs a--backend-flags
parameter so that we can pass config-settings arguments to the backend. In the meantime, we usepython -m build ...
.One can also try this locally with:
as long as both
pyodide-build
and the exact version of Emscripten (currently 3.1.32, can be installed with https://emscripten.org/docs/tools_reference/emsdk.html) are available. The configure stage of the build looks fine, the build itself fails halfway through due to:That issue is due to a static assert in
pyconfig.h
, also discussed at: pyodide/pyodide#2494 (comment)See also pyodide/pyodide#2238 and the patches to
_numpyconfig.h
in https://github.com/pyodide/pyodide/tree/main/packages/numpy.tl;dr this needs some work, and it seems like cross-compilation is hard because Pyodide doesn't ship its own Python interpreter that we can actually target during a direct cross build.
Cc @hoodmane @rth. I hope I can bother you with this. If I got any of the above wrong or if you've got a suggestion to get past the
LONG_BIT
error, I'd love to hear it. Also, a couple of questions:--config-settings
flags to the backend in thepyodide build
CLI, would you accept a PR to Pyodide to add that? It should matchbackend-flags
inmeta.yaml
recipes I think.numpy
too. But after reading this comment, that may not be true? Is that still the case, and do you see a road to a regular cross-compile working for NumPy? It's actually not clear to me how thedistutils
-based build works right now, it doesn't seem to be doing the "playback" thing explained in that comment.