Closed lighterowl closed 1 year ago
Thanks
I think I hit the same issue when I tried to update pyside6.
I presume that
wpathname
might not be a fully qualified path at the timeLoadLibraryEx
is called but I have not checked this myself.
I think you are correct, as MSYSTEM= python3 -c "import cmake_example"
works. Likely LoadLibraryEx only considers paths using backslashes as fully qualified (??). So we need to normalize the path separators when building the path to load.
Thanks for the nice reproducer.
@xavery the fix is in the MSYS2 repo now
It's not possible to load
pyd
s which depend on other non-system DLLs, even if those DLLs are located in the same directory as thepyd
.mingw-w64-x86_64-python
version is3.11.4-6
, which includes the patches introduced in #144 .A minimal example using cmake and pybind11 is here : https://github.com/xavery/pybind-with-dll . It's essentially a minified https://github.com/pybind/cmake_example but with an extra DLL in between.
Building this with said
mingw-w64-x86_64-python
gives :Setting
PYTHONLEGACYWINDOWSDLLLOADING=1
works.This should still work without this variable being defined, though, as the flags passed to
LoadLibraryEx
indynload_win.c
includeLOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
, which should add the originally loaded DLL's directory to the search path :I presume that
wpathname
might not be a fully qualified path at the timeLoadLibraryEx
is called but I have not checked this myself.If you consider this working as desired, please consider removing
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
from the flags passed toLoadLibraryEx
as it's misleading and hints that it should be possible to load the dependencies from the directory even without callingAddDllDirectory
(or its Python wrapper) explicitly.Thanks.