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