Include additional files in itk external module python wheels

The new scripts for building external modules are amazing!

What is the magic to include additional files in a python wheel for an external module using the new scripts?

For example, if I have a project directory


  • CMakeLists.txt
  • .github/workflows/build-test-package.yml
  • src
    • CMakeLists.txt
    • foo.cxx
  • include
    • foo.h
  • wrapping
    • CMakeLists.txt
    • foo.wrap
  • extras

How can I include in the wheel?

Could perhaps copy to ITK-build/Wrapping/Generators/Python/itk, but I’m guessing that there is a much cleaner way.


For Python applications, you can use PythonWheelRuntimeLibraries:

and scripts in

They then go to your bin package directory. I don’t know how to put them where goes…

1 Like

Thanks! That might be perfect for my use cases.

Since I do not want to include applications only, I also found a way to add python files using WRAP_ITK_PYTHON_BINDINGS_INSTALL:

It seems to work so far. What I now miss is a way to add an initialization line in the module init, e.g.

from import *

Any suggestion is welcome…

@matt.mccormick might have some suggestions?



A follow-up on your suggestion. In wrapping/CMakeLists.txt, I have modified ITK_WRAP_PYTHON_LIBRARY_IMPORTS. It works if RTK is loaded (no LazyLoading or something loaded the module beforehand). If the first RTK attribute is in one of the imports and lazy loading is on, ITK does not know the symbol. I have found a work around with, see

What do you think of this “solution” to add the new attributes to the lazy list? It seems a bit too low level but I haven’t found a better solution… Suggestions are welcome!

1 Like

@simon.rit beautiful, well done! :clap: :100: