Open hellik opened 3 years ago
Just wondering, maybe os.add_dll_directory() could be placed in lib/python/ctypes/loader.py
(7.8 branch) instead of gui/wxpython/wxgui.py
?
@petrasovaa any idea?
@petrasovaa any idea?
Well, I am not an expert on this, what @nilason suggests sounds reasonable. Here is my attempt, without any testing:
+++ b/python/grass/ctypes/loader.py
@@ -238,6 +238,12 @@ class _WindowsLibrary(object):
class WindowsLibraryLoader(LibraryLoader):
name_formats = ["%s.dll", "lib%s.dll"]
+ def __init__(self):
+ super().__init__()
+ for p in os.getenv("PATH").split(";"):
+ if os.path.exists(p) and hasattr(os, 'add_dll_directory'):
+ os.add_dll_directory(p)
+
def load(self, path):
return _WindowsLibrary(path)
I have no idea if it's necessary to add all the folders on PATH.
Can that also help with using ctypes-based components in external python scripts (e.g. in Jupyter):
https://pypi.org/project/grass-session/ for example uses the workaround here: https://github.com/zarch/grass-session/blob/6097f834be20ee0d703deb2af90f22d6dc66f368/grass_session/session.py#L332-L370
In any case it would be great to get that fixed one way or the other for packaging the next release on MS Windows, which is an important platform...
Will see if I can test Annas suggestion on MS Windows...
Describe the bug
taken from libgrass_gis.7.8 Not Found - OSGeo4W trac
fix see https://github.com/jef-n/OSGeo4W/commit/9443c34538aed62944f30db98867fa52ccdadf6c