1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 httpx,
7 libiconv,
8 nettle,
9 PCSC,
10 pcsclite,
11 pkg-config,
12 pytestCheckHook,
13 pythonOlder,
14 rustPlatform,
15 vcrpy,
16}:
17
18buildPythonPackage rec {
19 pname = "johnnycanencrypt";
20 version = "0.15.0";
21 pyproject = true;
22
23 disabled = pythonOlder "3.8";
24
25 src = fetchFromGitHub {
26 owner = "kushaldas";
27 repo = "johnnycanencrypt";
28 rev = "refs/tags/v${version}";
29 hash = "sha256-tbHW3x+vwFz0nqFGWvgxjhw8XH6/YKz1uagU339SZyk=";
30 };
31
32 cargoDeps = rustPlatform.fetchCargoTarball {
33 inherit src;
34 name = "${pname}-${version}";
35 hash = "sha256-vDlMdzZgmaRkviEk8IjIN+Q5x95gnpQiW5c8fT+dats=";
36 };
37
38 build-system = with rustPlatform; [
39 bindgenHook
40 cargoSetupHook
41 maturinBuildHook
42 ];
43
44 nativeBuildInputs =
45 [ pkg-config ]
46 ++ (with rustPlatform; [
47 bindgenHook
48 cargoSetupHook
49 maturinBuildHook
50 ]);
51
52 buildInputs =
53 [ nettle ]
54 ++ lib.optionals stdenv.hostPlatform.isLinux [ pcsclite ]
55 ++ lib.optionals stdenv.hostPlatform.isDarwin [
56 PCSC
57 libiconv
58 ];
59
60 dependencies = [ httpx ];
61
62 nativeCheckInputs = [
63 pytestCheckHook
64 vcrpy
65 ];
66
67 preCheck = ''
68 # import from $out
69 rm -r johnnycanencrypt
70 '';
71
72 pythonImportsCheck = [ "johnnycanencrypt" ];
73
74 meta = with lib; {
75 description = "Python module for OpenPGP written in Rust";
76 homepage = "https://github.com/kushaldas/johnnycanencrypt";
77 changelog = "https://github.com/kushaldas/johnnycanencrypt/blob/v${version}/changelog.md";
78 license = licenses.lgpl3Plus;
79 maintainers = with maintainers; [ _0x4A6F ];
80 };
81}