Skip to content

Commit dc7f51c

Browse files
hjmjohnsonclaude
andcommitted
ENH: Add libitk-wrapping pixi-build package recipe
Add a rattler-build recipe to produce a conda package containing ITK C++ libraries with full Python wrapping artifacts (SWIG interfaces, CastXML outputs, compiled Python modules, stubs). This package can be consumed as a host-dependency to skip the expensive ITK C++ build when generating Python wheels for ITK or remote modules. The recipe supports overriding the ITK source repository and tag via ITK_GIT_URL and ITK_GIT_TAG environment variables, enabling builds from feature branches and PRs for testing. Build scripts are provided for both Unix and Windows platforms. CMake flags match conda-forge's libitk-feedstock (using system libraries) plus the additional wrapping options needed for Python wheel generation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1728684 commit dc7f51c

4 files changed

Lines changed: 210 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
4+
:: Build ITK C++ with Python wrapping for use as a conda package (Windows).
5+
6+
set BUILD_DIR=%SRC_DIR%\..\build
7+
mkdir %BUILD_DIR%
8+
cd %BUILD_DIR%
9+
10+
cmake ^
11+
-G "Ninja" ^
12+
%CMAKE_ARGS% ^
13+
-D BUILD_SHARED_LIBS:BOOL=ON ^
14+
-D BUILD_TESTING:BOOL=OFF ^
15+
-D BUILD_EXAMPLES:BOOL=OFF ^
16+
-D CMAKE_BUILD_TYPE:STRING=Release ^
17+
-D "CMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX%" ^
18+
^
19+
-D ITK_WRAP_PYTHON:BOOL=ON ^
20+
-D ITK_WRAP_DOC:BOOL=ON ^
21+
-D ITK_LEGACY_SILENT:BOOL=ON ^
22+
-D CMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON ^
23+
^
24+
-D ITK_WRAP_unsigned_short:BOOL=ON ^
25+
-D ITK_WRAP_double:BOOL=ON ^
26+
-D ITK_WRAP_complex_double:BOOL=ON ^
27+
-D "ITK_WRAP_IMAGE_DIMS:STRING=2;3;4" ^
28+
^
29+
-D WRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel ^
30+
-D WRAP_ITK_INSTALL_COMPONENT_PER_MODULE:BOOL=ON ^
31+
^
32+
-D ITK_USE_SYSTEM_EXPAT:BOOL=ON ^
33+
-D ITK_USE_SYSTEM_HDF5:BOOL=ON ^
34+
-D ITK_USE_SYSTEM_JPEG:BOOL=ON ^
35+
-D ITK_USE_SYSTEM_PNG:BOOL=ON ^
36+
-D ITK_USE_SYSTEM_TIFF:BOOL=ON ^
37+
-D ITK_USE_SYSTEM_ZLIB:BOOL=ON ^
38+
-D ITK_USE_SYSTEM_FFTW:BOOL=ON ^
39+
-D ITK_USE_SYSTEM_EIGEN:BOOL=ON ^
40+
-D ITK_USE_FFTWD:BOOL=ON ^
41+
-D ITK_USE_FFTWF:BOOL=ON ^
42+
^
43+
-D ITK_BUILD_DEFAULT_MODULES:BOOL=ON ^
44+
-D Module_ITKReview:BOOL=ON ^
45+
-D Module_ITKTBB:BOOL=ON ^
46+
-D Module_MGHIO:BOOL=ON ^
47+
-D Module_ITKIOTransformMINC:BOOL=ON ^
48+
-D Module_GenericLabelInterpolator:BOOL=ON ^
49+
-D Module_AdaptiveDenoising:BOOL=ON ^
50+
^
51+
-D ITK_USE_KWSTYLE:BOOL=OFF ^
52+
-D "ITK_DEFAULT_THREADER:STRING=Pool" ^
53+
^
54+
"%SRC_DIR%"
55+
56+
if errorlevel 1 exit /b 1
57+
58+
cmake --build . --config Release
59+
if errorlevel 1 exit /b 1
60+
61+
cmake --install . --config Release
62+
if errorlevel 1 exit /b 1
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Build ITK C++ with Python wrapping for use as a conda package.
5+
# This produces headers, shared libraries, CMake config, and all
6+
# wrapping metadata (SWIG .i/.idx/.mdx files, Python stubs) needed
7+
# by downstream ITK remote modules.
8+
9+
BUILD_DIR="${SRC_DIR}/../build"
10+
mkdir -p "${BUILD_DIR}"
11+
cd "${BUILD_DIR}"
12+
13+
# Use TBB on Linux; macOS has known issues with conda TBB
14+
use_tbb=ON
15+
if [ "$(uname)" = "Darwin" ]; then
16+
use_tbb=OFF
17+
fi
18+
19+
# Handle cross-compilation try-run results if available
20+
if [[ "${CONDA_BUILD_CROSS_COMPILATION:-0}" == "1" ]]; then
21+
try_run_results="${RECIPE_DIR}/TryRunResults-${target_platform}.cmake"
22+
if [[ -f "${try_run_results}" ]]; then
23+
CMAKE_ARGS="${CMAKE_ARGS} -C ${try_run_results}"
24+
fi
25+
fi
26+
27+
cmake \
28+
-G "Ninja" \
29+
${CMAKE_ARGS} \
30+
-D BUILD_SHARED_LIBS:BOOL=ON \
31+
-D BUILD_TESTING:BOOL=OFF \
32+
-D BUILD_EXAMPLES:BOOL=OFF \
33+
-D CMAKE_BUILD_TYPE:STRING=Release \
34+
-D "CMAKE_INSTALL_PREFIX=${PREFIX}" \
35+
\
36+
-D ITK_WRAP_PYTHON:BOOL=ON \
37+
-D ITK_WRAP_DOC:BOOL=ON \
38+
-D ITK_LEGACY_SILENT:BOOL=ON \
39+
-D CMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \
40+
\
41+
-D ITK_WRAP_unsigned_short:BOOL=ON \
42+
-D ITK_WRAP_double:BOOL=ON \
43+
-D ITK_WRAP_complex_double:BOOL=ON \
44+
-D "ITK_WRAP_IMAGE_DIMS:STRING=2;3;4" \
45+
\
46+
-D WRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel \
47+
-D WRAP_ITK_INSTALL_COMPONENT_PER_MODULE:BOOL=ON \
48+
\
49+
-D ITK_USE_SYSTEM_EXPAT:BOOL=ON \
50+
-D ITK_USE_SYSTEM_HDF5:BOOL=ON \
51+
-D ITK_USE_SYSTEM_JPEG:BOOL=ON \
52+
-D ITK_USE_SYSTEM_PNG:BOOL=ON \
53+
-D ITK_USE_SYSTEM_TIFF:BOOL=ON \
54+
-D ITK_USE_SYSTEM_ZLIB:BOOL=ON \
55+
-D ITK_USE_SYSTEM_FFTW:BOOL=ON \
56+
-D ITK_USE_SYSTEM_EIGEN:BOOL=ON \
57+
-D ITK_USE_FFTWD:BOOL=ON \
58+
-D ITK_USE_FFTWF:BOOL=ON \
59+
\
60+
-D ITK_BUILD_DEFAULT_MODULES:BOOL=ON \
61+
-D Module_ITKReview:BOOL=ON \
62+
-D Module_ITKTBB:BOOL=${use_tbb} \
63+
-D Module_MGHIO:BOOL=ON \
64+
-D Module_ITKIOTransformMINC:BOOL=ON \
65+
-D Module_GenericLabelInterpolator:BOOL=ON \
66+
-D Module_AdaptiveDenoising:BOOL=ON \
67+
\
68+
-D ITK_USE_KWSTYLE:BOOL=OFF \
69+
-D NIFTI_SYSTEM_MATH_LIB= \
70+
-D GDCM_USE_COREFOUNDATION_LIBRARY:BOOL=OFF \
71+
-D "ITK_DEFAULT_THREADER:STRING=Pool" \
72+
\
73+
"${SRC_DIR}"
74+
75+
cmake --build . --config Release
76+
77+
cmake --install . --config Release

