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