Skip to content

add Macaulay2 - #5959

Merged
IsabelParedes merged 33 commits into
emscripten-forge:mainfrom
wangyenshu:M2
Sep 3, 2026
Merged

add Macaulay2#5959
IsabelParedes merged 33 commits into
emscripten-forge:mainfrom
wangyenshu:M2

Conversation

@wangyenshu

@wangyenshu wangyenshu commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Pre-submission Checks

  • Package requires building for emscripten-wasm32 platform (not a noarch package), in other words, the package requires compilation.

Recipe Structure

Added recipes/recipes_emscripten/[package-name]/recipe.yaml with proper structure:

  • context section with version (and optionally name)
  • package section with name and version using Jinja2 templates
  • source section with:
    • Source URL is valid and points to archive file (.tar.gz, .tar.bz2, .tar.xz, .tgz, or .zip)
    • Source URL contains ${{ version }} template for version updates
    • SHA256 hash is correct (verified with curl -sL <url> | sha256sum)
    • Patches (if any) are included in [package-name]/patches/ directory
  • build section with appropriate script/method
    • Python packages: ${PYTHON} -m pip install . ${PIP_ARGS}
    • R packages: $R CMD INSTALL $R_ARGS .
    • C++ packages: Uses emcmake/emmake or emconfigure/emmake
    • Rust packages: Uses rust-nightly and maturin or appropriate Rust build tool
    • Build number is 0
    • If the script is longer than 3 lines, a build.sh is included
  • requirements section (build, host, run as needed)
  • tests section
    • Python packages: test_import_[package].py file created and referenced
    • C++ packages: Test executable or package_contents test
    • R packages: Package contents test
  • about section with license, homepage, summary

PR Formatting

  • PR title follows format: Add [package-name] or Update [package-name] to [version]
  • PR description includes:
    • Version being added/updated
    • Any special build considerations or patches applied

Package Details

  • Package Name: macaulay2
  • Version: 1.26.06

Build Notes

This pr depends on #5876 and #5873.

@wangyenshu

Copy link
Copy Markdown
Contributor Author

I disabled openmp for Macaulay2. Maybe it is better to remove the omp.h requirement or use a dummy file.

@wangyenshu

Copy link
Copy Markdown
Contributor Author

My fault. I removed -fopenmp. Now it works. No modification needed for Eigen. I will delete that message.

@wangyenshu

Copy link
Copy Markdown
Contributor Author

I get this error in local build and I cannot figure out the cause:

 │ │ -- Generating done (0.7s)
 │ │ -- Build files have been written to: $SRC_DIR/M2/BUILD/build
 │ │ [  0%] Built target M2-supervisor
 │ │ [  9%] Built target scc1
 │ │ [ 45%] Built target M2-interpreter
 │ │ [100%] Built target M2-engine
 │ │ [100%] Built target M2-binary
 │ │ [100%] Generating Macaulay2/Core/tvalues.m2
 │ │ Aborted()
 │ │ wasm://wasm/04b3b126:1
 │ │ RuntimeError: unreachable
 │ │     at wasm://wasm/04b3b126:wasm-function[26689]:0x1145867
 │ │     at ___trap ($SRC_DIR/M2/BUILD/build/usr-dist/x86-Emscripten-Ubuntu-24.0
 │ │ 4/bin/M2-binary.js:1:118684)
 │ │     at abort ($SRC_DIR/M2/BUILD/build/usr-dist/x86-Emscripten-Ubuntu-24.04/
 │ │ bin/M2-binary.js:1:4111)
 │ │     at __abort_js ($SRC_DIR/M2/BUILD/build/usr-dist/x86-Emscripten-Ubuntu-2
 │ │ 4.04/bin/M2-binary.js:1:95358)
 │ │     at wasm://wasm/04b3b126:wasm-function[25384]:0x110a360
 │ │     at wasm://wasm/04b3b126:wasm-function[116]:0x30099
 │ │     at wasm://wasm/04b3b126:wasm-function[601]:0x45720
 │ │     at wasm://wasm/04b3b126:wasm-function[61]:0xe814
 │ │     at initRuntime ($SRC_DIR/M2/BUILD/build/usr-dist/x86-Emscripten-Ubuntu-
 │ │ 24.04/bin/M2-binary.js:1:3245)
 │ │     at doRun ($SRC_DIR/M2/BUILD/build/usr-dist/x86-Emscripten-Ubuntu-24.04/
 │ │ bin/M2-binary.js:1:119745)
 │ │ Node.js v26.5.0
 │ │ make[3]: *** [Macaulay2/m2/CMakeFiles/M2-core.dir/build.make:75: usr-dist/c
 │ │ ommon/share/Macaulay2/Core/tvalues.m2] Error 1
 │ │ make[2]: *** [CMakeFiles/Makefile2:5337: Macaulay2/m2/CMakeFiles/M2-core.di
 │ │ r/all] Error 2
 │ │ make[1]: *** [CMakeFiles/Makefile2:5344: Macaulay2/m2/CMakeFiles/M2-core.di
 │ │ r/rule] Error 2
 │ │ make: *** [Makefile:1902: M2-core] Error 2
 │ │ emmake: error: 'make M2-binary M2-core' failed (returned 2)

