Skip to content

Use cibuildwheel to build WASM/Pyodide wheels for scikit-image, push nightlies to Anaconda.org#7440

Merged
stefanv merged 43 commits intoscikit-image:mainfrom
agriyakhetarpal:cibuildwheel-wasm+nightly-uploads
May 2, 2025
Merged

Use cibuildwheel to build WASM/Pyodide wheels for scikit-image, push nightlies to Anaconda.org#7440
stefanv merged 43 commits intoscikit-image:mainfrom
agriyakhetarpal:cibuildwheel-wasm+nightly-uploads

Conversation

@agriyakhetarpal
Copy link
Contributor

@agriyakhetarpal agriyakhetarpal commented Jun 11, 2024

Description

This PR is a follow-up to #7350 based on #7350 (comment). It modifies the wheel recipe workflow in wheels-recipe.yml to additionally build and test Pyodide wheels through cibuildwheel version 2.23.0, which added support for building against Pyodide 0.27. Since the workflow is triggered using the workflow_call: event in nightly-wheel-build.yml, this enables pushing the wheels to the Anaconda.org index, which is hosted at https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/. These wheels can then be used for interactive docs for "dev"/"latest" versions; this is a prerequisite for follow-ups to #7644.

Checklist

Release note

For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.

...

@agriyakhetarpal agriyakhetarpal marked this pull request as draft June 11, 2024 20:35
@agriyakhetarpal
Copy link
Contributor Author

agriyakhetarpal commented Jun 11, 2024

This isn't currently working because the Node.js script runner isn't able to find pyodide where it gets installed: https://github.com/agriyakhetarpal/scikit-image/actions/runs/9471953221/job/26096398007

I think I have two potential fixes; one is to do npm install pyodide --global (this didn't work), and the other is to install to the {project} directory, i.e., the root of the repository, as a prefix because that is where I have instructed cibuildwheel to run the JavaScript file from. I'll test this in a moment. Edit: started a run here: https://github.com/agriyakhetarpal/scikit-image/actions/runs/9472581755/job/26098187649, let's see if this works. Edit 2: okay, this works, but now I can't do import skimage because it will pick up skimage from the {project} directory... argh. I'll have to think about this so that other libraries that use the Node.js runner such as scikit-learn can adopt this too.

Summoning @hoodmane – would you consider this a bug or rather an intricacy of how npm works (I am not proficient with JavaScript enough)? In any case, I would like to improve the Pyodide docs around all of this – not just for highlighting how to configure/use cibuildwheel with it, but also for out-of-tree builds in general and recommendations around it, in the coming time. I still have some other documentation work from our previous discussions in my backlog :)

@agriyakhetarpal agriyakhetarpal force-pushed the cibuildwheel-wasm+nightly-uploads branch from 82a7f81 to 32c1980 Compare June 12, 2024 18:15
Copy link
Member

@stefanv stefanv left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Maybe add a note to emscripten to explain the difference in build methodology?

@stefanv stefanv added the 🤖 type: Infrastructure CI, packaging, tools and automation label Mar 27, 2025
@agriyakhetarpal
Copy link
Contributor Author

Maybe add a note to emscripten to explain the difference in build methodology?

Yes, sure; where should I add this? Do you mean adding one above the workflow?

@stefanv
Copy link
Member

stefanv commented Mar 27, 2025

Maybe add a note to emscripten to explain the difference in build methodology?

Yes, sure; where should I add this? Do you mean adding one above the workflow?

Sure, anywhere to document that there is a discrepancy in the way we build emscripten, and why. Probably should be mentioned in both builds!

@agriyakhetarpal
Copy link
Contributor Author

agriyakhetarpal commented Mar 27, 2025

Got it! I won't say there's a difference in how we build for Emscripten. The only changes from a regular pip install build && python -m build are:

  • we use pyodide build which monkeypatches pypa/build and uses a pywasmcross.py script to cross-compile from Linux to wasm32-unknown-emscripten, instead of compiling natively
  • cibuildwheel uses pyodide build as well and sets up Emscripten, Node.js, etc. automatically
  • the testing differs by a bit as pytest's cacheprovider plugin is somewhat broken – which I noted using a comment.

This translates to just one extra option to pass to cibuildwheel, which can only be configured using an environment variable at the moment and is done using CIBW_PLATFORM: pyodide.

Or, were you referring to how this job and the emscripten.yaml workflow differ from each other?

@stefanv
Copy link
Member

stefanv commented Mar 27, 2025

Ah, OK, I just wasn't sure of the reasoning of why there was any difference at all, and wanted to make sure others who look into this in the future can follow. However you choose to document that is fine.

@agriyakhetarpal
Copy link
Contributor Author

Okay, I added a note about this in 49ac338. The git blame should also point to this PR so developers can examine why the difference exists. Thanks for the review!

@agriyakhetarpal
Copy link
Contributor Author

I addressed the merge conflicts here. Thanks!

