From adf5888faf52249c3256ff29ae43753bc486e325 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Wed, 18 Nov 2020 13:02:15 -0600 Subject: [PATCH 1/3] Fix libffi not found --- src/runner/pythonrunner.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 0924e7f..5f82d52 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -1254,15 +1254,19 @@ 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__"); mainNamespace["sys"] = bpy::import("sys"); mainNamespace["moprivate"] = bpy::import("moprivate"); mainNamespace["mobase"] = bpy::import("mobase"); bpy::import("site"); - bpy::exec("sys.stdout = moprivate.PrintWrapper()\n" + bpy::exec(("import os\n" + "sys.stdout = moprivate.PrintWrapper()\n" "sys.stderr = moprivate.ErrWrapper.instance()\n" - "sys.excepthook = lambda x, y, z: sys.__excepthook__(x, y, z)\n", + "sys.excepthook = lambda x, y, z: sys.__excepthook__(x, y, z)\n" + "os.add_dll_directory('" + dlls + "')").c_str(), mainNamespace); configure_python_logging(mainNamespace["mobase"]); From d9243bb6177e40abaa69094c563de788dc60e3eb Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Wed, 18 Nov 2020 13:37:54 -0600 Subject: [PATCH 2/3] Better --- src/runner/pythonrunner.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 5f82d52..9dd85f7 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -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(); From 9a10c01cc08f356bba163a996a9531c1f56c10cd Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Wed, 18 Nov 2020 14:30:40 -0600 Subject: [PATCH 3/3] lamb-da --- src/runner/pythonrunner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 9dd85f7..d482124 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -1264,7 +1264,7 @@ bool PythonRunner::initPython(const QString &pythonPath) bpy::import("site"); bpy::exec("sys.stdout = moprivate.PrintWrapper()\n" "sys.stderr = moprivate.ErrWrapper.instance()\n" - "sys.excepthook = sys.__excepthook__\n", + "sys.excepthook = lambda x, y, z: sys.__excepthook__(x, y, z)\n", mainNamespace); // add dlls directory