Skip to content

Add libitk wrapping output#118

Closed
CavRiley wants to merge 7 commits into
conda-forge:mainfrom
CavRiley:add-libitk-wrapping-output
Closed

Add libitk wrapping output#118
CavRiley wants to merge 7 commits into
conda-forge:mainfrom
CavRiley:add-libitk-wrapping-output

Conversation

@CavRiley

Copy link
Copy Markdown

Checklist

  • Used a personal fork of the feedstock to propose changes
  • Bumped the build number (if the version is unchanged)
  • Reset the build number to 0 (if the version changed)
  • Re-rendered with the latest conda-smithy (Use the phrase @conda-forge-admin, please rerender in a comment in this PR for automated rerendering)
  • Ensured the license file is being packaged.

Purpose

The purpose of this PR is to add a wrapping output to libitk conda packaging (discussed in ITKPythonPackage PR #302). This allows ITK remote modules to be packages as conda packages usable in Python conda environments.

I also experimented with using these conda packages as caches for building Python wheels for ITK. While this worked for mac and windows builds, to make manylinux compatible wheels, I believe the conda packages would need to be created within the manylinux docker environments with the correct compilers and toolchains (which may not be possible here).

Note

Only one Python version is built per platform variant.
Expanding to multiple Python versions (e.g. 3.10, 3.11, 3.12) is a follow-up decisions as it multiplies CI time, and the supported version set hasn't been agreed on yet.

CavRiley added 7 commits May 20, 2026 11:25
Adds a `libitk-wrapping` output that includes the Python `itk` module
(site-packages/itk and site-packages/itkConfig.py). Build turns on
ITK_WRAP_PYTHON with ITK_USE_SYSTEM_CASTXML, identified by
WRAP_ITK_INSTALL_COMPONENT_IDENTIFIER=PythonWrapping.

ITK's wrapping install rules don't cleanly partition by COMPONENT, so:
- libitk_install removes site-packages/itk* after its component sweep so
  the wrapping payload is not included in libitk.
- libitk-wrapping_install sweeps all components into PREFIX then prunes
  to keep only the Python wrapping content.

Bumps build.number to 5.
Includes Wrapping/, per-module wrapping/ subdirs, and build-tree Typedefs/
artifacts so external Python-wrapped modules can build against an
installed ITK. libitk-devel also includes ITKModule*/KWStyle/Maintenance
helpers required by ITKModuleExternal.cmake. Post-install patches
WrappingConfigCommon.cmake to forward Eigen3 + module include dirs into
the directory's INCLUDE_DIRECTORIES (read by ITK's wrapping/castxml pass).
ITK_WRAP_PYTHON=ON activates find_package(Python3 Development.Module), which
fails on aarch64/ppc64le because ${PYTHON} introspection yields BUILD x86_64
headers that CMAKE_FIND_ROOT_PATH=${PREFIX} filters out. Add explicit
Python3_INCLUDE_DIR + Python3_LIBRARY hints inside the existing cross-compile
block.
itk_auto_load_submodules.cmake demands CMAKE_CXX_COMPILER_TARGET so
castxml (Clang-based) knows the target triple. Add inside the existing
cross-compile block alongside the Python hints.
Castxml's bundled Clang can't parse PowerPC's __float128/__ieee128 builtin
(in libstdc++ <limits>/<bits/specfun.h>) or Eigen's AltiVec PacketMath, so
ITK_WRAP_PYTHON=ON fails at the castxml step on ppc64le.

Disable wrapping for the linux-ppc64le target and skip the libitk-wrapping
and libitk-wrapping-devel outputs on that platform.
@conda-forge-admin

Copy link
Copy Markdown
Contributor

Hi! This is the friendly automated conda-forge-linting service.

I wanted to let you know that I linted all conda-recipes in your PR (recipe/meta.yaml) and found some lint.

Here's what I've got...

For recipe/meta.yaml:

  • ❌ Selectors are suggested to take a <two spaces>#<one space>[<expression>] form. See lines [142]

For recipe/meta.yaml:

  • ℹ️ The recipe is not parsable by parser conda-souschef (grayskull). This parser is not currently used by conda-forge, but may be in the future. We are collecting information to see which recipes are compatible with grayskull.
  • ℹ️ The recipe is not parsable by parser conda-recipe-manager. The recipe can only be automatically migrated to the new v1 format if it is parseable by conda-recipe-manager.
  • ℹ️ top-level output has some malformed specs:
  • In section build: cmake >=3.16.3, <3.30.0
    Requirement spec fields should match the syntax name [version [build]]to avoid known issues in conda-build. For example, instead of name =version=build, use name version.* build. There should be no spaces between version operators and versions either: python >= 3.8 should be python >=3.8.

This message was generated by GitHub Actions workflow run https://github.com/conda-forge/conda-forge-webservices/actions/runs/26177234353. Examine the logs at this URL for more detail.

@blowekamp

Copy link
Copy Markdown
Contributor

Please consider updating the itk-feedstock where the current ITK python package is.

@CavRiley

Copy link
Copy Markdown
Author

Please consider updating the itk-feedstock where the current ITK python package is.

Does it make sense to add an itk output here with the Python bindings, and retire the separate itk-feedstock? It would avoid rebuilding the ITK C++ libraries in a second feedstock, though I'm not sure whether these changes would break downstream packages like libsimpleitk.

@blowekamp

blowekamp commented May 20, 2026

Copy link
Copy Markdown
Contributor

As far as I know ITK python requires static ITK libraries, while libitk provides share libraries to be reused by other packages. The compile time of the ITK libraries will be rather small compared to the wrapping.

There appear to be several other libraries which depend on libitk:
https://github.com/search?q=org%3Aconda-forge+libitk&type=code

Addition: IMHO it would be ideal If the wrapping package would be an independent project which depended on the ITK shared libraries. That would require a MAJOR rework of the ITK wrapping code though.

@CavRiley

Copy link
Copy Markdown
Author

As far as I know ITK python requires static ITK libraries

With the conda packages I have been testing, ITK Python seems to be working within the conda environment using shared ITK libraries. Could this be a Python wheel limitation?

There appear to be several other libraries which depend on libitk: https://github.com/search?q=org%3Aconda-forge+libitk&type=code

I tried to be the least disruptive with the changes to the libitk and devel install scripts. Focusing on making just a wrapping bindings and wrapping source tree outputs. I wouldn't expect there to be any regression.

If you still think these additions would be better suited for the itk-feedstock, I can move this over!

@blowekamp

Copy link
Copy Markdown
Contributor

Yes, please move this work to the irk-feedstock repo where the existing python wrapping is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants