Skip to content

Commit 711ec7e

Browse files
committed
Fix DLL loading for libexpat on windows
1 parent ed2296e commit 711ec7e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Libs/Application/Job/PythonWorker.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ using namespace pybind11::literals; // to bring in the `_a` literal
1616
#include <QThread>
1717
#include <iostream>
1818

19+
#ifdef _WIN32
20+
#include <windows.h>
21+
#endif
22+
1923
namespace shapeworks {
2024

2125
//---------------------------------------------------------------------------
@@ -207,6 +211,21 @@ bool PythonWorker::init() {
207211

208212
qputenv("PATH", path.toUtf8());
209213
SW_LOG("Setting PATH for Python to: " + path.toStdString());
214+
215+
// Python 3.8+ requires explicit DLL directory registration
216+
// PATH environment variable is no longer used for DLL search
217+
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_USER_DIRS);
218+
219+
// Add the Library\bin directory where conda keeps DLLs like libexpat.dll
220+
QString library_bin = python_home + "/Library/bin";
221+
AddDllDirectory(library_bin.toStdWString().c_str());
222+
223+
// Also add the DLLs directory
224+
QString dlls_dir = python_home + "/DLLs";
225+
AddDllDirectory(dlls_dir.toStdWString().c_str());
226+
227+
// And the base python home
228+
AddDllDirectory(python_home.toStdWString().c_str());
210229
}
211230
#endif // ifdef _WIN32
212231

0 commit comments

Comments
 (0)