3 ms·
Maybe it's possible to patch the dependency? For example, for Node.js / npm, there are automated ways to do this, like [patch-package](https://www.npmjs.com/pac
by kosinus 4y ago
Maybe it's possible to patch the dependency? For example, for Node.js / npm, there are automated ways to do this, like [patch-package](https://www.npmjs.com/package/patch-package https://www.npmjs.com/package/patch-package). Does Python / pip have something similar?
- hynek 4y agoYou mean at the Python driver level? Unfortunately, that doesn't work with ctypes. I've tried it by adding the DYLD_LIBRARY_PATH to os.environ before calling ctypes.LibraryLoader.LoadLibrary (https://docs.python.org/3/library/ctypes.html#ctypes.LibraryLoader https://docs.python.org/3/library/ctypes.html#ctypes.Library...) and it didn't work. I suspect ctypes gets somehow initialized much sooner and adding environment variables in your apps doesn't help. TBH I didn't research it further, since the problems of the post are more general and it can happen that you trip into them regardless of runtime.
- orf 4y agoHere’s the relevant source: https://github.com/python/cpython/blob/8dd2766d99f8f51ad62dc0fde8282483590c6cd0/Lib/ctypes/__init__.py#L458 https://github.com/python/cpython/blob/8dd2766d99f8f51ad62dc... I believe you should just be able to replace the library name with an absolute path to the library, and remove the need for the lookup at all?
- hynek 4y agoRight, but that would take some really deep patching of code I don't control, just so it works in development. If this were a production issue, I would probably fork the driver and do what you're suggesting (it's not like it's actively maintained or something :|).
- orf 4y agoWhy not fork it? If only to have the code under your control in case it abruptly becomes inaccessible. Then the fix is a single if statement. Seems worth it to me.