1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6 # deps
7 setuptools,
8 aiohttp,
9 attrs,
10 yarl,
11 # optional deps
12 python-magic,
13 python-olm,
14 unpaddedbase64,
15 pycryptodome,
16 # check deps
17 pytestCheckHook,
18 pytest-asyncio,
19 aiosqlite,
20 asyncpg,
21 ruamel-yaml,
22 fetchpatch,
23
24 withOlm ? false,
25}:
26
27buildPythonPackage rec {
28 pname = "mautrix";
29 version = "0.20.8";
30 pyproject = true;
31
32 disabled = pythonOlder "3.10";
33
34 src = fetchFromGitHub {
35 owner = "mautrix";
36 repo = "python";
37 tag = "v${version}";
38 hash = "sha256-giK8JZ6nzsA8SV6CzDNEbJmbwDju9t6fLJr/oXNjvKs=";
39 };
40
41 patches = [
42 (fetchpatch {
43 url = "https://github.com/mautrix/python/commit/0349445bd6992ac8f294582e85c3f61ce5c863b3.patch";
44 hash = "sha256-JYuFuzdwnyOdnxWg094uVKcaGza6I6hNUXUp75msRTI=";
45 })
46 ];
47
48 build-system = [ setuptools ];
49
50 dependencies = [
51 aiohttp
52 attrs
53 yarl
54 ]
55 ++ lib.optionals withOlm optional-dependencies.encryption;
56
57 optional-dependencies = {
58 detect_mimetype = [ python-magic ];
59 encryption = [
60 python-olm
61 unpaddedbase64
62 pycryptodome
63 ];
64 };
65
66 nativeCheckInputs = [
67 pytestCheckHook
68 pytest-asyncio
69 aiosqlite
70 asyncpg
71 ruamel-yaml
72 ];
73
74 disabledTestPaths = lib.optionals (!withOlm) [ "mautrix/crypto/" ];
75
76 pythonImportsCheck = [ "mautrix" ];
77
78 meta = with lib; {
79 description = "Asyncio Matrix framework";
80 homepage = "https://github.com/tulir/mautrix-python";
81 changelog = "https://github.com/mautrix/python/releases/tag/v${version}";
82 license = licenses.mpl20;
83 maintainers = with maintainers; [
84 nyanloutre
85 ma27
86 sumnerevans
87 nickcao
88 ];
89 };
90}