External vtk 9.0 class with python wrapping (vtkWrapHierarchy)

Dear vtk users,

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:

INCLUDE(${VTK_USE_FILE})
include(vtkWrapHierarchy)

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

Hi Eugeniya,

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)

I think this is what you are requesting: RFC: Toward supporting distribution of VTK based modules on PyPI

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.