Skip to content

Commit 3985efd

Browse files
committed
Merge librebound and rebound into a single multi-output recipe
- 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
1 parent b4c2c3b commit 3985efd

6 files changed

Lines changed: 119 additions & 109 deletions

File tree

recipes/recipes_emscripten/librebound/recipe.yaml

Lines changed: 0 additions & 76 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Remove emscripten_sleep calls that require ASYNCIFY.
2+
3+
Upstream uses emscripten_sleep(0) in the integration loop to yield to the
4+
browser for drawing, and emscripten_sleep(100) in the pause loop to poll.
5+
Both require -sASYNCIFY which we do not compile with (no display server).
6+
Without ASYNCIFY these calls abort at runtime with "Please compile your
7+
program with async support".
8+
9+
For the integration loop: simply drop the yield — without a display server
10+
there is nothing to draw and synchronous WASM cannot yield anyway.
11+
For the pause loop: break immediately rather than spinning; the simulation
12+
resumes as if it was never paused (pause is not meaningful without ASYNCIFY).
13+
--- a/src/simulation.c
14+
+++ b/src/simulation.c
15+
@@ -300,7 +300,8 @@ static int reb_check_exit(struct reb_simulation* const r, const double tmax, do
16+
while(r->status == REB_STATUS_PAUSED || r->status == REB_STATUS_SCREENSHOT){
17+
// Wait for user to disable paused simulation
18+
#ifdef __EMSCRIPTEN__
19+
- emscripten_sleep(100);
20+
+ r->status = REB_STATUS_RUNNING; // ASYNCIFY not available; resume immediately
21+
+ break;
22+
#else
23+
usleep(1000);
24+
#endif
25+
@@ -399,7 +399,6 @@ static void* reb_simulation_integrate_raw(void* args){
26+
if (t1-t0>1000./120.){ // max framerate 120Hz
27+
t0 = t1;
28+
- emscripten_sleep(0); // allow drawing and event handling
29+
}
30+
31+
#endif

recipes/recipes_emscripten/rebound/recipe.yaml

Lines changed: 88 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,110 @@ context:
22
name: rebound
33
version: 5.0.0
44

5-
package:
6-
name: ${{ name }}
7-
version: ${{ version }}
8-
95
source:
10-
- url: https://pypi.io/packages/source/${{ name[0] }}/${{ name }}/${{ name }}-${{ version }}.tar.gz
6+
- url: https://pypi.io/packages/source/r/rebound/rebound-${{ version }}.tar.gz
117
sha256: 9012bc4ceac42da8c1344f54e72b64da4720149875dc069d8e0dd1be0285dc04
128
patches:
139
- patches/0001-skip-c-extension-on-emscripten.patch
1410
- patches/0002-load-librebound-from-prefix.patch
1511
- patches/0003-fix-pyodide-import.patch
12+
- patches/0004-remove-emscripten-sleep.patch
1613

1714
build:
1815
number: 0
19-
script: ${PYTHON} -m pip install . ${PIP_ARGS} --no-deps --no-build-isolation
20-
21-
files:
22-
exclude:
23-
- '**/__pycache__/**'
24-
- '**/*.pyc'
25-
- '**/*.so'
26-
python:
27-
skip_pyc_compilation:
28-
- '**/*.py'
2916

30-
requirements:
17+
outputs:
18+
- package:
19+
name: librebound
20+
version: ${{ version }}
3121
build:
32-
- cross-python_${{ target_platform }}
33-
- python
34-
- setuptools
35-
- wheel
36-
- pip
37-
host:
38-
- python
39-
run:
40-
- python
41-
- librebound
22+
script: build_librebound.sh
23+
requirements:
24+
build:
25+
- ${{ compiler('c') }}
26+
tests:
27+
- package_contents:
28+
lib:
29+
- librebound.so
30+
include:
31+
- rebound.h
32+
- rebound_internal.h
33+
- boundary.h
34+
- collision.h
35+
- derivatives.h
36+
- display.h
37+
- fmemopen.h
38+
- frequency_analysis.h
39+
- gravity.h
40+
- integrator_bs.h
41+
- integrator_eos.h
42+
- integrator_ias15.h
43+
- integrator_janus.h
44+
- integrator_leapfrog.h
45+
- integrator_mercurius.h
46+
- integrator_saba.h
47+
- integrator_sei.h
48+
- integrator_trace.h
49+
- integrator_whfast.h
50+
- integrator_whfast512.h
51+
- output.h
52+
- particle.h
53+
- rebound.h
54+
- rotations.h
55+
- server.h
56+
- simulation.h
57+
- simulationarchive.h
58+
- tools.h
59+
- transformations.h
60+
- tree.h
61+
- binarydata.h
62+
- script: build_tests.sh
63+
requirements:
64+
build:
65+
- ${{ compiler('c') }}
66+
files:
67+
source:
68+
- src/
69+
recipe:
70+
- build_tests.sh
71+
- tests/
4272

43-
tests:
44-
- script: pytester
45-
files:
46-
recipe:
47-
- test_import_rebound.py
73+
- package:
74+
name: rebound
75+
version: ${{ version }}
76+
build:
77+
script: ${PYTHON} -m pip install . ${PIP_ARGS} --no-deps --no-build-isolation
78+
files:
79+
exclude:
80+
- '**/__pycache__/**'
81+
- '**/*.pyc'
82+
- '**/*.so'
83+
python:
84+
skip_pyc_compilation:
85+
- '**/*.py'
4886
requirements:
4987
build:
50-
- pytester
88+
- cross-python_${{ target_platform }}
89+
- python
90+
- setuptools
91+
- wheel
92+
- pip
93+
host:
94+
- python
5195
run:
52-
- pytester-run
96+
- python
5397
- librebound
98+
tests:
99+
- script: pytester
100+
files:
101+
recipe:
102+
- test_import_rebound.py
103+
requirements:
104+
build:
105+
- pytester
106+
run:
107+
- pytester-run
108+
- librebound
54109

55110
about:
56111
homepage: https://github.com/hannorein/rebound

recipes/recipes_emscripten/librebound/tests/test_rebound.c renamed to recipes/recipes_emscripten/rebound/tests/test_rebound.c

File renamed without changes.

0 commit comments

Comments
 (0)