This commit is contained in:
Qudix
2020-11-18 13:37:54 -06:00
parent adf5888faf
commit d9243bb617
+10 -8
View File
@@ -1254,21 +1254,23 @@ bool PythonRunner::initPython(const QString &pythonPath)
PySys_SetArgv(0, (wchar_t**)&argBuffer);
const auto dlls = QCoreApplication::applicationDirPath().toStdString() + "/dlls";
bpy::object mainModule = bpy::import("__main__");
bpy::object mainNamespace = mainModule.attr("__dict__");
auto os = bpy::import("os");
auto mainModule = bpy::import("__main__");
auto mainNamespace = mainModule.attr("__dict__");
mainNamespace["os"] = os;
mainNamespace["sys"] = bpy::import("sys");
mainNamespace["moprivate"] = bpy::import("moprivate");
mainNamespace["mobase"] = bpy::import("mobase");
bpy::import("site");
bpy::exec(("import os\n"
"sys.stdout = moprivate.PrintWrapper()\n"
bpy::exec("sys.stdout = moprivate.PrintWrapper()\n"
"sys.stderr = moprivate.ErrWrapper.instance()\n"
"sys.excepthook = lambda x, y, z: sys.__excepthook__(x, y, z)\n"
"os.add_dll_directory('" + dlls + "')").c_str(),
"sys.excepthook = sys.__excepthook__\n",
mainNamespace);
// add dlls directory
const auto dlls = QCoreApplication::applicationDirPath().toStdString() + "/dlls";
os.attr("add_dll_directory")(dlls);
configure_python_logging(mainNamespace["mobase"]);
PyEval_SaveThread();