Skip to content

Commit 2d75a4e

Browse files
mkoeppeCopilotDerThorstenIsabelParedes
authored
Add passagemath-{environment,setup}, cysignals, passagemath-{objects,repl}, memory-allocator, passagemath-{categories,graphs}, symmetrica, passagemath-combinat, gsl, passagemath-modules, cmr, passagemath-cmr (emscripten-forge#4446)
* Add cysignals recipe for emscripten-wasm32 platform Co-authored-by: DerThorsten <904752+DerThorsten@users.noreply.github.com> * Add meson-python requirement * Add build.sh script and emscripten.meson.cross file for cysignals Co-authored-by: IsabelParedes <23283243+IsabelParedes@users.noreply.github.com> * Add pkg-config to cysignals recipe dependencies * Delete pixi.lock * recipes/recipes_emscripten/passagemath-environment: New * recipes/recipes_emscripten/passagemath-environment/recipe.yaml: Update requirements as example 'regex' seems to suggest, add extra/recipe-maintainers * recipes/recipes_emscripten/passagemath-environment/recipe.yaml: Add about/license, about/license_file * recipes/recipes_emscripten/passagemath-environment/recipe.yaml: Adapt tests, extra/emscripten_tests from brotli recipe * recipes/recipes_emscripten/passagemath-setup: New * recipes/recipes_emscripten/passagemath-objects: New * recipes/recipes_emscripten/cysignals/recipe.yaml: Update to 1.12.6 * recipes/recipes_emscripten/cysignals: Add patch * recipes/recipes_emscripten/cysignals/recipe.yaml: Update license_file * recipes/recipes_emscripten/cysignals: Add sigaltstack patch * recipes/recipes_emscripten/cysignals/build.sh: Set c_thread_count=0 * recipes/recipes_emscripten/cysignals/test_import_cysignals.py: Do not try to import what can only be cimported * recipes/recipes_emscripten/cysignals: Patch out use of threads * recipes/recipes_emscripten/passagemath-*: Update to 10.8.1 * recipes/recipes_emscripten/passagemath-categories: New * recipes/recipes_emscripten/memory-allocator: New * recipes/recipes_emscripten/passagemath-categories: Add memory-allocator dep * recipes/recipes_emscripten/memory-allocator/recipe.yaml: Add license * recipes/recipes_emscripten/passagemath-repl: New * recipes/recipes_emscripten/passagemath-categories: Add tests * recipes/recipes_emscripten/passagemath-repl: Add ipython dep * recipes/recipes_emscripten/passagemath-categories: Disable many tests * recipes/recipes_emscripten/passagemath-categories/test_passagemath_categories.py: Do not try to run doctests * recipes/recipes_emscripten/passagemath-graphs: New * recipes/recipes_emscripten/passagemath-categories/test_passagemath_categories.py: Do not try to run doctests at all * recipes/recipes_emscripten/symmetrica: New * recipes/recipes_emscripten/passagemath-combinat: New * recipes/recipes_emscripten/gsl: New * recipes/recipes_emscripten/passagemath-modules: New * recipes/recipes_emscripten/gsl/build.sh: Use openblas * recipes/recipes_emscripten/gsl: Fixups * variant.yaml: Pin gsl to 2.8 * recipes/recipes_emscripten/passagemath-modules: Add deps * recipes/recipes_emscripten/cmr: New * recipes/recipes_emscripten/passagemath-cmr: New * .github/workflows/build_recipes.yaml: Upload packages as an artifact * recipes/recipes_emscripten/cysignals/recipe.yaml: Update extra/recipe-maintainers * recipes/recipes_emscripten/passagemath-environment/recipe.yaml: Remove commented-out extra deps * recipes/recipes_emscripten/symmetrica/recipe.yaml: Test presence of lib/libsymmetrica.a * recipes/recipes_emscripten/passagemath-*: Shorten the autogenerated long descriptions * recipes/recipes_emscripten/gsl: Remove openblas dependency * recipes/recipes_emscripten/cysignals: Make patches sequential * recipes/recipes_emscripten/cmr/build.sh: Copy wasm files also * recipes/recipes_emscripten/cmr/build.sh: Copy wasm files also (fixup) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DerThorsten <904752+DerThorsten@users.noreply.github.com> Co-authored-by: Isabel Paredes <isabel.paredes@quantstack.net> Co-authored-by: IsabelParedes <23283243+IsabelParedes@users.noreply.github.com>
1 parent 7695c76 commit 2d75a4e

36 files changed

Lines changed: 1078 additions & 1 deletion
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
mkdir build
2+
cd build
3+
mkdir -p $PREFIX
4+
5+
# Configure step
6+
cmake ${CMAKE_ARGS} .. \
7+
-GNinja \
8+
-DCMAKE_PREFIX_PATH:PATH=${PREFIX} \
9+
-DCMAKE_INSTALL_PREFIX:PATH=${PREFIX} \
10+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
11+
-DCMAKE_BUILD_TYPE=Release
12+
13+
ninja install
14+
15+
# Copy wasm files also
16+
cp *.wasm $PREFIX/bin/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
context:
2+
version: 1.4
3+
4+
package:
5+
name: cmr
6+
version: ${{ version }}
7+
8+
source:
9+
url: https://github.com/discopt/cmr/archive/refs/tags/v${{ version }}.tar.gz
10+
sha256: 956a6114d7ee2d3176376660ab1221306da9b2f6de985825d8e60c9cbdf41c17
11+
12+
build:
13+
number: 0
14+
15+
requirements:
16+
build:
17+
- ${{ compiler("cxx") }}
18+
- cmake
19+
- ninja
20+
- gmp
21+
- gtest
22+
23+
tests:
24+
- script:
25+
- test -d ${PREFIX}/include/cmr
26+
27+
about:
28+
license: MIT
29+
license_file: LICENSE
30+
summary: Combinatorial matrix recognition
31+
homepage: https://github.com/discopt/cmr
32+
33+
extra:
34+
recipe-maintainers:
35+
- mkoeppe
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cp $RECIPE_DIR/emscripten.meson.cross $SRC_DIR
2+
3+
# write out the cross file
4+
sed "s|@(PYTHON)|${PYTHON}|g" $SRC_DIR/emscripten.meson.cross > $SRC_DIR/emscripten.meson.new
5+
mv $SRC_DIR/emscripten.meson.new $SRC_DIR/emscripten.meson.cross
6+
7+
cat $SRC_DIR/emscripten.meson.cross
8+
9+
${PYTHON} -m pip install . -vvv --no-deps --no-build-isolation \
10+
-Csetup-args="--cross-file=$SRC_DIR/emscripten.meson.cross" \
11+
-Csetup-args="-Dc_thread_count=0"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# binaries section is at the end as may want to append python binary.
2+
3+
[properties]
4+
needs_exe_wrapper = true
5+
skip_sanity_check = true
6+
longdouble_format = 'IEEE_QUAD_LE' # for numpy
7+
8+
[host_machine]
9+
system = 'emscripten'
10+
cpu_family = 'wasm32'
11+
cpu = 'wasm'
12+
endian = 'little'
13+
14+
[binaries]
15+
exe_wrapper = 'node'
16+
pkgconfig = 'pkg-config'
17+
python = '@(PYTHON)'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From 4bc25048707657e93bfd0169a0bb0bad7421773c Mon Sep 17 00:00:00 2001
2+
From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
3+
Date: Mon, 9 Feb 2026 18:25:33 -0800
4+
Subject: [PATCH 1/3] src/cysignals/implementation.c: Only use backtrace when
5+
both HAVE_BACKTRACE and HAVE_EXECINFO_H
6+
7+
---
8+
src/cysignals/implementation.c | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/src/cysignals/implementation.c b/src/cysignals/implementation.c
12+
index 88dee66..5f8f3e5 100644
13+
--- a/src/cysignals/implementation.c
14+
+++ b/src/cysignals/implementation.c
15+
@@ -719,7 +719,7 @@ static void print_sep(void)
16+
/* Print a backtrace if supported by libc */
17+
static void print_backtrace()
18+
{
19+
-#if HAVE_BACKTRACE
20+
+#if HAVE_BACKTRACE && HAVE_EXECINFO_H
21+
void* backtracebuffer[BACKTRACELEN];
22+
int btsize = backtrace(backtracebuffer, BACKTRACELEN);
23+
if (btsize)
24+
--
25+
2.51.1
26+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From fb6cde9a76a6245adfdf2a905d28797b7dd8aaec Mon Sep 17 00:00:00 2001
2+
From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
3+
Date: Wed, 11 Feb 2026 10:50:16 -0800
4+
Subject: [PATCH 2/3] meson.build: Do not use threads on emscripten
5+
6+
---
7+
meson.build | 3 ++-
8+
1 file changed, 2 insertions(+), 1 deletion(-)
9+
10+
diff --git a/meson.build b/meson.build
11+
index 2253bcd..8082e2d 100644
12+
--- a/meson.build
13+
+++ b/meson.build
14+
@@ -15,6 +15,7 @@ is_windows = host_machine.system() == 'windows'
15+
is_cygwin = host_machine.system() == 'cygwin'
16+
is_msvc = cc.get_id() == 'msvc'
17+
is_mingw = cc.get_id()=='gcc' and host_machine.system()=='windows'
18+
+is_emscripten = host_machine.system() == 'emscripten'
19+
20+
# Set preprocessor macros
21+
# Disable .c line numbers in exception tracebacks
22+
@@ -94,7 +95,7 @@ config.set('CYSIGNALS_STD_ATOMIC', cxx.links('#include <atomic>\nint main() { st
23+
# for std::atomic with OpenMP in C++ code
24+
config.set('CYSIGNALS_STD_ATOMIC_WITH_OPENMP', cxx.links('#include <atomic>\nint main() { static std::atomic<int> x; return 0; }', args: ['-fopenmp']) ? 1 : 0)
25+
26+
-if is_windows
27+
+if is_windows or is_emscripten
28+
threads_dep = []
29+
else
30+
threads_dep = dependency('threads')
31+
--
32+
2.51.1
33+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From 2ce8b6b240072d218ece162fb3705ad318472a46 Mon Sep 17 00:00:00 2001
2+
From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
3+
Date: Wed, 24 Jan 2024 23:24:45 -0800
4+
Subject: [PATCH 3/3] src/cysignals/implementation.c [EMSCRIPTEN]: Do not use
5+
sigaltstack
6+
7+
---
8+
src/cysignals/implementation.c | 4 +++-
9+
1 file changed, 3 insertions(+), 1 deletion(-)
10+
11+
diff --git a/src/cysignals/implementation.c b/src/cysignals/implementation.c
12+
index 5f8f3e5..ae27eee 100644
13+
--- a/src/cysignals/implementation.c
14+
+++ b/src/cysignals/implementation.c
15+
@@ -632,7 +632,7 @@ static void _sig_off_warning(const char* file, int line)
16+
17+
static void setup_alt_stack(void)
18+
{
19+
-#if HAVE_SIGALTSTACK
20+
+#if HAVE_SIGALTSTACK && !defined(__EMSCRIPTEN__)
21+
/* Space for the alternate signal stack. The size should be
22+
* of the form MINSIGSTKSZ + constant. The constant is chosen rather
23+
* ad hoc but sufficiently large. */
24+
@@ -675,7 +675,9 @@ static void setup_cysignals_handlers(void)
25+
* After setting up the trampoline, we reset the signal mask. */
26+
sigprocmask(SIG_BLOCK, &sa.sa_mask, &default_sigmask);
27+
#endif
28+
+#if !defined(__EMSCRIPTEN__)
29+
setup_trampoline();
30+
+#endif
31+
#if HAVE_SIGPROCMASK
32+
sigprocmask(SIG_SETMASK, &default_sigmask, &sigmask_with_sigint);
33+
#endif
34+
--
35+
2.51.1
36+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
context:
2+
name: cysignals
3+
version: 1.12.6
4+
5+
package:
6+
name: ${{ name }}
7+
version: ${{ version }}
8+
9+
source:
10+
url: https://pypi.io/packages/source/${{ name[0] }}/${{ name }}/${{ name }}-${{ version }}.tar.gz
11+
sha256: 3ef3a37bdb244821b85475a08e2762ca1019570b369e321504995fa9a54675ce
12+
patches: # from https://github.com/passagemath/upstream-cysignals
13+
- 'patches/0001-src-cysignals-implementation.c-Only-use-backtrace-wh.patch'
14+
- 'patches/0002-meson.build-Do-not-use-threads-on-emscripten.patch'
15+
- 'patches/0003-src-cysignals-implementation.c-EMSCRIPTEN-Do-not-use.patch'
16+
17+
build:
18+
number: 0
19+
20+
requirements:
21+
build:
22+
- ${{ compiler('c') }}
23+
- cython
24+
- cross-python_${{ target_platform }}
25+
- python
26+
- pip
27+
- meson-python
28+
- pkg-config
29+
host:
30+
- python
31+
run:
32+
- python
33+
34+
tests:
35+
- script: pytester
36+
files:
37+
recipe:
38+
- test_import_cysignals.py
39+
requirements:
40+
build:
41+
- pytester
42+
run:
43+
- pytester-run
44+
45+
about:
46+
homepage: https://github.com/sagemath/cysignals
47+
license: LGPL-3.0-or-later
48+
license_file: LICENSE
49+
summary: Interrupt and signal handling for Cython
50+
description: |
51+
When writing Cython code, special care must be taken to ensure that the code
52+
can be interrupted with CTRL-C. Since Cython optimizes for speed, Cython
53+
normally does not check for interrupts. For example, code like the following
54+
cannot be interrupted in Cython:
55+
56+
cdef long i
57+
for i in range(2^63):
58+
if i > 2^60:
59+
print i
60+
61+
The cysignals package provides mechanisms to handle interrupts (and other
62+
signals and errors) in Cython code.
63+
64+
extra:
65+
recipe-maintainers:
66+
- mkoeppe
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test_import_cysignals():
2+
import cysignals
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
emconfigure ./configure \
2+
CFLAGS="$CFLAGS -fPIC" \
3+
--prefix=${PREFIX} \
4+
--disable-shared
5+
emmake make -j${CPU_COUNT}
6+
emmake make install

0 commit comments

Comments
 (0)