I am trying to implement the python bindings for vtk class with vtkWrapHierarchy. I use vtk 9.0, compiled from scratch with wrappings tools, python bindings and etc. features enabled.
For the first lines of code that seems to work for vtk 8.0 based wrapping, such as:
I receive warnings:
The VTK_USE_FILE is no longer used starting with 8.90.
Call Stack (most recent call first):
CMakeLists.txt:114 (include)
…
CMake Error at CMakeLists.txt:176 (include):
include could not find load file:
vtkWrapHierarchy
Is there something wrong that I do or are there any changes in wrapping approach? Is it assumed the python bindings are somehow now generated/planned to be generated by vtkWrap project? Or should I write CmakeLists much similar to it?
Where I can find examples of how to use vtkWrap tool as external wrapping tool?
Thank you very much in advance,
Best regards,
Evgeniya
WrapVTK was an experimental project, it is not going to be used as the path forward for VTK Python wrapping. It doesn’t work with VTK 9.
As of VTK 9, the wrapping is managed by the new module system which is documented here and here with auto-generated APIs documentation here. The cmake recipes are completely different from VTK 8 and earlier versions of VTK. For VTK 9, wrapping requires that cmake configures your project as a VTK module.
Note that this is because the wrapping support does a lot more for you now (at least in Python, Java differs in details):
tracks hierarchy files reliably across the build and install trees
tracks headers for wrapping across the build and install trees
ensures that dependent modules are loaded first (e.g., vtkmodules.vtkCommonCore needs imported before vtkmodules.vtkCommonSystem) even across projects (so your modules .py file will import the right VTK, ParaView, etc. modules before it is loaded)
wrapping a module is a single call (vtk_module_wrap_python) which handles proper installation and CMake metadata for you automatically (with appropriate controls available as arguments to the command)
For now, all you need to do is “heart” the topic to show your support and wait a couple of weeks (maybe a few months) until it is completed. There are already preliminary wrapping scripts in vtkAddon, but the final version might be a standalone repository.
DearDavid Gobbi, Ben Boeckel andAndras Lasso**, thank you very much. The info clarifies all aspects of the process. I was able to reimplement my structure as a module system and I also figured out that there is an example of how to do it in GitHub that I found very useful for starting with:
I came across a few days ago a similar post about wrapping with VTK 9 and Python. I believe the post had answers from David Gobbi and Ben Boeckel and provided a link to an example on how to wrap a VTK external class with VTK 9.
After a lot of searching, I am not able to find that post again. If anyone knows what I am talking about, or knows where the wrapping example might be, can they please post a link?
the link to discussion is here External vtk 9.0 class with python wrapping (vtkWrapHierarchy) - #5 by EMalikova . Also, in addition to the example you have provided, this has been implemented in open source project, so the example of implementation with external dependencies involved could be found here (see src/CMakeLists vtk_module_add_module function, vtk_module_wrap_python in CMakeLists.txt and src/fits.module file).
I hope this helps,
Best of luck with your research:),
Best regards,
Evgeniya