1{ stdenv, libusb1, udev, fetchPypi, buildPythonPackage, cython }:
2
3buildPythonPackage rec {
4 name = "${pname}-${version}";
5 pname = "hidapi";
6 version = "0.7.99.post20";
7
8 src = fetchPypi {
9 inherit pname version;
10 sha256 = "1k7z5m7xsqy8j4qkjy4pfxdx4hm36ha68vi65z6smvnyg4zgv22z";
11 };
12
13 propagatedBuildInputs = [ libusb1 udev cython ];
14
15 # Fix the USB backend library lookup
16 postPatch = ''
17 libusb=${libusb1.dev}/include/libusb-1.0
18 test -d $libusb || { echo "ERROR: $libusb doesn't exist, please update/fix this build expression."; exit 1; }
19 sed -i -e "s|/usr/include/libusb-1.0|$libusb|" setup.py
20 '';
21
22 meta = with stdenv.lib; {
23 description = "A Cython interface to the hidapi from https://github.com/signal11/hidapi";
24 homepage = https://github.com/trezor/cython-hidapi;
25 # license can actually be either bsd3 or gpl3
26 # see https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt
27 license = licenses.bsd3;
28 maintainers = with maintainers; [ np ];
29 };
30}