@wangyenshu
wangyenshu marked this pull request as ready for review August 30, 2026 20:06
@wangyenshu

Copy link
Copy Markdown
Contributor Author

@IsabelParedes It works! A web demo is here: https://macaulay2-wasm.wasmer.app/.

@wangyenshu

wangyenshu commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

The build process succeds on my local machine. I guess that the optimization step exhausts github action's memory.

@wangyenshu

Copy link
Copy Markdown
Contributor Author

@mkoeppe Macaulay2 is compiled to WebAssembly. Does passagemath provide a interface that allows Macaulay2 to be called in jupyterlite?

@mkoeppe

mkoeppe commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Only a subprocess-based one. (And M2 is not available as a callable library, last time I checked.)

@mkoeppe

mkoeppe commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

@wangyenshu

Copy link
Copy Markdown
Contributor Author

Macaulay2 has a jupyter kernel https://github.com/Macaulay2/Macaulay2-Jupyter-Kernel. I don't know if it is process based.

@mkoeppe

mkoeppe commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@wangyenshu

Copy link
Copy Markdown
Contributor Author

@IsabelParedes Hello. Could you speed up the review for this recipe a little bit? So that Macaulay2 community can use the wasm binary without building.

@IsabelParedes IsabelParedes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few changes needed. Thank you!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you convert these sed commands into *.patch files?
sed edits could silently fail in future releases, plus patch files are easier to read.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But '.patch' file will more likely fail with new releases. It is too rigid and specifies changes for each line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can add a '.patch' file that will not be used for this release for readability.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, patches failing to apply on new releases is the intention. If a patch fails to apply on a new release, then maybe that patch is no longer needed because the changes have been integrated upstream. This works better with smaller patches where each patch addresses one particular issue, as opposed to one large patch to fix everything.

With sed these failures are not obvious. On new releases there will be no indicator if a sed command is needed or not, or if it needs to be modified.

But I leave this up to you. If you prefer sed that's fine.

Comment thread recipes/recipes_emscripten/M2/recipe.yaml Outdated
Comment thread recipes/recipes_emscripten/M2/recipe.yaml Outdated
Comment thread recipes/recipes_emscripten/M2/build.sh Outdated
Comment thread recipes/recipes_emscripten/macaulay2/build.sh
Comment thread recipes/recipes_emscripten/M2/recipe.yaml Outdated
Comment thread recipes/recipes_emscripten/M2/recipe.yaml Outdated
@wangyenshu wangyenshu changed the title add M2 (Macaulay2) add Macaulay2 Sep 2, 2026
@wangyenshu

Copy link
Copy Markdown
Contributor Author

No license files are copied.

So COPYING-GPL-2 does not exist in release. I have to fall back to README.md.

@IsabelParedes

Copy link
Copy Markdown
Member

No license files are copied.

So COPYING-GPL-2 does not exist in release. I have to fall back to README.md.

The license files are there. They're just nested.
https://github.com/Macaulay2/M2/blob/stable/M2/Macaulay2/COPYING-GPL-2

@IsabelParedes IsabelParedes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tiny change to fix the licenses. Thanks!

Comment thread recipes/recipes_emscripten/macaulay2/recipe.yaml Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, patches failing to apply on new releases is the intention. If a patch fails to apply on a new release, then maybe that patch is no longer needed because the changes have been integrated upstream. This works better with smaller patches where each patch addresses one particular issue, as opposed to one large patch to fix everything.

With sed these failures are not obvious. On new releases there will be no indicator if a sed command is needed or not, or if it needs to be modified.

But I leave this up to you. If you prefer sed that's fine.

@IsabelParedes IsabelParedes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@IsabelParedes
IsabelParedes merged commit 96828be into emscripten-forge:main Sep 3, 2026
3 checks passed
IsabelParedes pushed a commit that referenced this pull request Sep 3, 2026
Co-authored-by: emscripten-forge-bot <emscripten-forge-bot@users.noreply.github.com>
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.

3 participants