Commit ea6b4948 authored by David C. Lonie's avatar David C. Lonie
Browse files

Allow the python interpretor used by RenderingMatplotlib to change.

This patch allows users to specify a python environment for the
Matplotlib MathText renderer to use via the VTK_MATPLOTLIB_PYTHONINTERP
variable.

This is needed for the ParaView superbuild.

Change-Id: If588b1dff13dba7e8f3637d46baa79cbf7749d75
parent 159e26e6
......@@ -31,9 +31,12 @@
#include "vtkObjectFactory.h"
#include "vtkPath.h"
#include "vtkPoints.h"
#include "vtkStdString.h"
#include "vtkTextProperty.h"
#include "vtkTransform.h"
#include <vtksys/SystemTools.hxx>
#include <vector>
// Smart pointer for PyObjects. Calls Py_XDECREF when scope ends.
......@@ -80,7 +83,20 @@ vtkMatplotlibMathTextUtilities* vtkMatplotlibMathTextUtilities::New()
case vtkMatplotlibMathTextUtilities::AVAILABLE:
break;
case vtkMatplotlibMathTextUtilities::NOT_TESTED:
Py_Initialize();
// Initialize the python interpretor if needed
if (!Py_IsInitialized())
{
// Check for a specified interpreter in the system environment.
vtkStdString mplPyInterp;
if (vtksys::SystemTools::GetEnv("VTK_MATPLOTLIB_PYTHONINTERP",
mplPyInterp) &&
mplPyInterp.size() != 0)
{
Py_SetProgramName(const_cast<char*>(mplPyInterp.c_str()));
}
Py_Initialize();
}
if (PyErr_Occurred() ||
!PyImport_ImportModule("matplotlib") ||
PyErr_Occurred())
......
......@@ -16,6 +16,10 @@
// .SECTION Description
// vtkMatplotlibMathTextUtilities provides access to the MatPlotLib MathText
// implementation.
//
// The python interpretor used by this class can be specified by setting the
// VTK_MATPLOTLIB_PYTHONINTERP environment variable. This will be passed to
// Py_SetProgramName prior to calling Py_Initialize.
#ifndef __vtkMatplotlibMathTextUtilities_h
#define __vtkMatplotlibMathTextUtilities_h
......
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