Skip to content

Commit ccce032

Browse files
committed
OSX: load shared libraries using RTLD_GLOBAL
- Sometimes this isn't needed, but to be safe just do it always
1 parent 46c5d1e commit ccce032

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

robotpy_build/wrapper.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,18 @@ def _write_libinit_py(self, libnames):
488488
init += "\n"
489489

490490
if libnames:
491-
init += "from ctypes import cdll\n\n"
491+
if self.platform.os == "osx":
492+
init += "from ctypes import CDLL, RTLD_GLOBAL\n\n"
493+
else:
494+
init += "from ctypes import cdll\n\n"
492495

493496
for libname in libnames:
494497
init += "try:\n"
495-
init += (
496-
f' _lib = cdll.LoadLibrary(join(_root, "lib", "{libname}"))\n'
497-
)
498+
if self.platform.os == "osx":
499+
init += f' _lib = CDLL(join(_root, "lib", "{libname}"), mode=RTLD_GLOBAL)\n'
500+
else:
501+
init += f' _lib = cdll.LoadLibrary(join(_root, "lib", "{libname}"))\n'
502+
498503
init += "except FileNotFoundError:\n"
499504
init += f' if not exists(join(_root, "lib", "{libname}")):\n'
500505
init += f' raise FileNotFoundError("{libname} was not found on your system. Is this package correctly installed?")\n'

0 commit comments

Comments
 (0)