.. contents::
A Cython interface to HIDAPI <https://github.com/libusb/hidapi>
_ library.
This has been tested with:
TREZOR <https://trezor.io/>
_ Hardware WalletIt works on Linux, Windows and macOS.
Python <http://python.org>
_Cython <http://cython.org>
_cython-hidapi may be used by one of three licenses as outlined in LICENSE.txt
::
$ sudo apt-get install python-dev libusb-1.0-0-dev libudev-dev
$ sudo pip install --upgrade setuptools
$ sudo pip install hidapi
For other download options visit the PyPi page <https://pypi.python.org/pypi/hidapi/>
_.
Download cython-hidapi archive::
$ git clone --recursive https://github.com/trezor/cython-hidapi.git $ cd cython-hidapi
Build cython-hidapi extension module::
$ python setup.py build
On Linux, the hidraw API is now used by default, and the libusb API is not included. That is, --without-libusb is now the default behavior. To force the use of the libusb API instead, use the --with-libusb option::
$ python setup.py build --with-libusb
Or you can also use the environment variable::
$ export HIDAPI_WITH_LIBUSB=1 $ python setup.py build
Install cython-hidapi module into your Python distribution::
$ sudo python setup.py install
Alternatively, you can run pip directly, which will call the necessary build and install commands::
$ pip install -e .
Test install::
$ python
import hid
Try example script::
$ python try.py
For correct functionality under Linux, you need to create a rule file similar
to this one <https://raw.githubusercontent.com/trezor/trezor-common/master/udev/51-trezor.rules>
_
in your udev rules directory.
Also you might need to call udevadm control --reload-rules
to reload the rules.
Documentation can be built using Sphinx::
$ cd docs && make html
The HTML output will be in docs/_build/html
.
The documentation is extracted from the code using autodoc
.
Note that the build output is used. So rebuilt the package before generating documentation.
Built documentation is also deployed to: https://trezor.github.io/cython-hidapi/ <https://trezor.github.io/cython-hidapi/>
_.