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

itkFOO

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

How can I include FOOExtras.py in the wheel?

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

Thanks,
Stephen

For Python applications, you can use PythonWheelRuntimeLibraries:

and scripts in setup.py

They then go to your bin package directory. I don’t know how to put them where itkExtras.py 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 FOOExtras.py import *

Any suggestion is welcome…

@matt.mccormick might have some suggestions?

Perhaps ITK_WRAP_PYTHON_LIBRARY_IMPORTS is useful here?

2 Likes