apmorton / pyhidapi

hidapi bindings in ctypes
MIT License
112 stars 42 forks source link

Add MinGW hidapi library name #22

Closed EchterAgo closed 5 years ago

EchterAgo commented 5 years ago

This adds the correct library name to make it work on MinGW.

apmorton commented 5 years ago

Is this for native python loading a hidapi dll built with mingw?

That doesn't sound like a great idea, especially considering the signal11 hidapi specifically supports being built with msvc on windows.

Maybe there is some other motivating case here I am missing?

EchterAgo commented 5 years ago

No, it is for MinGW python loading a MinGW hidapi dll. pip install hid in MSYS2 results in an install that is not working, even though mingw-w64-x86_64-hidapi is installed.

$ pip install hid
Collecting hid
  Downloading https://files.pythonhosted.org/packages/45/36/6c6f8403b0c892f9b8c4a6bb32970a817904b8eb48d932120f8f1c0e93b9/hid-1.0.0.tar.gz
Installing collected packages: hid
  Running setup.py install for hid ... done
Successfully installed hid-1.0.0

axel@AgoDesk MINGW64 ~
$ python
Python 3.7.2 (default, Dec 26 2018, 08:10:46)
[GCC 7.4.0] on msys
Type "help", "copyright", "credits" or "license" for more information.
>>> import hid
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/hid/__init__.py", line 29, in <module>
    raise ImportError(error)
ImportError: Unable to load any of the following libraries:libhidapi-hidraw.so libhidapi-hidraw.so.0 libhidapi-libusb.so libhidapi-libusb.so.0 libhidapi-iohidmanager.so libhidapi-iohidmanager.so.0 libhidapi.dylib hidapi.dll
>>>

axel@AgoDesk MINGW64 ~
$ pacman -Ql mingw-w64-x86_64-hidapi
mingw-w64-x86_64-hidapi /mingw64/
mingw-w64-x86_64-hidapi /mingw64/bin/
mingw-w64-x86_64-hidapi /mingw64/bin/libhidapi-0.dll
mingw-w64-x86_64-hidapi /mingw64/include/
mingw-w64-x86_64-hidapi /mingw64/include/hidapi/
mingw-w64-x86_64-hidapi /mingw64/include/hidapi/hidapi.h
mingw-w64-x86_64-hidapi /mingw64/lib/
mingw-w64-x86_64-hidapi /mingw64/lib/libhidapi.a
mingw-w64-x86_64-hidapi /mingw64/lib/libhidapi.dll.a
mingw-w64-x86_64-hidapi /mingw64/lib/pkgconfig/
mingw-w64-x86_64-hidapi /mingw64/lib/pkgconfig/hidapi.pc
mingw-w64-x86_64-hidapi /mingw64/share/
mingw-w64-x86_64-hidapi /mingw64/share/doc/
mingw-w64-x86_64-hidapi /mingw64/share/doc/hidapi/
mingw-w64-x86_64-hidapi /mingw64/share/doc/hidapi/AUTHORS.txt
mingw-w64-x86_64-hidapi /mingw64/share/doc/hidapi/LICENSE-bsd.txt
mingw-w64-x86_64-hidapi /mingw64/share/doc/hidapi/LICENSE-gpl3.txt
mingw-w64-x86_64-hidapi /mingw64/share/doc/hidapi/LICENSE-orig.txt
mingw-w64-x86_64-hidapi /mingw64/share/doc/hidapi/LICENSE.txt
mingw-w64-x86_64-hidapi /mingw64/share/doc/hidapi/README.txt

With this patch it is working.

apmorton commented 5 years ago

Thanks for the explanation - I will merge and push a release to pypi when I am at my desk next.