Commit 881e17d3 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

Fixing static python to import modules on demand.

Fixing vtkPythonAppInit to import statically linked modules when first called
rather than immediately after intialization. This was an oversight during the
changes to cleanup static python builds.

Change-Id: I2a2155c9c4d0d3109f44dafd1cf0f75b1d7f8cc6
parent 5b4e5032
......@@ -105,8 +105,10 @@ function(vtk_write_python_modules_header filename)
if (NOT BUILD_SHARED_LIBS)
# fill in the init functions only when BUILD_SHARED_LIBS is OFF.
foreach (module ${ARGN})
set (EXTERN_DEFINES "${EXTERN_DEFINES}\n void init${module}Python();")
set (INIT_CALLS "${INIT_CALLS}\n init${module}Python();")
set (EXTERN_DEFINES "${EXTERN_DEFINES}\n extern void init${module}Python();")
set (INIT_CALLS "${INIT_CALLS}\n
static char name${module}[] = \"${module}Python\";
PyImport_AppendInittab(name${module}, init${module}Python);")
endforeach()
endif()
......
......@@ -131,14 +131,13 @@ int main(int argc, char **argv)
strcpy(argv0, av0.c_str());
Py_SetProgramName(argv0);
// This function is generated, and will register any static Python modules for VTK
// This needs to be done *before* Py_Initialize().
CMakeLoadAllPythonModules();
// Initialize interpreter.
Py_Initialize();
// This function is generated, and will load any static Python modules for VTK
// This needs to be done *after* Py_Initialize().
CMakeLoadAllPythonModules();
// Initialize python thread support. This function should first be
// called from the main thread, after Py_Initialize.
#ifndef VTK_NO_PYTHON_THREADS
......
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