Commit 741fffbf authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Add new `vtkmodules` package.

Split `vtk` package into `vtkmodules` and `vtk`. `vtkmodules` doesn't
import any of the modules included in its `__init__.py`, instead
provides a `all.py` module that imports all modules in the old `vtk`
package. `vtk` is now a module that imports `vtkmodules/all.py` thus
behaving like the old `vtk` package.
parent bc78b766
......@@ -170,11 +170,11 @@ function(_vtk_add_python_module name)
endif()
# build python module libraries under the ${VTK_BUILD_PYTHON_MODULES_DIR} dir.
set_target_properties(${name}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${VTK_BUILD_PYTHON_MODULES_DIR}/vtk)
PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${VTK_BUILD_PYTHON_MODULES_DIR}/vtkmodules)
if (NOT VTK_INSTALL_NO_RUNTIME)
install(TARGETS ${name}
RUNTIME DESTINATION ${VTK_INSTALL_PYTHON_MODULES_DIR}/vtk COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${VTK_INSTALL_PYTHON_MODULES_DIR}/vtk COMPONENT RuntimeLibraries
RUNTIME DESTINATION ${VTK_INSTALL_PYTHON_MODULES_DIR}/vtkmodules COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${VTK_INSTALL_PYTHON_MODULES_DIR}/vtkmodules COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${VTK_INSTALL_ARCHIVE_DIR} COMPONENT Development
)
endif()
......
......@@ -651,7 +651,7 @@ void vtkPythonInterpreter::SetupVTKPythonPaths()
vtkNew<vtkResourceFileLocator> locator;
locator->SetPrintDebugInformation(vtkPythonInterpreter::GetPythonVerboseFlag() > 1);
std::string path = locator->Locate(vtkdir, prefixes, "vtk/__init__.py");
std::string path = locator->Locate(vtkdir, prefixes, "vtkmodules/__init__.py");
if (!path.empty())
{
vtkSafePrependPythonPath(path);
......
......@@ -7,7 +7,7 @@ include(vtkModuleMacrosPython)
# The RELATIVE make vtk_module_python_package() preserve the vtk/module package
# structure when building/installing. Otherwise, we'd just get the "web"
# package.
vtk_module_python_package(${vtk-module} "vtk/web"
vtk_module_python_package(${vtk-module} "vtkmodules/web"
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}")
if(BUILD_TESTING)
......
......@@ -276,21 +276,21 @@ unset(configured_py_files)
foreach(module IN LISTS VTK_PYTHON_MODULES_AND_KITS)
set(VTK_PYTHON_IMPORT_ALL
"${VTK_PYTHON_IMPORT_ALL}from .${module} import *\n")
configure_file(vtk/module.py.in
"${CMAKE_CURRENT_BINARY_DIR}/vtk/${module}.py" @ONLY)
list(APPEND configured_py_files "${CMAKE_CURRENT_BINARY_DIR}/vtk/${module}.py")
configure_file(vtkmodules/module.py.in
"${CMAKE_CURRENT_BINARY_DIR}/vtkmodules/${module}.py" @ONLY)
list(APPEND configured_py_files "${CMAKE_CURRENT_BINARY_DIR}/vtkmodules/${module}.py")
endforeach()
configure_file(vtk/__init__.py.in
"${CMAKE_CURRENT_BINARY_DIR}/vtk/__init__.py" @ONLY)
list(APPEND configured_py_files "${CMAKE_CURRENT_BINARY_DIR}/vtk/__init__.py")
configure_file(vtkmodules/all.py.in
"${CMAKE_CURRENT_BINARY_DIR}/vtkmodules/all.py" @ONLY)
list(APPEND configured_py_files "${CMAKE_CURRENT_BINARY_DIR}/vtkmodules/all.py")
# Kit module adapters
foreach(kit IN LISTS vtk_kits)
set(_module_kit ${kit}${VTK_KIT_SUFFIX})
foreach(dep IN LISTS _${kit}_modules)
configure_file(vtk/kit_module__init__.py.in
"${CMAKE_CURRENT_BINARY_DIR}/vtk/${dep}.py" @ONLY)
list(APPEND configured_py_files "${CMAKE_CURRENT_BINARY_DIR}/vtk/${dep}.py")
configure_file(vtkmodules/kit_module.py.in
"${CMAKE_CURRENT_BINARY_DIR}/vtkmodules/${dep}.py" @ONLY)
list(APPEND configured_py_files "${CMAKE_CURRENT_BINARY_DIR}/vtkmodules/${dep}.py")
endforeach()
unset(_module_kit)
endforeach()
......@@ -298,14 +298,15 @@ endforeach()
# Now copy configured files to build-cfg specific dir.
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copy-complete"
COMMAND ${CMAKE_COMMAND}
-E copy_directory "${CMAKE_CURRENT_BINARY_DIR}/vtk" "${VTK_BUILD_PYTHON_MODULES_DIR}/vtk"
-E copy_directory "${CMAKE_CURRENT_BINARY_DIR}/vtkmodules" "${VTK_BUILD_PYTHON_MODULES_DIR}/vtkmodules"
COMMAND ${CMAKE_COMMAND}
-E touch "${CMAKE_CURRENT_BINARY_DIR}/copy-complete"
DEPENDS ${configured_py_files})
# Build all py files that form the `vtk` package.
vtk_python_package(vtkpython_pyc vtk DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copy-complete")
vtk_python_package(vtkpython_pyc vtkmodules DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copy-complete")
vtk_python_module(vtk_python_module vtk.py)
# Let's add a target that generates the `vtk` python package
# including all the platform dependent and independent modules.
......
import compileall
compileall.compile_dir('@VTK_BINARY_DIR@/Wrapping/Python')
file = open('@VTK_BINARY_DIR@/Wrapping/Python/vtk_compile_complete', 'w')
file.write('Done')
"""This is the vtk module."""
from vtkmodules.all import *
......@@ -681,4 +681,3 @@ if __name__ == "__main__":
# Test with the above trivial sample test.
main( [ (SampleTest, 'test') ] )
......@@ -368,4 +368,3 @@ if __name__ == "__main__":
button.pack(fill='x')
frame.mainloop()
......@@ -470,4 +470,3 @@ def vtkRenderWidgetConeExample():
if __name__ == "__main__":
vtkRenderWidgetConeExample()
......@@ -400,4 +400,3 @@ def vtkRenderWindowInteractorConeExample():
if __name__ == "__main__":
vtkRenderWindowInteractorConeExample()
......@@ -235,4 +235,3 @@ def vtkVariantEqual(s1, s2):
Return true if s1 == s2.
"""
return (vtk.vtkVariant(s1) == vtk.vtkVariant(s2))
......@@ -703,4 +703,3 @@ def wxVTKRenderWindowInteractorConeExample():
if __name__ == "__main__":
wxVTKRenderWindowInteractorConeExample()
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