1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, pythonOlder
5, asn1crypto
6, click
7, cryptography
8, pyhanko-certvalidator
9, pytz
10, pyyaml
11, qrcode
12, requests
13, tzlocal
14, certomancer
15, freezegun
16, python-pae
17, pytest-aiohttp
18, requests-mock
19, pytestCheckHook
20
21# optionals
22, defusedxml
23, oscrypto
24, fonttools
25, uharfbuzz
26, pillow
27, python-barcode
28, python-pkcs11
29, aiohttp
30}:
31
32buildPythonPackage rec {
33 pname = "pyhanko";
34 version = "0.17.0";
35 format = "setuptools";
36
37 disabled = pythonOlder "3.7";
38
39 # Tests are only available on GitHub
40 src = fetchFromGitHub {
41 owner = "MatthiasValvekens";
42 repo = "pyHanko";
43 rev = "refs/tags/${version}";
44 hash = "sha256-tvb2zdmIN6MkezmLNkyCcP8EfqxrbPg/FEqgW16Ka6Q=";
45 };
46
47 propagatedBuildInputs = [
48 asn1crypto
49 click
50 cryptography
51 pyhanko-certvalidator
52 pytz
53 pyyaml
54 qrcode
55 requests
56 tzlocal
57 ];
58
59 passthru.optional-dependencies = {
60 extra_pubkey_algs = [
61 oscrypto
62 ];
63 xmp = [
64 defusedxml
65 ];
66 opentype = [
67 fonttools
68 uharfbuzz
69 ];
70 image-support = [
71 pillow
72 python-barcode
73 ];
74 pkcs11 = [
75 python-pkcs11
76 ];
77 async_http = [
78 aiohttp
79 ];
80 };
81
82 postPatch = ''
83 substituteInPlace setup.py \
84 --replace ", 'pytest-runner'" "" \
85 '';
86
87 nativeCheckInputs = [
88 aiohttp
89 certomancer
90 freezegun
91 python-pae
92 pytest-aiohttp
93 requests-mock
94 pytestCheckHook
95 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
96
97 disabledTestPaths = [
98 # ModuleNotFoundError: No module named 'csc_dummy'
99 "pyhanko_tests/test_csc.py"
100 ];
101
102 disabledTests = [
103 # Most of the test require working with local certificates,
104 # contacting OSCP or performing requests
105 "test_generic_data_sign_legacy"
106 "test_generic_data_sign"
107 "test_cms_v3_sign"
108 "test_detached_cms_with_self_reported_timestamp"
109 "test_detached_cms_with_tst"
110 "test_detached_cms_with_content_tst"
111 "test_detached_cms_with_wrong_content_tst"
112 "test_detached_with_malformed_content_tst"
113 "test_noop_attribute_prov"
114 "test_detached_cades_cms_with_tst"
115 "test_read_qr_config"
116 "test_no_changes_policy"
117 "test_bogus_metadata_manipulation"
118 "test_tamper_sig_obj"
119 "test_signed_file_diff_proxied_objs"
120 "test_pades_revinfo_live"
121 "test_diff_fallback_ok"
122 "test_no_diff_summary"
123 "test_ocsp_embed"
124 "test_ts_fetch_aiohttp"
125 "test_ts_fetch_requests"
126 ];
127
128 pythonImportsCheck = [
129 "pyhanko"
130 ];
131
132 meta = with lib; {
133 description = "Sign and stamp PDF files";
134 homepage = "https://github.com/MatthiasValvekens/pyHanko";
135 license = licenses.mit;
136 maintainers = with maintainers; [ wolfangaukang ];
137 };
138}