Skip to content
Draft
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
2 changes: 2 additions & 0 deletions recipes/recipes/cross-python_emscripten-wasm32/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export CMAKE_ARGS="${CMAKE_ARGS} \
# in ctypes/__init_.py there is
# if _os.name == "posix" and _sys.platform == "darwin":

CTYPES_INIT_FILE="$BUILD_PREFIX/lib/python$PY_VER/ctypes/__init__.py"

# we need to replace this with if False: because otherwise we run into issues:
# * just replacing _sys.platform with a smth else fails at other places...
sed 's/_sys.platform == "darwin"/False/g' "$CTYPES_INIT_FILE" > "$CTYPES_INIT_FILE.tmp" && mv "$CTYPES_INIT_FILE.tmp" "$CTYPES_INIT_FILE"
Expand Down
2 changes: 1 addition & 1 deletion recipes/recipes/cross-python_emscripten-wasm32/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package:
version: ${{ version }}

build:
number: 19
number: 22

requirements:
run:
Expand Down
20 changes: 0 additions & 20 deletions recipes/recipes_emscripten/doctest/build.sh

This file was deleted.

34 changes: 0 additions & 34 deletions recipes/recipes_emscripten/doctest/recipe.yaml

This file was deleted.

1 change: 1 addition & 0 deletions recipes/recipes_emscripten/hdf5/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_STATIC_LIBS=OFF \
-DHDF5_BUILD_CPP_LIB=ON \
-DCMAKE_PROJECT_INCLUDE=${RECIPE_DIR}/overwriteProp.cmake \
-DONLY_SHARED_LIBS=ON \
-DBUILD_TESTING=OFF \
Expand Down
7 changes: 6 additions & 1 deletion recipes/recipes_emscripten/hdf5/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ source:
sha256: c15adf34647918dd48150ea1bd9dffd3b32a3aec5298991d56048cc3d39b4f6f

build:
number: 0
number: 1

requirements:
build:
Expand All @@ -21,6 +21,11 @@ requirements:
host:
- zlib

tests:
- package_contents:
files:
- include/H5Cpp.h

about:
homepage: https://www.hdfgroup.org/solutions/hdf5/
license: BSD-3-Clause
Expand Down
81 changes: 81 additions & 0 deletions recipes/recipes_emscripten/libitk/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
set -e

mkdir -p build
cd build




# add to cmake global include path
export CXXFLAGS="$CXXFLAGS -I${HDF5_INC_DIR}"
export CFLAGS="$CFLAGS -I${HDF5_INC_DIR}"
export LDFLAGS="$LDFLAGS -L${PREFIX}/lib"


# delete shared libz
rm -f ${PREFIX}/lib/libz.so*

emcmake cmake ${CMAKE_ARGS} \
-GNinja \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_STATIC_LIBS=OFF \
-DCMAKE_PROJECT_INCLUDE=${RECIPE_DIR}/overwriteProp.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
-DBUILD_TESTING=OFF \
-DModule_ITKTestKernel=OFF \
-DBUILD_EXAMPLES=OFF \
-DITK_USE_GPU=OFF \
-DITK_DEFAULT_THREADER=Platform \
-DITK_USE_PTHREADS=OFF \
-DITK_USE_OPENMP=OFF \
-DModule_ITKTBBImageToImageFilter=OFF \
-DITK_USE_FFTWD=OFF \
-DITK_USE_FFTWF=OFF \
-DITK_USE_SYSTEM_FFTW=OFF \
-DITK_DYNAMIC_LOADING=OFF \
-DITK_USE_SYSTEM_EXPAT=ON \
-DITK_USE_SYSTEM_JPEG=ON \
-D "CMAKE_BUILD_TYPE:STRING=RELEASE" \
-D "CMAKE_FIND_ROOT_PATH:PATH=${PREFIX}" \
-D "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE:STRING=ONLY" \
-D "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY:STRING=ONLY" \
-D "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM:STRING=NEVER" \
-D "CMAKE_FIND_ROOT_PATH_MODE_PACKAGE:STRING=ONLY" \
-D "CMAKE_FIND_FRAMEWORK:STRING=NEVER" \
-D "CMAKE_FIND_APPBUNDLE:STRING=NEVER" \
-D "CMAKE_INSTALL_PREFIX=${PREFIX}" \
-D "CMAKE_PROGRAM_PATH=${BUILD_PREFIX}" \
-DITK_USE_SYSTEM_PNG=ON \
-DITK_USE_SYSTEM_TIFF=ON \
-DITK_USE_SYSTEM_ZLIB=ON \
-DITK_USE_SYSTEM_EIGEN=ON \
-DITK_USE_SYSTEM_HDF5=ON \
-DITK_BUILD_DEFAULT_MODULES=ON \
-DModule_ITKReview=OFF \
-DModule_ITKTBB=OFF \
-DModule_ITKIOTransformHDF5=ON \
-DModule_ITKDisplacementFields=ON \
-DModule_ITKCommon=ON \
-DModule_ITKDisplacementField=ON \
-DModule_ITKIOGDCM=ON \
-DModule_ITKIOImageBase=ON \
-DModule_ITKIOTransformBase=ON \
-DModule_ITKImageCompose=ON \
-DModule_ITKImageIntensity=ON \
-DModule_ITKLabelMap=ON \
-DModule_ITKMetricsv4=ON \
-DModule_ITKOptimizersv4=ON \
-DModule_ITKRegistrationMethodsv4=ON \
-DModule_ITKTransform=ON \
-DModule_ITKHDF5=ON \
-DModule_ITKIOTransformFactory=ON \
-DITK_FORBID_DOWNLOADS=ON \
-DDO_NOT_BUILD_ITK_TEST_DRIVER=ON \
"${SRC_DIR}"

