1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchPypi,
6 pkg-config,
7 xcbuild,
8 cython,
9 setuptools,
10 hidapi,
11 libusb1,
12 udev,
13}:
14
15buildPythonPackage rec {
16 pname = "hidapi";
17 version = "0.14.0.post4";
18 pyproject = true;
19
20 src = fetchPypi {
21 inherit pname version;
22 hash = "sha256-SPziU+Um0XtmP7+ZicccfvdlPO1fS+ZfFDfDE/s9vfY=";
23 };
24
25 build-system = [
26 cython
27 setuptools
28 ];
29
30 nativeBuildInputs = [ pkg-config ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ];
31
32 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
33 hidapi
34 libusb1
35 ];
36
37 env = lib.optionalAttrs stdenv.hostPlatform.isLinux {
38 HIDAPI_SYSTEM_HIDAPI = true;
39 };
40
41 propagatedBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ udev ];
42
43 pythonImportsCheck = [ "hid" ];
44
45 meta = with lib; {
46 description = "Cython interface to the hidapi from https://github.com/libusb/hidapi";
47 homepage = "https://github.com/trezor/cython-hidapi";
48 # license can actually be either bsd3 or gpl3
49 # see https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt
50 license = with licenses; [
51 bsd3
52 gpl3Only
53 ];
54 maintainers = with maintainers; [
55 np
56 prusnak
57 ];
58 };
59}