biome: 1.9.2 -> 1.9.3 (#349335)
[NixPkgs.git] / pkgs / development / python-modules / python-matter-server / default.nix
blob8a736730ef5449809b50ce22c3c1c9bd06d4e5ea
2   lib,
3   buildPythonPackage,
4   fetchFromGitHub,
5   pythonOlder,
6   stdenvNoCC,
7   substituteAll,
9   # build
10   setuptools,
12   # propagates
13   aiohttp,
14   aiorun,
15   async-timeout,
16   coloredlogs,
17   dacite,
18   orjson,
19   home-assistant-chip-clusters,
21   # optionals
22   cryptography,
23   home-assistant-chip-core,
24   zeroconf,
26   # tests
27   aioresponses,
28   python,
29   pytest,
30   pytest-aiohttp,
31   pytestCheckHook,
34 let
35   paaCerts = stdenvNoCC.mkDerivation rec {
36     pname = "matter-server-paa-certificates";
37     version = "1.3.0.0";
39     src = fetchFromGitHub {
40       owner = "project-chip";
41       repo = "connectedhomeip";
42       rev = "refs/tags/v${version}";
43       hash = "sha256-5MI6r0KhSTzolesTQ8YWeoko64jFu4jHfO5KOOKpV0A=";
44     };
46     installPhase = ''
47       runHook preInstall
49       mkdir -p $out
50       cp $src/credentials/development/paa-root-certs/* $out/
52       runHook postInstall
53     '';
54   };
57 buildPythonPackage rec {
58   pname = "python-matter-server";
59   version = "6.6.0";
60   pyproject = true;
62   disabled = pythonOlder "3.10";
64   src = fetchFromGitHub {
65     owner = "home-assistant-libs";
66     repo = "python-matter-server";
67     rev = "refs/tags/${version}";
68     hash = "sha256-g+97a/X0FSapMLfdW6iNf1akkHGLqCmHYimQU/M6loo=";
69   };
71   patches = [
72     (substituteAll {
73       src = ./link-paa-root-certs.patch;
74       paacerts = paaCerts;
75     })
76   ];
78   postPatch = ''
79     substituteInPlace pyproject.toml \
80       --replace 'version = "0.0.0"' 'version = "${version}"' \
81       --replace '--cov' ""
82   '';
84   build-system = [
85     setuptools
86   ];
88   pythonRelaxDeps = [ "home-assistant-chip-clusters" ];
90   dependencies = [
91     aiohttp
92     aiorun
93     async-timeout
94     coloredlogs
95     dacite
96     orjson
97     home-assistant-chip-clusters
98   ];
100   optional-dependencies = {
101     server = [
102       cryptography
103       home-assistant-chip-core
104       zeroconf
105     ];
106   };
108   nativeCheckInputs = [
109     aioresponses
110     pytest-aiohttp
111     pytestCheckHook
112   ] ++ lib.flatten (lib.attrValues optional-dependencies);
114   preCheck =
115     let
116       pythonEnv = python.withPackages (_: dependencies ++ nativeCheckInputs ++ [ pytest ]);
117     in
118     ''
119       export PYTHONPATH=${pythonEnv}/${python.sitePackages}
120     '';
122   pytestFlagsArray = [
123     # Upstream theymselves limit the test scope
124     # https://github.com/home-assistant-libs/python-matter-server/blob/main/.github/workflows/test.yml#L65
125     "tests/server"
126   ];
128   meta = with lib; {
129     changelog = "https://github.com/home-assistant-libs/python-matter-server/releases/tag/${version}";
130     description = "Python server to interact with Matter";
131     mainProgram = "matter-server";
132     homepage = "https://github.com/home-assistant-libs/python-matter-server";
133     license = licenses.asl20;
134     maintainers = teams.home-assistant.members;
135   };