trezor / cython-hidapi

:snake: Python wrapper for the HIDAPI
Other
288 stars 110 forks source link

0.10.0 release fails to load on macOS #97

Closed flit closed 4 years ago

flit commented 4 years ago

The 0.10.0 release of cython-hidapi causes an ImportError exception to be raised when imported on macOS 10.15. Tested with both Python 3.8.6 and 3.9.0 (same exception in both).

>>> import hid
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Volumes/projects/pyOCD-flit/venv/mac38/lib/python3.8/site-packages/hid.cpython-38-darwin.so, 2): Symbol not found: _NSAppKitVersionNumber
  Referenced from: /Volumes/projects/pyOCD-flit/venv/mac38/lib/python3.8/site-packages/hid.cpython-38-darwin.so
  Expected in: flat namespace
 in /Volumes/projects/pyOCD-flit/venv/mac38/lib/python3.8/site-packages/hid.cpython-38-darwin.so
prusnak commented 4 years ago

Maybe @canselcik has an idea?

flit commented 4 years ago

It does seem to be related to upstream hidapi. A version of cython-hidapi built from a June 2020 commit imports fine. Starting a bisect now…

flit commented 4 years ago

d824d96 pulls in the afflicted upstream hidapi.

flit commented 4 years ago

libusb/hidapi@cdc473d is the upstream commit that adds an extern reference to NSAppKitVersionNumber. This requires the addition of linking to AppKit. Since that's missing in cython-hidapi, the linker assumes the extern reference will be resolved by the environment into which the shared lib is loaded (flat-namespace).

I'll try to put together a patch.

prusnak commented 4 years ago

Released 0.10.0.post1 with the fix. Thanks!