Skip to content

add snappy-computop - #5815

Open
wangyenshu wants to merge 5 commits into
emscripten-forge:mainfrom
wangyenshu:snappy-computop
Open

add snappy-computop#5815
wangyenshu wants to merge 5 commits into
emscripten-forge:mainfrom
wangyenshu:snappy-computop

Conversation

@wangyenshu

Copy link
Copy Markdown
Contributor

Template A: Checklist for adding a package

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: snappy-computop
  • Version: 3.3.2

Build Notes

@wangyenshu

Copy link
Copy Markdown
Contributor Author

This is a port of SnapPy to emscripten-forge.

I am not very familiar with packing python and cpp mixed packages and also unfamiliar with using it in a website. @mkoeppe Hello. SnapPy is included in sagemath as an extra package. Does passagemath include SnapPy so that it could run as a static website?

@wangyenshu

Copy link
Copy Markdown
Contributor Author

The file lib/python3.13/site-packages/snappy/CyOpenGL.cpython-313-wasm32-emscripten.so seems missing on github CI build. I guess this is because github action environment does not include opengl.

@mkoeppe

mkoeppe commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@wangyenshu I have a fork of SnapPy that adds support for running on top of the needed modularized distributions of passagemath. I need to go back to updating it for the latest SnapPy.

@mkoeppe

mkoeppe commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Generally, if you are looking to make packages depending on the Sage library work on Wasm, I have numerous forks of curated packages: https://github.com/orgs/passagemath/repositories?type=all&q=passagemath-pkg+sort%3Aname-asc

@wangyenshu

wangyenshu commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Also the gui for SnapPy uses tkinter. I wonder if it is possible to port the gui to WebAssembly.

@mkoeppe

mkoeppe commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@culler or the other authors can comment whether there are plans to change the GUI to something that works in Jupyter notebooks or whether they would accept contributions that do that

@wangyenshu

Copy link
Copy Markdown
Contributor Author

I tried to load SnapPy by pyodide, but I get

Failed to load wheel. Ensure your local server is running and the filename matches.
PythonError: Traceback (most recent call last):
  File "/lib/python3.12/site-packages/micropip/package_manager.py", line 133, in install
    return await install(
           ^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/micropip/install.py", line 53, in install
    await transaction.gather_requirements(requirements)
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 55, in gather_requirements
    await asyncio.gather(*requirement_promises)
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 68, in add_requirement
    await self.add_wheel(wheel, extras=set(), specifier="")
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 271, in add_wheel
    await self.gather_requirements(wheel.requires(extras))
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 55, in gather_requirements
    await asyncio.gather(*requirement_promises)
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 59, in add_requirement
    return await self.add_requirement_inner(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 152, in add_requirement_inner
    await self._add_requirement_from_package_index(req)
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 204, in _add_requirement_from_package_index
    wheel = find_wheel(metadata, req)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 316, in find_wheel
    raise ValueError(
ValueError: Can't find a pure Python 3 wheel for 'pyx'.

I guess its dependencies are not yet put to pyodide recipe.

I am using this frontend: index.html and this build script build.sh.

@mkoeppe

mkoeppe commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@wangyenshu https://pypi.org/project/PyX/#files only has a source distribution; for pyodide to install it using micropip, the maintainers would have to upload a (platform-independent) wheel file to PyPI. The pyodide folks don't like to add recipes for pure Python packages.

@wangyenshu

Copy link
Copy Markdown
Contributor Author

I find this in its setup.py:

install_requires = ['FXrays>=1.3',
                    'plink>=2.4.9',
                    'spherogram>=2.4.1',
                    'snappy_manifolds>=1.4',
                    'low_index>=1.2.1',
                    'tkinter-gl>=1.0',
                    'decorator',
                    'packaging',
                    'pypng', # Used to save OpenGL images.
                    'PyX', # Used to save PDF images of links.
                    'pickleshare', # To avoid https://github.com/ipython/ipython/issues/14416
                    ]
try:
    import sage
except ImportError:
    install_requires.append('cypari>=2.3')
    install_requires.append('ipython>=5.0')

That is a lot of dependencies.

@wangyenshu
wangyenshu marked this pull request as draft July 13, 2026 23:28
@wangyenshu

Copy link
Copy Markdown
Contributor Author

Many of these dependencies have not yet been ported to emscripten-forge. But why the build is successful?

@mkoeppe

mkoeppe commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

All pure Python packages without compiled code are taken directly from conda-forge if a noarch package is available there.

@wangyenshu
wangyenshu marked this pull request as ready for review July 21, 2026 08:28
@wangyenshu

Copy link
Copy Markdown
Contributor Author

Let's try if it works. @mkoeppe Could you contribute a recipe that enable snappy to run in passagemath?

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.

2 participants