1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 cargo,
6 fetchFromGitHub,
7 frelatage,
8 libiconv,
9 maturin,
10 pytestCheckHook,
11 pythonOlder,
12 rustc,
13 rustPlatform,
14}:
15
16buildPythonPackage rec {
17 pname = "base2048";
18 version = "0.1.3";
19 pyproject = true;
20
21 disabled = pythonOlder "3.7";
22
23 src = fetchFromGitHub {
24 owner = "ionite34";
25 repo = "base2048";
26 rev = "refs/tags/v${version}";
27 hash = "sha256-OXlfycJB1IrW2Zq0xPDGjjwCdRTWtX/ixPGWcd+YjAg=";
28 };
29
30 cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };
31
32 postPatch = ''
33 ln -s ${./Cargo.lock} Cargo.lock
34 '';
35
36 nativeBuildInputs = [
37 cargo
38 rustPlatform.cargoSetupHook
39 rustPlatform.maturinBuildHook
40 rustc
41 ];
42
43 buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
44
45 passthru.optional-dependencies = {
46 fuzz = [ frelatage ];
47 };
48
49 nativeCheckInputs = [ pytestCheckHook ];
50
51 pythonImportsCheck = [ "base2048" ];
52
53 meta = with lib; {
54 description = "Binary encoding with base-2048 in Python with Rust";
55 homepage = "https://github.com/ionite34/base2048";
56 changelog = "https://github.com/ionite34/base2048/releases/tag/v${version}";
57 license = licenses.mit;
58 maintainers = with maintainers; [ fab ];
59 };
60}