Getting Python version

Another question for you @dgobbi. How can I detect VTKs Python version?

I tried this:

 execute_process(COMMAND "${_vtk}/bin/vtkpython" -c "import sys; sys.stdout.write('.'.join(map(str, sys.version_info[:2])))" OUTPUT_VARIABLE py_ver)

But not all VTK installations have that executable.

I already asked that on the old mailing list.

The VTK cmake configuration does not export that information, so there is no guaranteed way to detect it. This kind of stuff frustrates me all the time, too. The Kitware folks seem to want to limit the number of exported CMake variables to an absolute minimum.

1 Like

It is guaranteed that find_package(PythonN) will be called if you request a Python-using component when finding VTK. There is (now?) a mention in the docs on how to request Python information at the top of vtk-config.cmake.

1 Like