1 { lib, stdenv, libusb1, udev, darwin, fetchPypi, buildPythonPackage, cython }:
3 buildPythonPackage rec {
9 sha256 = "a1170b18050bc57fae3840a51084e8252fd319c0fc6043d68c8501deb0e25846";
12 propagatedBuildInputs =
13 lib.optionals stdenv.isLinux [ libusb1 udev ] ++
14 lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ AppKit CoreFoundation IOKit ]) ++
17 # Fix the USB backend library lookup
18 postPatch = lib.optionalString stdenv.isLinux ''
19 libusb=${libusb1.dev}/include/libusb-1.0
20 test -d $libusb || { echo "ERROR: $libusb doesn't exist, please update/fix this build expression."; exit 1; }
21 sed -i -e "s|/usr/include/libusb-1.0|$libusb|" setup.py
22 '' + lib.optionalString stdenv.isDarwin ''
23 substituteInPlace setup.py --replace 'macos_sdk_path =' 'macos_sdk_path = "" #'
26 pythonImportsCheck = [ "hid" ];
29 description = "A Cython interface to the hidapi from https://github.com/libusb/hidapi";
30 homepage = "https://github.com/trezor/cython-hidapi";
31 # license can actually be either bsd3 or gpl3
32 # see https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt
33 license = licenses.bsd3;
34 maintainers = with maintainers; [ np prusnak ];