1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, fetchpatch
5, pythonOlder
6
7# build
8, setuptools
9, wheel
10
11# propagates
12, aiohttp
13, aiorun
14, coloredlogs
15, dacite
16, orjson
17, home-assistant-chip-clusters
18
19# optionals
20, cryptography
21, home-assistant-chip-core
22
23# tests
24, python
25, pytest
26, pytest-aiohttp
27, pytestCheckHook
28}:
29
30buildPythonPackage rec {
31 pname = "python-matter-server";
32 version = "3.7.0";
33 format = "pyproject";
34
35 disabled = pythonOlder "3.10";
36
37 src = fetchFromGitHub {
38 owner = "home-assistant-libs";
39 repo = "python-matter-server";
40 rev = "refs/tags/${version}";
41 hash = "sha256-t++7jQreibGpJRjJawicxjFIye5X6R1dpFqiM6yvRf0=";
42 };
43
44 patches = [
45 # https://github.com/home-assistant-libs/python-matter-server/pull/379
46 (fetchpatch {
47 name = "relax-setuptools-dependency.patch";
48 url = "https://github.com/home-assistant-libs/python-matter-server/commit/1bbc945634db92ea081051645b03c3d9c358fb15.patch";
49 hash = "sha256-kTu1+IwDrcdqelyK/vfhxw8MQBis5I1jag7YTytKQhs=";
50 })
51 ];
52
53 nativeBuildInputs = [
54 setuptools
55 wheel
56 ];
57
58 propagatedBuildInputs = [
59 aiohttp
60 aiorun
61 coloredlogs
62 dacite
63 orjson
64 home-assistant-chip-clusters
65 ];
66
67 passthru.optional-dependencies = {
68 server = [
69 cryptography
70 home-assistant-chip-core
71 ];
72 };
73
74 nativeCheckInputs = [
75 pytest-aiohttp
76 pytestCheckHook
77 ]
78 ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
79
80 preCheck = let
81 pythonEnv = python.withPackages (_: propagatedBuildInputs ++ nativeCheckInputs ++ [ pytest ]);
82 in
83 ''
84 export PYTHONPATH=${pythonEnv}/${python.sitePackages}
85 '';
86
87 pytestFlagsArray = [
88 # Upstream theymselves limit the test scope
89 # https://github.com/home-assistant-libs/python-matter-server/blob/main/.github/workflows/test.yml#L65
90 "tests/server"
91 ];
92
93 meta = with lib; {
94 changelog = "https://github.com/home-assistant-libs/python-matter-server/releases/tag/${version}";
95 description = "Python server to interact with Matter";
96 homepage = "https://github.com/home-assistant-libs/python-matter-server";
97 license = licenses.asl20;
98 maintainers = teams.home-assistant.members;
99 };
100}