1{ lib
2, fetchFromGitHub
3, fetchpatch
4, buildPythonPackage
5, pythonOlder
6, pytestCheckHook
7, rustPlatform
8, stdenv
9, libiconv }:
10
11buildPythonPackage rec {
12 pname = "py-bip39-bindings";
13 version = "0.1.11";
14 format = "pyproject";
15
16 disabled = pythonOlder "3.7";
17
18 src = fetchFromGitHub {
19 owner = "polkascan";
20 repo = "py-bip39-bindings";
21 rev = "refs/tags/v${version}";
22 hash = "sha256-3/KBPUFVFkJifunGWJeAHLnY08KVTb8BHCFzDqKWH18=";
23 };
24
25 patches = [
26 (fetchpatch {
27 name = "update-to-latest-maturin-and-pyo3.patch";
28 url = "https://github.com/polkascan/py-bip39-bindings/commit/f05cced028b43b59cfa67e17fbf0f337bdd3aa8d.patch";
29 hash = "sha256-/pFNSFtYyKiOoIDVqEWdZCbQxFZ7FIcvAHY2m5STlEc=";
30 })
31 ];
32
33 cargoDeps = rustPlatform.importCargoLock {
34 lockFile = ./Cargo.lock;
35 };
36
37 postPatch = ''
38 cp ${./Cargo.lock} Cargo.lock
39 '';
40
41 nativeBuildInputs = with rustPlatform; [
42 cargoSetupHook
43 maturinBuildHook
44 ];
45
46 buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
47
48 nativeCheckInputs = [
49 pytestCheckHook
50 ];
51
52 pytestFlagsArray = [
53 "tests.py"
54 ];
55
56 pythonImportsCheck = [
57 "bip39"
58 ];
59
60 meta = with lib; {
61 description = "Python bindings for the tiny-bip39 library";
62 homepage = "https://github.com/polkascan/py-bip39-bindings";
63 license = licenses.asl20;
64 maintainers = with maintainers; [ stargate01 ];
65 };
66}