I notice that zizmor did not warn me about missing SHAs for the cibuildwheel action, as it's not running with the --pedantic argument. I assume it was removed at some later point, but I've still added the hash.

@agriyakhetarpal
Copy link
Contributor Author

I'm having a bit of trouble running the tests on my fork to see if this is working: https://github.com/agriyakhetarpal/scikit-image/actions/runs/14802982173

I'll debug this, and we should be good to proceed once we have a passing wheel build.

@agriyakhetarpal
Copy link
Contributor Author

@stefanv stefanv merged commit 42bb07e into scikit-image:main May 2, 2025
24 checks passed
@stefanv stefanv added this to the 0.26 milestone May 2, 2025
@stefanv
Copy link
Member

stefanv commented May 2, 2025

Thanks, @agriyakhetarpal!

We're having a chat with the Anaconda team soon and will mention the CORS header issue so that, hopefully, we can start using the dev wheels from the nightly repo directly.

@agriyakhetarpal
Copy link
Contributor Author

agriyakhetarpal commented May 2, 2025

Thanks for this, @stefanv! Actually, the CORS headers issue from the Anaconda.org side has been resolved earlier this year (see pyodide/pyodide#4898 (comment)), so these wheels are now usable in the interactive docs for the "dev" versions. Here's an example from scikit-learn: scikit-learn/scikit-learn#31085

@stefanv
Copy link
Member

stefanv commented May 2, 2025

@matthewfeickert ☝️

@agriyakhetarpal agriyakhetarpal deleted the cibuildwheel-wasm+nightly-uploads branch May 5, 2025 02:02
matthew-brett added a commit to matthew-brett/scikit-image that referenced this pull request Jul 7, 2025
* origin/main:
  Deprecate estimate method in favor of class constructor (scikit-image#7771)
  Temporary fix for Visual Studio & Clang incompatibility in Windows image (scikit-image#7835)
  Address deprecations in Pillow 11.3 (scikit-image#7828)
  Remove unused & obsolete `legacy_datasets`, `legacy_registry` vars (scikit-image#7677)
  Draft migration guide for skimage2 (scikit-image#7785)
  Do not report failure in wheels sub-recipe (scikit-image#7806)
  Use consistent wording in property description. (scikit-image#7804)
  Add intensity_median to regionprops (scikit-image#7745)
  CI: Update pypa/gh-action-pypi-publish to v1.12.4 for attestations on PyPI (scikit-image#7793)
  Document output dtype for transform.resize. (scikit-image#7792)
  Use `cibuildwheel` to build WASM/Pyodide wheels for `scikit-image`, push nightlies to Anaconda.org (scikit-image#7440)
  DOC: Include missing gain parameter in adjust_gamma equation (scikit-image#7763)
  Temporarily pin to `pyodide-build==0.30.0`, and ensure that the correct xbuildenvs are used (scikit-image#7788)
  Deprecate old names & attributes in RegionProperties (scikit-image#7778)
  Pin JasonEtco/create-an-issue action to SHA for v2.9.2 (scikit-image#7787)
  Make doctest-plus work with spin (scikit-image#7786)
  Report failures on main via issue (scikit-image#7752)
  Use `workers` instead of alternate parameter names (scikit-image#7302)
  Fix f-string in otsu plot (scikit-image#7780)
  Further document use of regionprops function and fix terms. (scikit-image#7518)
matthew-brett added a commit to matthew-brett/scikit-image that referenced this pull request Jul 14, 2025
* origin/main: (31 commits)
  Update import convention in certain gallery examples (scikit-image#7764)
  Refactor fundamental matrix scaling (scikit-image#7767)
  Add unit test for cval unequal to zero
  Forward  in _generic_edge_filter
  Remove superfluous mask argument from _generic_edge_filter
  Only report failure on main branch once
  Deprecate estimate method in favor of class constructor (scikit-image#7771)
  Temporary fix for Visual Studio & Clang incompatibility in Windows image (scikit-image#7835)
  Address deprecations in Pillow 11.3 (scikit-image#7828)
  Remove unused & obsolete `legacy_datasets`, `legacy_registry` vars (scikit-image#7677)
  Draft migration guide for skimage2 (scikit-image#7785)
  Do not report failure in wheels sub-recipe (scikit-image#7806)
  Use consistent wording in property description. (scikit-image#7804)
  Add intensity_median to regionprops (scikit-image#7745)
  CI: Update pypa/gh-action-pypi-publish to v1.12.4 for attestations on PyPI (scikit-image#7793)
  Document output dtype for transform.resize. (scikit-image#7792)
  Use `cibuildwheel` to build WASM/Pyodide wheels for `scikit-image`, push nightlies to Anaconda.org (scikit-image#7440)
  DOC: Include missing gain parameter in adjust_gamma equation (scikit-image#7763)
  Temporarily pin to `pyodide-build==0.30.0`, and ensure that the correct xbuildenvs are used (scikit-image#7788)
  Deprecate old names & attributes in RegionProperties (scikit-image#7778)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 type: Infrastructure CI, packaging, tools and automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants