greatscottgadgets / libgreat

a library to help you do Great things
BSD 3-Clause "New" or "Revised" License
31 stars 25 forks source link

Set DYLD_FALLBACK_LIBRARY_PATH on macOS #41

Closed cdwilson closed 4 months ago

cdwilson commented 4 months ago

Potential fix for https://github.com/greatscottgadgets/cynthion/issues/136

Homebrew patches it's own python so that ctypes.find_library can find libraries also installed by homebrew. When using a version of python not installed by Homebrew, this sets DYLD_FALLBACK_LIBRARY_PATH so that the homebrew-installed libusb library is found.

I tested this on my ARM Mac, but I don't have an Intel Mac to test this with. Can somebody with an Intel Mac try this out and see if it also works for them?

depili commented 4 months ago

Should this also check the existence of the the homebrew environment variable?

martinling commented 4 months ago

I feel like it might be better to warn the user if the libusb dylib isn't found, and give them advice on fixing that, rather than just tweaking the search path internally in libgreat (or in any of our other Python projects).

Otherwise you get a quite confusing situation where scripts using our libraries will work, but other software, or users' own scripts using pyusb or libusb1 directly, will not work.

cdwilson commented 4 months ago

@martinling that makes sense, I'll close this out in favor of what you are suggesting.