ninja -j${CPU_COUNT}
ninja install
4 changes: 4 additions & 0 deletions recipes/recipes_emscripten/libitk/overwriteProp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_STRIP FALSE) # used by default in pybind11 on .so modules
51 changes: 51 additions & 0 deletions recipes/recipes_emscripten/libitk/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
context:
name: libitk
version: "5.4.6"

package:
name: ${{ name }}
version: ${{ version }}

source:
- url: https://github.com/InsightSoftwareConsortium/ITK/archive/v${{ version }}.tar.gz
sha256: cf28bc7220c57c24ebcbabbd3b2544ea7ab65f0aad430a99f8e157738ed812b7

build:
number: 0

requirements:
build:
- ${{ compiler('c') }}
- ${{ compiler('cxx') }}
- cmake
- ninja
host:
- expat
- libjpeg-turbo
- libpng
- libtiff
- eigen
- zlib
- hdf5

tests:
- package_contents:
files:
- include/ITK-5.4/itkImage.h
- lib/libITKCommon-5.4.so

about:
homepage: https://www.itk.org/
license: Apache-2.0
license_file: LICENSE
summary: ITK is an open-source toolkit for multidimensional image analysis
description: |
The Insight Toolkit (ITK) is an open-source, cross-platform system that
provides developers with an extensive suite of software tools for image
analysis. Developed through extreme programming methodologies, ITK employs
leading-edge algorithms for registering and segmenting multidimensional data.
repository: https://github.com/InsightSoftwareConsortium/ITK

extra:
recipe-maintainers:
- Copilot
50 changes: 50 additions & 0 deletions recipes/recipes_emscripten/simpleitk/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
set -e

# Step 1: Build SimpleITK C++ library (without Python wrapping)
# Use CMAKE_ARGS from emscripten environment (set up by emscripten_emscripten-wasm32)
# but strip the Python flags that cross-python adds, as they are not needed here
mkdir -p build_cpp
cd build_cpp



cmake ${CMAKE_ARGS} \
-GNinja \
-DITK_DIR="${PREFIX}/lib/cmake/ITK-5.4" \
-DCMAKE_PROJECT_INCLUDE="${RECIPE_DIR}/overwriteProp.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_EXAMPLES=OFF \
-DSimpleITK_BUILD_DISTRIBUTE=ON \
-DWRAP_DEFAULT=OFF \
"${SRC_DIR}"

ninja -j${CPU_COUNT}
ninja install

cd ..

# Step 2: Build the Python wrapper
# CMAKE_ARGS now also contains Python-related flags added by cross-python
mkdir -p build_python
cd build_python

emcmake cmake ${CMAKE_ARGS} \
-G Ninja \
-D CMAKE_BUILD_TYPE:STRING=Release \
-D SimpleITK_BUILD_DISTRIBUTE:BOOL=ON \
-D SimpleITK_BUILD_STRIP:BOOL=ON \
-D BUILD_SHARED_LIBS:BOOL=OFF \
-D BUILD_TESTING:BOOL=OFF \
-D SimpleITK_PYTHON_USE_VIRTUALENV:BOOL=OFF \
"${SRC_DIR}"/Wrapping/Python

emmake cmake --build . --config Release
"${PYTHON}" -m pip install .
4 changes: 4 additions & 0 deletions recipes/recipes_emscripten/simpleitk/overwriteProp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s WASM_BIGINT -s SIDE_MODULE=1")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s WASM_BIGINT -s SIDE_MODULE=1 -fwasm-exceptions")
set(CMAKE_STRIP FALSE)
66 changes: 66 additions & 0 deletions recipes/recipes_emscripten/simpleitk/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
context:
name: SimpleITK
version: "2.5.5"

package:
name: simpleitk
version: ${{ version }}

source:
url: https://github.com/SimpleITK/SimpleITK/archive/refs/tags/v${{ version }}.tar.gz
sha256: d216d687c7d0d1aebcbc43a0c3367e1172c8446301accd7acad796dd18430bc3

build:
number: 0
files:
exclude:
- '**/__pycache__/**'
- '**/*.pyc'
python:
skip_pyc_compilation:
- '**/*.py'

requirements:
build:
- ${{ compiler('c') }}
- ${{ compiler('cxx') }}
- cmake
- ninja
- swig >=4.0.0
- cross-python_${{ target_platform }}
- python
- lua <5.5
host:
- python
- pip
- libitk
- hdf5
- eigen
run:
- python

tests:
- script: pytester
files:
recipe:
- test_import_simpleitk.py
requirements:
build:
- pytester
run:
- pytester-run

about:
homepage: http://www.simpleitk.org
license: Apache-2.0
license_file: LICENSE
summary: Simplified interface to the Insight Toolkit for image registration and segmentation
description: |
SimpleITK is a simplified layer built on top of ITK (Insight Segmentation and
Registration Toolkit). It provides bindings for multiple programming languages
including Python, Java, C#, R, Lua, Tcl, and Ruby.
repository: https://github.com/SimpleITK/SimpleITK

extra:
recipe-maintainers:
- Copilot
6 changes: 6 additions & 0 deletions recipes/recipes_emscripten/simpleitk/test_import_simpleitk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def test_import_simpleitk():
import SimpleITK as sitk
# Basic sanity check
img = sitk.Image(10, 10, sitk.sitkUInt8)
assert img.GetWidth() == 10
assert img.GetHeight() == 10
Loading