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
include
wrapping
extras
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
simon.rit
(Simon Rit)
March 13, 2023, 6:19am
2
For Python applications, you can use PythonWheelRuntimeLibraries
:
and scripts
in setup.py
scripts=[
"lib/rtkorageometry.py",
"lib/rtksimulatedgeometry.py",
"lib/rtkvarianobigeometry.py",
"lib/rtkelektasynergygeometry.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.
simon.rit
(Simon Rit)
March 14, 2023, 3:03pm
4
Since I do not want to include applications only, I also found a way to add python files using WRAP_ITK_PYTHON_BINDINGS_INSTALL
:
RTKConsortium:master
ā SimonRit:rtkconjugategradient_py
opened 11:26PM - 22 Feb 23 UTC
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ā¦
dzenanz
(Dženan ZukiÄ)
March 14, 2023, 4:36pm
5
@matt.mccormick might have some suggestions?
simon.rit
(Simon Rit)
March 30, 2023, 5:47am
7
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 __init_module__.py
, see
RTKConsortium:master
ā SimonRit:rtkconjugategradient_py
opened 11:26PM - 22 Feb 23 UTC
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!