From 74305c1d60ef27fd7e5598fe4477972f065f3c41 Mon Sep 17 00:00:00 2001 From: Isabel Paredes Date: Fri, 31 Jan 2025 15:37:05 +0100 Subject: [PATCH 1/3] WIP --- recipes/recipes_emscripten/scipy/build.sh | 52 ++++++++++++--- .../scipy/emscripten.meson.cross | 14 ++++ recipes/recipes_emscripten/scipy/recipe.yaml | 65 ++++++++++++++----- 3 files changed, 108 insertions(+), 23 deletions(-) create mode 100644 recipes/recipes_emscripten/scipy/emscripten.meson.cross diff --git a/recipes/recipes_emscripten/scipy/build.sh b/recipes/recipes_emscripten/scipy/build.sh index f4b39fb4d..d4d930e8f 100644 --- a/recipes/recipes_emscripten/scipy/build.sh +++ b/recipes/recipes_emscripten/scipy/build.sh @@ -1,10 +1,46 @@ #!/bin/bash -PYODIDE_PACKED=$RECIPE_DIR/scipy-1.11.1-cp311-cp311-emscripten_3_1_45_wasm32.whl -# unzip -unzip $PYODIDE_PACKED - -# copy complete folder scipy to side-packages -mkdir -p $PREFIX/lib/python3.11/site-packages -cp -r scipy $PREFIX/lib/python3.11/site-packages -cp -r scipy-1.11.1.dist-info $PREFIX/lib/python3.11/site-packages \ No newline at end of file +set -ex + +# Using flang as a WASM cross-compiler +# https://github.com/serge-sans-paille/llvm-project/blob/feature/flang-wasm/README.wasm.md +# https://github.com/conda-forge/flang-feedstock/pull/69 +micromamba install -p $BUILD_PREFIX \ + conda-forge/label/llvm_rc::libllvm19=19.1.0.rc2 \ + conda-forge/label/llvm_dev::flang=19.1.0.rc2 \ + -y --no-channel-priority +rm $BUILD_PREFIX/bin/clang # links to clang19 +ln -s $BUILD_PREFIX/bin/clang-20 $BUILD_PREFIX/bin/clang # links to emsdk clang + +export FC=flang-new +export FFLAGS="-g --target=wasm32-unknown-emscripten" +export LDFLAGS="" + +mkdir builddir + +meson setup builddir \ + "${meson_config_args[@]}" \ + --buildtype=release \ + --default-library=static \ + --prefer-static \ + --prefix=$PREFIX \ + -Dlibdir=lib \ + -Dfortran_std=none \ + -Dblas=blas \ + -Dlapack=lapack \ + --wrap-mode=nofallback \ + --cross-file=$RECIPE_DIR/emscripten.meson.cross + +# -wnx flags mean: --wheel --no-isolation --skip-dependency-check +$PYTHON -m build -w -n -x \ + -Cbuilddir=builddir \ + -Cinstall-args=--tags=runtime,python-runtime,devel \ + -Csetup-args=-Dblas=blas \ + -Csetup-args=-Dlapack=lapack \ + -Csetup-args=-Duse-g77-abi=true \ + -Csetup-args=${MESON_ARGS// / -Csetup-args=} + +# # copy complete folder scipy to side-packages +# mkdir -p $PREFIX/lib/python3.11/site-packages +# cp -r scipy $PREFIX/lib/python3.11/site-packages +# cp -r scipy-1.11.1.dist-info $PREFIX/lib/python3.11/site-packages \ No newline at end of file diff --git a/recipes/recipes_emscripten/scipy/emscripten.meson.cross b/recipes/recipes_emscripten/scipy/emscripten.meson.cross new file mode 100644 index 000000000..48763013f --- /dev/null +++ b/recipes/recipes_emscripten/scipy/emscripten.meson.cross @@ -0,0 +1,14 @@ +[properties] +needs_exe_wrapper = true +skip_sanity_check = true +longdouble_format = 'IEEE_QUAD_LE' # for numpy + +[host_machine] +system = 'emscripten' +cpu_family = 'wasm32' +cpu = 'wasm' +endian = 'little' + +[binaries] +exe_wrapper = 'node' +pkg-config = 'pkg-config' diff --git a/recipes/recipes_emscripten/scipy/recipe.yaml b/recipes/recipes_emscripten/scipy/recipe.yaml index 47e3b96e8..4a0c535cf 100644 --- a/recipes/recipes_emscripten/scipy/recipe.yaml +++ b/recipes/recipes_emscripten/scipy/recipe.yaml @@ -1,31 +1,66 @@ context: - version: 1.11.1 name: scipy + version: 1.15.1 package: name: ${{ name }} version: ${{ version }} +source: + - url: https://pypi.org/packages/source/s/${{ name }}/${{ name }}-${{ version }}.tar.gz + sha256: 033a75ddad1463970c96a88063a1df87ccfddd526437136b6ee81ff0312ebdf6 + build: - number: 1 + number: 0 requirements: build: - - ${{ compiler('c') }} + - python + - cross-python_${{ target_platform }} + - cython + - numpy + - pybind11 + - meson-python + - cmake + - ninja + - pkg-config + - ${{ compiler('c') }} + - ${{ compiler('cxx') }} + - cmake + # - ${{ compiler('fortran') }} + host: + - libblas >=3.12 + - libcblas >=3.12 + - liblapack >=3.12 + - python + - cython + - python-build + - pybind11 + - pythran + - numpy + - pip run: - - openblas - - numpy + - python + # numpy's run-export only requires <3 because not every package + # is exposed as deeply to its ABI. scipy however only supports + # the two next minor versions after the numpy we build against, see + # https://scipy.github.io/devdocs/dev/core-dev/index.html#version-ranges-for-numpy-and-other-dependencies + - numpy <2.3 + # double-check lower bound from + # https://github.com/scipy/scipy/blob/v${{ version }}/pyproject.toml#L55 + - numpy >=1.23.5 + +about: + homepage: http://www.scipy.org/ + license: BSD-3-Clause + license_file: LICENSE.txt + summary: Scientific Library for Python + description: | + SciPy is a Python-based ecosystem of open-source software for mathematics, + science, and engineering. + documentation: http://www.scipy.org/docs.html + repository: https://github.com/scipy/scipy -tests: -- script: pytester - files: - recipe: - - test_scipy.py - requirements: - build: - - pytester - run: - - pytester-run extra: recipe-maintainers: - DerThorsten From 73c5c916ffbc56b512d59665134de772d248b206 Mon Sep 17 00:00:00 2001 From: Isabel Paredes Date: Fri, 31 Jan 2025 18:20:17 +0100 Subject: [PATCH 2/3] Update build --- recipes/recipes_emscripten/scipy/build.sh | 31 ++++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/recipes/recipes_emscripten/scipy/build.sh b/recipes/recipes_emscripten/scipy/build.sh index d4d930e8f..6a4bf8dab 100644 --- a/recipes/recipes_emscripten/scipy/build.sh +++ b/recipes/recipes_emscripten/scipy/build.sh @@ -14,31 +14,38 @@ ln -s $BUILD_PREFIX/bin/clang-20 $BUILD_PREFIX/bin/clang # links to emsdk clang export FC=flang-new export FFLAGS="-g --target=wasm32-unknown-emscripten" + +# stderr: flang-new: error: unknown argument: '-s' +# flang-new: error: no such file or directory: 'SIDE_MODULE=1' export LDFLAGS="" +# export FC_LD=wasm-ld + mkdir builddir +meson_config_args=( + -Dblas=blas + -Dlapack=lapack + -Duse-pythran=false +) + meson setup builddir \ "${meson_config_args[@]}" \ --buildtype=release \ --default-library=static \ --prefer-static \ --prefix=$PREFIX \ - -Dlibdir=lib \ - -Dfortran_std=none \ - -Dblas=blas \ - -Dlapack=lapack \ --wrap-mode=nofallback \ --cross-file=$RECIPE_DIR/emscripten.meson.cross -# -wnx flags mean: --wheel --no-isolation --skip-dependency-check -$PYTHON -m build -w -n -x \ - -Cbuilddir=builddir \ - -Cinstall-args=--tags=runtime,python-runtime,devel \ - -Csetup-args=-Dblas=blas \ - -Csetup-args=-Dlapack=lapack \ - -Csetup-args=-Duse-g77-abi=true \ - -Csetup-args=${MESON_ARGS// / -Csetup-args=} +# # -wnx flags mean: --wheel --no-isolation --skip-dependency-check +# $PYTHON -m build -w -n -x \ +# -Cbuilddir=builddir \ +# -Cinstall-args=--tags=runtime,python-runtime,devel \ +# -Csetup-args=-Dblas=blas \ +# -Csetup-args=-Dlapack=lapack \ +# -Csetup-args=-Duse-g77-abi=true \ +# -Csetup-args=${MESON_ARGS// / -Csetup-args=} # # copy complete folder scipy to side-packages # mkdir -p $PREFIX/lib/python3.11/site-packages From a6b2763c55af753d75996ea278eac796df0a429c Mon Sep 17 00:00:00 2001 From: Isabel Paredes Date: Fri, 31 Jan 2025 18:53:45 +0100 Subject: [PATCH 3/3] Restore tests --- recipes/recipes_emscripten/scipy/recipe.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/recipes/recipes_emscripten/scipy/recipe.yaml b/recipes/recipes_emscripten/scipy/recipe.yaml index 4a0c535cf..c342561ae 100644 --- a/recipes/recipes_emscripten/scipy/recipe.yaml +++ b/recipes/recipes_emscripten/scipy/recipe.yaml @@ -50,6 +50,17 @@ requirements: # https://github.com/scipy/scipy/blob/v${{ version }}/pyproject.toml#L55 - numpy >=1.23.5 +tests: +- script: pytester + files: + recipe: + - test_scipy.py + requirements: + build: + - pytester + run: + - pytester-run + about: homepage: http://www.scipy.org/ license: BSD-3-Clause