1{
2 lib,
3 fetchFromGitHub,
4 fetchpatch,
5 buildPythonPackage,
6 pythonOlder,
7 pytestCheckHook,
8 rustPlatform,
9 stdenv,
10 libiconv,
11}:
12
13buildPythonPackage rec {
14 pname = "py-bip39-bindings";
15 version = "0.1.11";
16 format = "pyproject";
17
18 disabled = pythonOlder "3.7";
19
20 src = fetchFromGitHub {
21 owner = "polkascan";
22 repo = "py-bip39-bindings";
23 rev = "refs/tags/v${version}";
24 hash = "sha256-3/KBPUFVFkJifunGWJeAHLnY08KVTb8BHCFzDqKWH18=";
25 };
26
27 patches = [
28 (fetchpatch {
29 name = "update-to-latest-maturin-and-pyo3.patch";
30 url = "https://github.com/polkascan/py-bip39-bindings/commit/f05cced028b43b59cfa67e17fbf0f337bdd3aa8d.patch";
31 hash = "sha256-/pFNSFtYyKiOoIDVqEWdZCbQxFZ7FIcvAHY2m5STlEc=";
32 })
33 ];
34
35 cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };
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 = [ pytestCheckHook ];
49
50 pytestFlagsArray = [ "tests.py" ];
51
52 pythonImportsCheck = [ "bip39" ];
53
54 meta = with lib; {
55 description = "Python bindings for the tiny-bip39 library";
56 homepage = "https://github.com/polkascan/py-bip39-bindings";
57 license = licenses.asl20;
58 maintainers = with maintainers; [ stargate01 ];
59 };
60}