Commit ea6cc393 authored by T.J. Corona's avatar T.J. Corona

Check SMTK_PYTHON_MODULE_LOAD_VERBOSE env when loading py modules

parent 34a53d78
...@@ -50,6 +50,7 @@ SMTK_THIRDPARTY_POST_INCLUDE ...@@ -50,6 +50,7 @@ SMTK_THIRDPARTY_POST_INCLUDE
// if it is not included before the stl headers our header file includes. // if it is not included before the stl headers our header file includes.
#include "smtk/common/PythonInterpreter.h" #include "smtk/common/PythonInterpreter.h"
#include "smtk/common/Environment.h"
#include "smtk/common/Paths.h" #include "smtk/common/Paths.h"
#include <cstdlib> #include <cstdlib>
...@@ -258,9 +259,17 @@ bool PythonInterpreter::canFindModule(const std::string& module) const ...@@ -258,9 +259,17 @@ bool PythonInterpreter::canFindModule(const std::string& module) const
std::stringstream testCmd; std::stringstream testCmd;
testCmd << "found = True\n" testCmd << "found = True\n"
<< "try:\n" << "try:\n"
<< " import " << module << "\n" << " import " << module << "\n";
<< "except ImportError:\n" if (Environment::hasVariable("SMTK_PYTHON_MODULE_LOAD_VERBOSE"))
<< " found = False"; {
testCmd << "except ImportError as error:\n"
<< " print(str(error))\n";
}
else
{
testCmd << "except ImportError:\n";
}
testCmd << " found = False";
pybind11::exec(testCmd.str().c_str(), pybind11::globals(), locals); pybind11::exec(testCmd.str().c_str(), pybind11::globals(), locals);
found = locals["found"].cast<bool>(); found = locals["found"].cast<bool>();
......
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