Wrap Plugin with python for superbuild

Hello ParaView-Community,

I started building my paraview plugin using the paraview-easy-plugin-builder. I successfully build my plugin and also tested it in the corresponding paraview release (5.10.0).
However, I could not get the python wrapping of my plugin to work properly.

Previously, I built my plugin locally on top of a paraview that I built from source, however for the python wrapping, the cmake-files I used do not exist in the superbuild (vtkPythonWrapping, vtkWrapPython, vtk_wrap_python3, python_add_module):

vtk_wrap_python3( ThetaReaderPython36 ThetaReaderPython_SRCS "${THETA_READER_WRAP_LIST}" )
# link python library
add_library( ThetaReaderPython36D ${ThetaReaderPython_SRCS} ${THETA_READER_WRAP_LIST} )
python_add_module( ThetaReaderPython36 ThetaReaderInit.cxx )

I tried switching to vtk_module_wrap_python, which builds the .so file, that I can load succesfully inside pvpython:

  MODULES vtkThetaReader

However, the python module is now not available within paraview.simple.

Is there anything I am missing, or did I just put the python-library into the wrong folder (I just keep it in the Plugin/ThetaReaderModule folder).
Maybe I also need to use vtk_module_add_python_module or vtk_module_add_python_package for this?

I hope someone can help me or hint into the right direction.


1 Like

Hi @StRuoff

Thanks for using the plugin builder !

Can you clarify if you are able to make the python wrapping work locally with your own build of ParaView ?

FYI @Francois_Mazen @ben.boeckel

You talk about ParaView Easy Plugin Builder but you link the older one, ParaView Plugin Builder, can you confirm which project you are using ?

Hello @mwestphal,

I am using the “Easy Builder” and changed the link in the first post accordingly (otherwise Paraview 5.10.0 would not work, right?)

Yes, the wrapping itself works (creates the vtkThetaReader.so file), which I can also load in pvpython after setting the PYTHONPATH to the location of the vtkThetaReader.so file.
However, to load my plugin, I have to do:

from vtkThetaReader import vtkThetaReader

whereas before I could do:

from paraview.simple import vtkThetaReader

In your local build, do you enable specific cmake flags related to python or python wrapping ?

Yes, for my local build (previous setup) I am using the following flags:


and there is this one function I am using (but since it was a while ago I wrote this, don’t know where I got it):

# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python.
# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include
# in your sources to initialize the static python modules

  # check for shared library property

  # add options
  option(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE)
    "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS})               
  # mark these options as advanced                                              
  # add python module

      set(PY_MODULE_TYPE MODULE)                                                
      set(PY_MODULE_TYPE STATIC)                                                
    # add library
    set_property(GLOBAL  APPEND  PROPERTY  PY_MODULES_LIST ${_NAME})            
    add_library(${_NAME} ${PY_MODULE_TYPE} ${ARGN})                             
    #    target_link_libraries(${_NAME} ${PYTHON_LIBRARIES})                    
    # set library prefix
      set_target_properties(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}")
      if(WIN32 AND NOT CYGWIN)
        set_target_properties(${_NAME} PROPERTIES SUFFIX ".pyd")


Another note I forgot to mention, that may explain the different behavior:

My local install (with custom built paraview) is with paraview Version 5.6.0.

The reason why I wanted to switch to the Easy-Builder was indeed, that I couldn’t get the plugin to work with newer paraview versions.

Well, you want to make your plugin work with 5.10 locally first.

That’s what I wanted to avoid, since I would have to completely install paraview 5.10.0 from source locally.

Isn’t there any example, on how to wrap a plugin to the vtk/paraview python? Or at least a hint, on where to put the python-library, so that pvpython can find it?

This is really easy to do the guide is here:

Isn’t there any example, on how to wrap a plugin to the vtk/paraview python? Or at least a hint, on where to put the python-library, so that pvpython can find it?

The wrapping si automatic and should not require anything specific in your plugin. You should be able to load your plugin and just use the python shell as if the code you built is part of actual paraview.

Ok, So I think I found the solution (or rather my error):

When I finished building the Plugin, I copied it to $PARAVIEW_DIR/plugins instead of $PARAVIEW_DIR/lib/paraview-5.10./plugins.
Now the plugin is automatically found by paraview and can be imported via
from paraview.simple import vtkThetaReader

Ok, but I want to mention that you are not supposed to put your own plugins there, there is dedicated mechanism for that.

I see…

I reread all the info on the Plugins from the HowTo and found another mistake I (unintenionally) made:
I forgot to set the PV_PLUGIN_PATH variable.
When I set it to point to the $PARAVIEW_DIR/plugins folder, everything loads fine and also the python-import still works as expected.