1{
2 stdenv,
3 lib,
4 buildPythonPackage,
5 fetchPypi,
6 isPy3k,
7 installShellFiles,
8 attrs,
9 click,
10 construct,
11 construct-classes,
12 ecdsa,
13 hidapi,
14 libusb1,
15 mnemonic,
16 pillow,
17 protobuf,
18 requests,
19 shamir-mnemonic,
20 simple-rlp,
21 typing-extensions,
22 trezor-udev-rules,
23 pytestCheckHook,
24}:
25
26buildPythonPackage rec {
27 pname = "trezor";
28 version = "0.13.8";
29 format = "setuptools";
30
31 disabled = !isPy3k;
32
33 src = fetchPypi {
34 inherit pname version;
35 hash = "sha256-Y01O3fNWAyV8MhYY2FSMajWyc4Rle2XjsL261jWlfP8=";
36 };
37
38 nativeBuildInputs = [ installShellFiles ];
39
40 propagatedBuildInputs = [
41 attrs
42 click
43 construct
44 construct-classes
45 ecdsa
46 hidapi
47 libusb1
48 mnemonic
49 pillow
50 protobuf
51 requests
52 shamir-mnemonic
53 simple-rlp
54 typing-extensions
55 ] ++ lib.optionals stdenv.isLinux [ trezor-udev-rules ];
56
57 nativeCheckInputs = [ pytestCheckHook ];
58
59 disabledTestPaths = [
60 "tests/test_stellar.py" # requires stellar-sdk
61 "tests/test_firmware.py" # requires network downloads
62 ];
63
64 pythonImportsCheck = [ "trezorlib" ];
65
66 postCheck = ''
67 $out/bin/trezorctl --version
68 '';
69
70 postFixup = ''
71 mkdir completions
72 _TREZORCTL_COMPLETE=source_bash $out/bin/trezorctl > completions/trezorctl || true
73 _TREZORCTL_COMPLETE=source_zsh $out/bin/trezorctl > completions/_trezorctl || true
74 _TREZORCTL_COMPLETE=source_fish $out/bin/trezorctl > completions/trezorctl.fish || true
75 installShellCompletion --bash completions/trezorctl
76 installShellCompletion --zsh completions/_trezorctl
77 installShellCompletion --fish completions/trezorctl.fish
78 '';
79
80 meta = with lib; {
81 description = "Python library for communicating with Trezor Hardware Wallet";
82 mainProgram = "trezorctl";
83 homepage = "https://github.com/trezor/trezor-firmware/tree/master/python";
84 license = licenses.gpl3;
85 maintainers = with maintainers; [
86 np
87 prusnak
88 mmahut
89 ];
90 };
91}