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