Skip to content

Add rebound recipe (librebound + rebound)#5801

Merged
IsabelParedes merged 3 commits into
emscripten-forge:mainfrom
MMesch:add-rebound
Jul 6, 2026
Merged

Add rebound recipe (librebound + rebound)#5801
IsabelParedes merged 3 commits into
emscripten-forge:mainfrom
MMesch:add-rebound

Conversation

@MMesch

@MMesch MMesch commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Add emscripten-forge recipes for REBOUND as a single multi-output recipe (following the matplotlib pattern):

librebound — C shared library (side module)

  • Builds src/*.c as a WASM side module with -sEXPORT_ALL=1
  • Installs to $PREFIX/lib/librebound.so and $PREFIX/include/
  • C test compiles test + source files statically (side module .so cannot be linked by wasm-ld)

rebound — Python ctypes wrapper (depends on librebound)

  • Patches setup.py to skip C extension build on emscripten
  • Patches rebound/__init__.py to load librebound.so from $PREFIX/lib/ via ctypes
  • Patches rebound/horizons.py to use try/except ImportError around pyodide.http import instead of sys.modules check
  • Patches src/simulation.c to remove emscripten_sleep() calls in the integration loop and pause poll — these require -sASYNCIFY which we do not compile with (no display server); without this patch sim.integrate() aborts in a browser context
  • Tested with pytester: import + 2-body N-body simulation

@IsabelParedes

Copy link
Copy Markdown
Member

@MMesch Since both recipes have the same source and are related, both packages can be in a single recipe rebound/recipe.yaml with multiple outputs. See matplotlib for example

@MMesch

MMesch commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Ok great. I'll do that!

@MMesch MMesch changed the title Add librebound and rebound recipes Add rebound recipe (librebound + rebound) Jul 6, 2026
MMesch added 3 commits July 6, 2026 14:44
Build the REBOUND C library as a wasm shared library for emscripten.
The library and headers are installed to /lib and /include
so they can be used by both xeus-cpp (C/C++ kernel) and the rebound
Python wrapper package.

The SERVER feature (POSIX sockets + pthreads) is not compiled since
it is unavailable in the browser environment.
- Combine librebound/ and rebound/ into rebound/ with two outputs,
  following the matplotlib pattern
- Add patch to remove emscripten_sleep calls that require ASYNCIFY;
  the integration loop yield and pause poll are no-ops without a
  display server and break browser-main execution otherwise
@IsabelParedes IsabelParedes merged commit 4a739e5 into emscripten-forge:main Jul 6, 2026
2 checks passed
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