Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / python-modules / hidapi / default.nix
blob790e7aa08fc23d40a88e7e3012af172a844095a9
1 { lib, stdenv, libusb1, udev, darwin, fetchPypi, buildPythonPackage, cython }:
3 buildPythonPackage rec {
4   pname = "hidapi";
5   version = "0.10.1";
7   src = fetchPypi {
8     inherit pname version;
9     sha256 = "a1170b18050bc57fae3840a51084e8252fd319c0fc6043d68c8501deb0e25846";
10   };
12   propagatedBuildInputs =
13     lib.optionals stdenv.isLinux [ libusb1 udev ] ++
14     lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ AppKit CoreFoundation IOKit ]) ++
15     [ cython ];
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 = "" #'
24   '';
26   pythonImportsCheck = [ "hid" ];
28   meta = with lib; {
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 ];
35   };