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