diff --git a/pkgs/development/python-modules/home-assistant-chip-clusters/default.nix b/pkgs/development/python-modules/home-assistant-chip-clusters/default.nix new file mode 100644 index 000000000000..0cf52ad3d08f --- /dev/null +++ b/pkgs/development/python-modules/home-assistant-chip-clusters/default.nix @@ -0,0 +1,37 @@ +{ lib +, buildPythonPackage +, fetchPypi +, dacite +}: + +buildPythonPackage rec { + pname = "home-assistant-chip-clusters"; + version = "2022.12.0"; + format = "wheel"; + + src = fetchPypi { + inherit format version; + pname = "home_assistant_chip_clusters"; + dist = "py3"; + python = "py3"; + hash = "sha256-zo54lRNyKXCCUUoYIiZmHZMqISim9QKEOnFbM/iBRqE="; + }; + + propagatedBuildInputs = [ + dacite + ]; + + pythonImportsCheck = [ + "chip.clusters" + ]; + + doCheck = false; # no tests + + meta = with lib; { + description = "Python-base APIs and tools for CHIP"; + homepage = "https://github.com/home-assistant-libs/chip-wheels"; + license = licenses.asl20; + maintainers = teams.home-assistant.members; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + }; +} diff --git a/pkgs/development/python-modules/home-assistant-chip-core/default.nix b/pkgs/development/python-modules/home-assistant-chip-core/default.nix new file mode 100644 index 000000000000..1394eef5cbdb --- /dev/null +++ b/pkgs/development/python-modules/home-assistant-chip-core/default.nix @@ -0,0 +1,93 @@ +{ lib +, stdenv +, buildPythonPackage +, fetchPypi +, pythonOlder + +# build +, autoPatchelfHook + +# runtime +, openssl_1_1 + +# propagates +, coloredlogs +, construct +, dacite +, rich +, pyyaml +, ipdb +, deprecation +, mobly +, pygobject3 +}: + +buildPythonPackage rec { + pname = "home-assistant-chip-core"; + version = "2022.12.0"; + format = "wheel"; + + disabled = pythonOlder "3.7"; + + src = let + system = { + "aarch64-linux" = { + name = "aarch64"; + hash = "sha256-oNqrvbzXeXpMG3v9RK6kppONH4n7xLVaJCEFXxVj2jE="; + }; + "x86_64-linux" = { + name = "x86_64"; + hash = "sha256-S5n1MUig8ZDSLgWeVmu+5qLZ4kfHQUC9qZcVfM8rPvw="; + }; + }.${stdenv.system} or (throw "Unsupported system"); + in fetchPypi { + pname = "home_assistant_chip_core"; + inherit version format; + dist = "cp37"; + python = "cp37"; + abi = "abi3"; + platform = "manylinux_2_31_${system.name}"; + hash = system.hash; + }; + + nativeBuildInputs = [ + autoPatchelfHook + ]; + + buildInputs = [ + openssl_1_1 + ]; + + propagatedBuildInputs = [ + coloredlogs + construct + dacite + rich + pyyaml + ipdb + deprecation + mobly + pygobject3 + ]; + + pythonImportsCheck = [ + "chip" + "chip.ble" + # https://github.com/project-chip/connectedhomeip/pull/24376 + #"chip.configuration" + "chip.discovery" + "chip.native" + "chip.storage" + ]; + + doCheck = false; # no tests + + meta = with lib; { + description = "Python-base APIs and tools for CHIP"; + homepage = "https://github.com/home-assistant-libs/chip-wheels"; + license = licenses.asl20; + maintainers = teams.home-assistant.members; + platforms = platforms.linux; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + }; +} diff --git a/pkgs/development/python-modules/mobly/default.nix b/pkgs/development/python-modules/mobly/default.nix new file mode 100644 index 000000000000..76f4e4fd9f29 --- /dev/null +++ b/pkgs/development/python-modules/mobly/default.nix @@ -0,0 +1,51 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub + +# runtime +, portpicker +, pyserial +, pyyaml +, timeout-decorator +, typing-extensions + +# tests +, procps +, pytestCheckHook +, pytz +}: + +buildPythonPackage rec { + pname = "mobly"; + version = "1.12"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "google"; + repo = "mobly"; + rev = "refs/tags/${version}"; + hash = "sha256-HAXm0/h5jbgVuIwP7IZ1ffUs92gcpOPiM2VgT38r8Go="; + }; + + propagatedBuildInputs = [ + portpicker + pyserial + pyyaml + timeout-decorator + typing-extensions + ]; + + checkInputs = [ + procps + pytestCheckHook + pytz + ]; + + meta = with lib; { + changelog = "https://github.com/google/mobly/blob/"; + description = "Automation framework for special end-to-end test cases"; + homepage = "https://github.com/google/mobly"; + license = licenses.asl20; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/python-matter-server/default.nix b/pkgs/development/python-modules/python-matter-server/default.nix new file mode 100644 index 000000000000..06d96a6d6dfc --- /dev/null +++ b/pkgs/development/python-modules/python-matter-server/default.nix @@ -0,0 +1,86 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, pythonOlder + +# build +, setuptools + +# propagates +, aiohttp +, aiorun +, coloredlogs +, dacite +, orjson +, home-assistant-chip-clusters + +# optionals +, home-assistant-chip-core + +# tests +, python +, pytest +, pytest-aiohttp +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "python-matter-server"; + version = "1.0.8"; + format = "pyproject"; + + disabled = pythonOlder "3.9"; + + src = fetchFromGitHub { + owner = "home-assistant-libs"; + repo = "python-matter-server"; + rev = "refs/tags/${version}"; + hash = "sha256-7w2Gg70Sl84zs55z6Hg8JPtkY9dNzyb1iBC6O4ulr1M="; + }; + + nativeBuildInputs = [ + setuptools + ]; + + propagatedBuildInputs = [ + aiohttp + aiorun + coloredlogs + dacite + orjson + home-assistant-chip-clusters + ]; + + passthru.optional-dependencies = { + server = [ + home-assistant-chip-core + ]; + }; + + checkInputs = [ + pytest-aiohttp + pytestCheckHook + ] + ++ lib.flatten (builtins.attrValues passthru.optional-dependencies); + + preCheck = let + pythonEnv = python.withPackages (_: propagatedBuildInputs ++ checkInputs ++ [ pytest ]); + in + '' + export PYTHONPATH=${pythonEnv}/${python.sitePackages} + ''; + + pytestFlagsArray = [ + # Upstream theymselves limit the test scope + # https://github.com/home-assistant-libs/python-matter-server/blob/main/.github/workflows/test.yml#L65 + "tests/server" + ]; + + meta = with lib; { + changelog = "https://github.com/home-assistant-libs/python-matter-server/releases/tag/${version}"; + description = "Python server to interact with Matter"; + homepage = "https://github.com/home-assistant-libs/python-matter-server"; + license = licenses.asl20; + maintainers = teams.home-assistant.members; + }; +} diff --git a/pkgs/servers/home-assistant/component-packages.nix b/pkgs/servers/home-assistant/component-packages.nix index 46d10548161b..610f5ff25eca 100644 --- a/pkgs/servers/home-assistant/component-packages.nix +++ b/pkgs/servers/home-assistant/component-packages.nix @@ -2020,8 +2020,9 @@ "matter" = ps: with ps; [ aiohttp-cors fnvhash + python-matter-server sqlalchemy - ]; # missing inputs: python-matter-server + ]; "maxcube" = ps: with ps; [ maxcube-api ]; @@ -4439,6 +4440,7 @@ "mailgun" "manual" "manual_mqtt" + "matter" "maxcube" "mazda" "meater" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f8f1b4cbd4ab..d260b44f76ac 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17933,6 +17933,8 @@ with pkgs; python-language-server = callPackage ../development/dotnet-modules/python-language-server { }; + python-matter-server = with python3Packages; toPythonApplication python-matter-server; + minify = callPackage ../development/web/minify { }; minizinc = callPackage ../development/tools/minizinc { }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 50bf8f8ba99b..9ecc9bab1b2d 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4311,6 +4311,10 @@ self: super: with self; { home-assistant-bluetooth = callPackage ../development/python-modules/home-assistant-bluetooth { }; + home-assistant-chip-clusters = callPackage ../development/python-modules/home-assistant-chip-clusters { }; + + home-assistant-chip-core = callPackage ../development/python-modules/home-assistant-chip-core { }; + homeassistant-pyozw = callPackage ../development/python-modules/homeassistant-pyozw { }; homeconnect = callPackage ../development/python-modules/homeconnect { }; @@ -5910,6 +5914,8 @@ self: super: with self; { moat-ble = callPackage ../development/python-modules/moat-ble { }; + mobly = callPackage ../development/python-modules/mobly { }; + mocket = callPackage ../development/python-modules/mocket { }; mock = callPackage ../development/python-modules/mock { }; @@ -9253,6 +9259,8 @@ self: super: with self; { python-markdown-math = callPackage ../development/python-modules/python-markdown-math { }; + python-matter-server = callPackage ../development/python-modules/python-matter-server { }; + python-miio = callPackage ../development/python-modules/python-miio { }; python-mimeparse = callPackage ../development/python-modules/python-mimeparse { };