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