Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add scipy #1841

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 51 additions & 8 deletions recipes/recipes_emscripten/scipy/build.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
#!/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
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"

# 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 \
--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
14 changes: 14 additions & 0 deletions recipes/recipes_emscripten/scipy/emscripten.meson.cross
Original file line number Diff line number Diff line change
@@ -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'
56 changes: 51 additions & 5 deletions recipes/recipes_emscripten/scipy/recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,54 @@
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

tests:
- script: pytester
Expand All @@ -26,6 +60,18 @@ tests:
- pytester
run:
- pytester-run

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

extra:
recipe-maintainers:
- DerThorsten
Loading