Skip to content

Support homebrew libusb on macOS #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2022

Conversation

cdwilson
Copy link
Contributor

@cdwilson cdwilson commented Mar 4, 2022

For macOS running on Apple Silicon, installing libusb via homebrew (brew install libusb) installs the libraries to /opt/homebrew/lib/. Older versions of python (e.g. 3.7 installed via pyenv) won't be able to find the homebrew libusb libraries. When trying to use a device like the GreatFET One that uses pyusb, bin/detect.py will throw an error like this:

❯ bin/detect.py 
Traceback (most recent call last):
  File "bin/detect.py", line 35, in <module>
    print("Chip id: ", detector.chip.id)
  File "/Users/chris/Projects/Adafruit_Python_PlatformDetect/adafruit_platformdetect/chip.py", line 138, in id
    if usb.core.find(idVendor=0x1D50, idProduct=0x60E6) is not None:
  File "/Users/chris/.pyenv/versions/test-platformdetect/lib/python3.7/site-packages/usb/core.py", line 1309, in find
    raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available

This PR just adds the homebrew libusb path to the macOS DYLD fallback library search path:

❯ bin/detect.py 
Chip id:  LPC4330
Board id:  GREATFET_ONE
...
Is this an OS environment variable special case? True

@cdwilson cdwilson force-pushed the support-homebrew-libusb branch from 35319c4 to 53ed144 Compare March 5, 2022 00:08
Copy link
Collaborator

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@makermelissa makermelissa merged commit 1096b73 into adafruit:main Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants