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