1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # dependencies
10 aiofiles,
11 aiohttp,
12 aiohttp-socks,
13 h11,
14 h2,
15 jsonschema,
16 pycryptodome,
17 unpaddedbase64,
18
19 # optional-dependencies
20 atomicwrites,
21 cachetools,
22 peewee,
23 python-olm,
24
25 # tests
26 aioresponses,
27 faker,
28 hpack,
29 hyperframe,
30 hypothesis,
31 pytest-aiohttp,
32 pytest-benchmark,
33 pytestCheckHook,
34
35 # passthru tests
36 nixosTests,
37 opsdroid,
38 pantalaimon,
39 weechatScripts,
40 zulip,
41
42 withOlm ? false,
43}:
44
45buildPythonPackage rec {
46 pname = "matrix-nio";
47 version = "0.25.2";
48 pyproject = true;
49
50 src = fetchFromGitHub {
51 owner = "poljar";
52 repo = "matrix-nio";
53 tag = version;
54 hash = "sha256-ZNYK5D4aDKE+N62A/hPmTphir+UsWvj3BW2EPG1z+R4=";
55 };
56
57 patches = [
58 # Ignore olm import failures when testing
59 ./allow-tests-without-olm.patch
60 ];
61
62 build-system = [ setuptools ];
63
64 dependencies = [
65 aiofiles
66 aiohttp
67 aiohttp-socks
68 h11
69 h2
70 jsonschema
71 pycryptodome
72 unpaddedbase64
73 ] ++ lib.optionals withOlm optional-dependencies.e2e;
74
75 optional-dependencies = {
76 e2e = [
77 atomicwrites
78 cachetools
79 python-olm
80 peewee
81 ];
82 };
83
84 pythonRelaxDeps = [
85 "aiofiles"
86 "aiohttp-socks" # Pending matrix-nio/matrix-nio#516
87 ];
88
89 nativeCheckInputs = [
90 aioresponses
91 faker
92 hpack
93 hyperframe
94 hypothesis
95 pytest-aiohttp
96 pytest-benchmark
97 pytestCheckHook
98 ];
99
100 pytestFlagsArray = [ "--benchmark-disable" ];
101
102 disabledTestPaths = lib.optionals (!withOlm) [
103 "tests/encryption_test.py"
104 "tests/key_export_test.py"
105 "tests/memory_store_test.py"
106 "tests/sas_test.py"
107 "tests/sessions_test.py"
108 "tests/store_test.py"
109 ];
110
111 disabledTests =
112 [
113 # touches network
114 "test_connect_wrapper"
115 # time dependent and flaky
116 "test_transfer_monitor_callbacks"
117 ]
118 ++ lib.optionals (!withOlm) [
119 "test_client_account_sharing"
120 "test_client_key_query"
121 "test_client_login"
122 "test_client_protocol_error"
123 "test_client_restore_login"
124 "test_client_room_creation"
125 "test_device_store"
126 "test_e2e_sending"
127 "test_early_store_loading"
128 "test_encrypted_data_generator"
129 "test_http_client_keys_query"
130 "test_key_claiming"
131 "test_key_exports"
132 "test_key_invalidation"
133 "test_key_sharing"
134 "test_key_sharing_callbacks"
135 "test_key_sharing_cancellation"
136 "test_keys_query"
137 "test_keys_upload"
138 "test_marking_sessions_as_shared"
139 "test_message_sending"
140 "test_query_rule"
141 "test_room_devices"
142 "test_sas_verification"
143 "test_sas_verification_cancel"
144 "test_session_sharing"
145 "test_session_sharing_2"
146 "test_session_unwedging"
147 "test_storing_room_encryption_state"
148 "test_sync_forever"
149 "test_sync_token_restoring"
150 ];
151
152 passthru.tests = {
153 inherit (nixosTests)
154 dendrite
155 matrix-appservice-irc
156 matrix-conduit
157 mjolnir
158 ;
159 inherit (weechatScripts) weechat-matrix;
160 inherit opsdroid pantalaimon zulip;
161 };
162
163 meta = with lib; {
164 homepage = "https://github.com/poljar/matrix-nio";
165 changelog = "https://github.com/poljar/matrix-nio/blob/${version}/CHANGELOG.md";
166 description = "Python Matrix client library, designed according to sans I/O principles";
167 license = licenses.isc;
168 maintainers = with maintainers; [
169 tilpner
170 symphorien
171 ];
172 };
173}