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 tag = "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 ]
94 ++ lib.flatten (lib.attrValues optional-dependencies);
95
96 disabledTestPaths = [
97 # ModuleNotFoundError: No module named 'csc_dummy'
98 "pyhanko_tests/test_csc.py"
99 ]
100 ++ lib.optionals stdenv.hostPlatform.isDarwin [
101 # OSError: One or more parameters passed to a function were not valid.
102 "pyhanko_tests/cli_tests"
103 ];
104
105 disabledTests = [
106 # Most of the test require working with local certificates,
107 # contacting OSCP or performing requests
108 "test_generic_data_sign_legacy"
109 "test_generic_data_sign"
110 "test_cms_v3_sign"
111 "test_detached_cms_with_self_reported_timestamp"
112 "test_detached_cms_with_tst"
113 "test_detached_cms_with_content_tst"
114 "test_detached_cms_with_wrong_content_tst"
115 "test_detached_with_malformed_content_tst"
116 "test_noop_attribute_prov"
117 "test_detached_cades_cms_with_tst"
118 "test_read_qr_config"
119 "test_no_changes_policy"
120 "test_bogus_metadata_manipulation"
121 "test_tamper_sig_obj"
122 "test_signed_file_diff_proxied_objs"
123 "test_pades_revinfo_live"
124 "test_diff_fallback_ok"
125 "test_no_diff_summary"
126 "test_ocsp_embed"
127 "test_ts_fetch_aiohttp"
128 "test_ts_fetch_requests"
129 ]
130 ++ lib.optionals stdenv.hostPlatform.isDarwin [
131 # OSError: One or more parameters passed to a function were not valid.
132 "test_detached_cms_with_duplicated_attr"
133 "test_detached_cms_with_wrong_tst"
134 "test_diff_analysis_add_extensions_dict"
135 "test_diff_analysis_update_indirect_extensions_not_all_path"
136 "test_no_certificates"
137 "test_ocsp_without_nextupdate_embed"
138 ];
139
140 pythonImportsCheck = [ "pyhanko" ];
141
142 meta = {
143 description = "Sign and stamp PDF files";
144 mainProgram = "pyhanko";
145 homepage = "https://github.com/MatthiasValvekens/pyHanko";
146 changelog = "https://github.com/MatthiasValvekens/pyHanko/blob/v${version}/docs/changelog.rst";
147 license = lib.licenses.mit;
148 maintainers = [ ];
149 };
150}