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