1{ lib
2, stdenv
3, fetchFromGitHub
4, buildPythonPackage
5, rustPlatform
6, llvmPackages
7, pkg-config
8, pcsclite
9, nettle
10, requests
11, vcrpy
12, numpy
13, pytestCheckHook
14, pythonOlder
15, PCSC
16}:
17
18buildPythonPackage rec {
19 pname = "johnnycanencrypt";
20 version = "0.5.0";
21 disabled = pythonOlder "3.7";
22
23 src = fetchFromGitHub {
24 owner = "kushaldas";
25 repo = "johnnycanencrypt";
26 rev = "v${version}";
27 sha256 = "192wfrlyylrpzq70yki421mi1smk8q2cyki2a1d03q7h6apib3j4";
28 };
29
30 cargoDeps = rustPlatform.fetchCargoTarball {
31 inherit patches src;
32 name = "${pname}-${version}";
33 hash = "sha256-2XhXCKyXVlFgbcOoMy/A5ajiIVxBii56YeI29mO720U=";
34 };
35
36 format = "pyproject";
37
38 patches = [ ./Cargo.lock.patch ];
39
40 LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
41
42 propagatedBuildInputs = [
43 requests
44 vcrpy
45 ];
46
47 nativeBuildInputs = [
48 llvmPackages.clang
49 pkg-config
50 ] ++ (with rustPlatform; [
51 cargoSetupHook
52 maturinBuildHook
53 ]);
54
55 buildInputs = [
56 pcsclite
57 nettle
58 ] ++ lib.optionals stdenv.isDarwin [ PCSC ];
59
60 # Needed b/c need to check AFTER python wheel is installed (using Rust Build, not buildPythonPackage)
61 doCheck = false;
62 doInstallCheck = true;
63
64 installCheckInputs = [
65 pytestCheckHook
66 numpy
67 ];
68
69 # Remove with the next release after 0.5.0. This change is required
70 # for compatibility with maturin 0.9.0.
71 postPatch = ''
72 sed '/project-url = /d' -i Cargo.toml
73 '';
74
75 preCheck = ''
76 export TESTDIR=$(mktemp -d)
77 cp -r tests/ $TESTDIR
78 pushd $TESTDIR
79 '';
80
81 postCheck = ''
82 popd
83 '';
84
85 pythonImportsCheck = [ "johnnycanencrypt" ];
86
87 meta = with lib; {
88 homepage = "https://github.com/kushaldas/johnnycanencrypt";
89 description = "Python module for OpenPGP written in Rust";
90 license = licenses.gpl3Plus;
91 maintainers = with maintainers; [ _0x4A6F ];
92 };
93}