Commit 540f2c5a authored by Max Smolens's avatar Max Smolens

python: Add adapter modules when VTK_ENABLE_KITS is ON

Some Python scripts explicitly import from named submodules as opposed to from
the top-level vtk module. When VTK_ENABLE_KITS is ON those modules might not
exist. This results in ImportErrors, like the one shown below when running the
vtkFiltersCorePython-pointsPrecisions test:

    Traceback (most recent call last):
      File "C:/dev/VTK/Filters/Core/Testing/Python/pointsPrecisions.py", line 3, in <module>
	from vtk.vtkCommonCore import vtkPoints, vtkDoubleArray, vtkIdList
    ImportError: No module named vtkCommonCore

This commit adds adapter modules to allow such scripts to run unmodified when
VTK_ENABLE_KITS is ON.
parent 31b7b0ef
......@@ -299,6 +299,18 @@ if(PYTHON_EXECUTABLE)
list(APPEND VTK_PYTHON_FILES
"${CMAKE_CURRENT_BINARY_DIR}/vtk/__init__.py")
# Kit module adapters
foreach(kit IN LISTS vtk_kits)
set(_module_kit ${kit}${VTK_KIT_SUFFIX})
foreach(dep IN LISTS _${kit}_modules)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/vtk/${dep}")
configure_file(vtk/kit_module__init__.py.in vtk/${dep}/__init__.py @ONLY)
list(APPEND VTK_PYTHON_FILES
"${CMAKE_CURRENT_BINARY_DIR}/vtk/${dep}/__init__.py")
endforeach()
endforeach()
unset(_module_kit)
# vtk.util package
list(APPEND VTK_PYTHON_FILES
vtk/util/__init__
......
"""
This module is an adapter for scripts that explicitly import from named
submodules as opposed to from the top-level vtk module. This is necessary
because the specific submodules might not exist when VTK_ENABLE_KITS is enabled.
"""
from __future__ import absolute_import
from ..@_module_kit@ import *
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment