Skip to content

Instantly share code, notes, and snippets.

@mmahut
Created January 2, 2020 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmahut/52f26af6b7d3c74efe62960e2abc399f to your computer and use it in GitHub Desktop.
Save mmahut/52f26af6b7d3c74efe62960e2abc399f to your computer and use it in GitHub Desktop.
mahut@highhopes ~/repo/nixpkgs (master) $ cat ./pkgs/development/python-modules/trezor/default.nix
{ lib, fetchPypi, buildPythonPackage, isPy3k, python, pytest
, typing-extensions
, protobuf
, hidapi
, ecdsa
, mnemonic
, requests
, pyblake2
, click
, construct
, libusb1
, rlp
, shamir-mnemonic
, trezor-udev-rules
}:
buildPythonPackage rec {
pname = "trezor";
version = "0.11.6";
disabled = !isPy3k;
src = fetchPypi {
inherit pname version;
sha256 = "1i73j812i0dgjw9n106pipc6qksd9cgs59d0as0b4j5iyl0087hh";
};
propagatedBuildInputs = [ typing-extensions protobuf hidapi ecdsa mnemonic requests pyblake2 click construct libusb1 rlp shamir-mnemonic trezor-udev-rules ];
checkInputs = [
pytest
];
# disable test_tx_api.py as it requires being online
checkPhase = ''
runHook preCheck
pytest --pyargs tests --ignore tests/test_tx_api.py
runHook postCheck
'';
meta = with lib; {
description = "Python library for communicating with TREZOR Bitcoin Hardware Wallet";
homepage = "https://github.com/trezor/trezor-firmware/tree/master/python";
license = licenses.gpl3;
maintainers = with maintainers; [ np prusnak mmahut maintainers."1000101" ];
};
}
mmahut@highhopes ~/repo/nixpkgs (master) $ nix-build -A python3Packages.trezor
/nix/store/ccxxnmqqdpbhrh6lmn0rpgp8dlwla6c5-python3.7-trezor-0.11.6
mmahut@highhopes ~/repo/nixpkgs (master) $
mmahut@highhopes ~/repo/trezor-firmware/python (master) $ cat default.nix
with import <nixpkgs> {};
let
python = let
packageOverrides = self: super: {
trezor = super.trezor.overridePythonAttrs(old: rec {
version = "master";
src = ./.;
});
};
in pkgs.python3.override {inherit packageOverrides; self = python;};
in python.withPackages(ps:[ps.trezor])
mmahut@highhopes ~/repo/trezor-firmware/python (master) $
mmahut@highhopes ~/repo/trezor-firmware/python (master) $ nix-build
these derivations will be built:
/nix/store/5yb2grbliap05yg3gn89yl9yn2l5ihcs-python3.7-trezor-master.drv
/nix/store/pgvmzvlffx86wjx6hvrnalrywdx5k669-python3-3.7.4-env.drv
building '/nix/store/5yb2grbliap05yg3gn89yl9yn2l5ihcs-python3.7-trezor-master.drv'...
Sourcing python-catch-conflicts-hook.sh
(...)
shrinking RPATHs of ELF executables and libraries in /nix/store/zba1l65idzhx14ibf8d8m2pjcqmxhlb7-python3.7-trezor-master
strip is /nix/store/cl1i6bfqnx48ipakj4px7pb1babzs23j-binutils-2.31.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/zba1l65idzhx14ibf8d8m2pjcqmxhlb7-python3.7-trezor-master/lib /nix/store/zba1l65idzhx14ibf8d8m2pjcqmxhlb7-python3.7-trezor-master/bin
patching script interpreter paths in /nix/store/zba1l65idzhx14ibf8d8m2pjcqmxhlb7-python3.7-trezor-master
checking for references to /build/ in /nix/store/zba1l65idzhx14ibf8d8m2pjcqmxhlb7-python3.7-trezor-master...
Rewriting #!/nix/store/k0igqpz995nmxwf6piyd5jjpcc7gcnyc-python3-3.7.4/bin/python3.7 to #!/nix/store/k0igqpz995nmxwf6piyd5jjpcc7gcnyc-python3-3.7.4
wrapping `/nix/store/zba1l65idzhx14ibf8d8m2pjcqmxhlb7-python3.7-trezor-master/bin/trezorctl'...
running install tests
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-5.1.0, py-1.8.0, pluggy-0.12.0
rootdir: /build/python
collected 0 items
============================ no tests ran in 0.00s =============================
ERROR: file or package not found: trezorlib.tests.unit_tests (missing __init__.py?)
builder for '/nix/store/5yb2grbliap05yg3gn89yl9yn2l5ihcs-python3.7-trezor-master.drv' failed with exit code 4
cannot build derivation '/nix/store/pgvmzvlffx86wjx6hvrnalrywdx5k669-python3-3.7.4-env.drv': 1 dependencies couldn't be built
error: build of '/nix/store/pgvmzvlffx86wjx6hvrnalrywdx5k669-python3-3.7.4-env.drv' failed
mmahut@highhopes ~/repo/trezor-firmware/python (master) $ git stash
Saved working directory and index state WIP on master: 95f8b6867 Drop pyargs
mmahut@highhopes ~/repo/trezor-firmware/python (master) $ cat default.nix
with import <nixpkgs> {};
let
python = let
packageOverrides = self: super: {
trezor = super.trezor.overridePythonAttrs(old: rec {
version = "master";
src = ./.;
doCheck = true; # set to false if you want to skip tests
checkPhase = ''
runHook preCheck
pytest tests/ --ignore tests/test_tx_api.py
runHook postCheck
'';
});
};
in pkgs.python3.override {inherit packageOverrides; self = python;};
in python.withPackages(ps:[ps.trezor])
mmahut@highhopes ~/repo/trezor-firmware/python (master) $
mmahut@highhopes ~/repo/trezor-firmware/python (master) $ nix-build
these derivations will be built:
/nix/store/cw6gmw2j468scsdqsc2dr99714m8zm4h-python3.7-trezor-master.drv
/nix/store/95afyzpl471ajbny9g8ag9iqwp7wr09g-python3-3.7.4-env.drv
building '/nix/store/cw6gmw2j468scsdqsc2dr99714m8zm4h-python3.7-trezor-master.drv'...
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
(...)
running install tests
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-5.1.0, py-1.8.0, pluggy-0.12.0
rootdir: /build/python
collected 54 items
tests/test_ckd_public.py . [ 1%]
tests/test_cosi.py ........... [ 22%]
tests/test_nem.py . [ 24%]
tests/test_protobuf_encoding.py .......... [ 42%]
tests/test_protobuf_misc.py ......... [ 59%]
tests/test_stellar.py ................... [ 94%]
tests/test_transport.py ... [100%]
=============================== warnings summary ===============================
/nix/store/fvb72plrbzl623lxb3ikqxsvayfibbfj-python3.7-trezor-master/lib/python3.7/site-packages/trezorlib/ckd_public.py:29
/nix/store/fvb72plrbzl623lxb3ikqxsvayfibbfj-python3.7-trezor-master/lib/python3.7/site-packages/trezorlib/ckd_public.py:29: DeprecationWarning: ckd_public module is deprecated and will be removed
warnings.warn("ckd_public module is deprecated and will be removed", DeprecationWarning)
-- Docs: https://docs.pytest.org/en/latest/warnings.html
======================== 54 passed, 1 warnings in 1.27s ========================
pythonCatchConflictsPhase
pythonRemoveBinBytecodePhase
pythonImportsCheckPhase
Executing pythonImportsCheckPhase
pytestcachePhase
building '/nix/store/95afyzpl471ajbny9g8ag9iqwp7wr09g-python3-3.7.4-env.drv'...
created 356 symlinks in user environment
/nix/store/bfhpdpn39dp2207lcm66wq35arlbh2bc-python3-3.7.4-env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment