Skip to content

Python environment improvements

This MR has multiple fixes.

  1. Each VTK module generates a Python module library named ${vtk-module}Python.[pyd|so|dylib]. This was built in the same location as the other libraries, but installed in the vtk Python package. We now make it consistent. These are not built under the vtk Python package itself.
  2. CMake variables VTK_INSTALL_PYTHON_MODULE_DIR and VTK_BUILD_PYTHON_MODULE_DIR are no longer supported. Instead, folks can set VTK_PYTHON_SITE_PACKAGES_SUFFIX, if needed to customize where the vtk Python package (and other Python packages) are built. VTK_PYTHON_SITE_PACKAGES_SUFFIX is initialized to Lib/site-packages on Windows, and python-${python-version}/site-packages on *nixes. Thus the Python packages ultimately end up in <prefix>/bin/Lib/site-packages on Windows and <prefix>/lib/python-${python-version}/site-packages on *nixes, where <prefix> is the install prefix for installs and VTK_BINARY_DIR for builds.
  3. vtkpython/pvtkpython use vtkPythonInterpreter. This avoids duplicating logic for locating VTK Python modules between VTK executables and other applications using VTK.
  4. For HPC use-cases with non-standard Python, vtkPythonInterpreter would end up picking incorrect standard Python library modules unless PYTHONHOME was explicitly set. To avoid that, vtkPythonInterpreter now call Py_SetProgramName with a executable location derived from the python library VTK links against. (thanks to @chuck.atkins).
  5. vtkPythonInterpreter now locates vtk Python package paths relative to the VTK libs. This makes it more robust for other apps using VTK since they don't need any extra logic to help the vtkPythonInterpreter find VTK package.
  6. vtkpython and pvtkpython now support standard python command line arguments -v and -vv to print information about paths looked up when trying to locate VTK Python modules
  7. vtk Python package is now built and installed using rules similar to other Python-only modules in VTK.
Edited by Utkarsh Ayachit

Merge request reports