packages/libitk-wrapping/pixi.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[workspace]
2+
channels = ["https://prefix.dev/conda-forge"]
3+
platforms = ["linux-64", "linux-aarch64", "osx-arm64", "osx-64", "win-64"]
4+
preview = ["pixi-build"]
5+
6+
[dependencies]
7+
libitk-wrapping = { path = "." }
8+
python = ">=3.10"
9+
10+
[package]
11+
name = "libitk-wrapping"
12+
version = "6.99.0"
13+
14+
[package.build]
15+
backend = { name = "pixi-build-rattler-build", version = "0.3.*" }
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package:
2+
name: libitk-wrapping
3+
version: "6.99.0"
4+
5+
source:
6+
git: ${{ env.get("ITK_GIT_URL", "https://github.com/BRAINSia/ITK.git") }}
7+
tag: ${{ env.get("ITK_GIT_TAG", "itk-conda-pythonpackage-support") }}
8+
9+
build:
10+
number: 0
11+
script:
12+
- if: unix
13+
then: bash ${RECIPE_DIR}/build-libitk-wrapping.sh
14+
- if: win
15+
then: cmd /c ${RECIPE_DIR}/build-libitk-wrapping.bat
16+
17+
requirements:
18+
build:
19+
- ${{ compiler('c') }}
20+
- ${{ compiler('cxx') }}
21+
- cmake >=3.26
22+
- ninja
23+
host:
24+
- python
25+
- swig >=4.1
26+
- castxml
27+
- expat
28+
- hdf5
29+
- libjpeg-turbo
30+
- libtiff
31+
- libpng
32+
- eigen
33+
- zlib
34+
- fftw
35+
- tbb-devel
36+
- doxygen
37+
run:
38+
- python
39+
- tbb
40+
- hdf5
41+
- fftw
42+
- libjpeg-turbo
43+
- libtiff
44+
- libpng
45+
- expat
46+
- zlib
47+
48+
about:
49+
home: https://itk.org
50+
license: Apache-2.0
51+
license_file: LICENSE
52+
summary: >
53+
ITK C++ libraries with Python wrapping artifacts (SWIG interfaces,
54+
CastXML outputs, compiled Python modules). Used as a build dependency
55+
for ITK Python wheel generation and remote module packaging.
56+
dev_url: https://github.com/InsightSoftwareConsortium/ITK

0 commit comments

Comments
 (0)