From cbbbee5ce3f3deb416c7a495f627233eb8235a1c Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 27 Nov 2023 19:05:49 +0100 Subject: [PATCH 1/3] home-assistant: migrate to pythonRelaxDepsHook Mutating the resulting wheel, which has a more stable format, is the better solution, than the homegrown sed expression we used up until now. --- pkgs/servers/home-assistant/default.nix | 50 ++++++++++++------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/pkgs/servers/home-assistant/default.nix b/pkgs/servers/home-assistant/default.nix index 1c5f52588e46..4b0b4ee83b66 100644 --- a/pkgs/servers/home-assistant/default.nix +++ b/pkgs/servers/home-assistant/default.nix @@ -352,10 +352,32 @@ in python.pkgs.buildPythonApplication rec { }; nativeBuildInputs = with python.pkgs; [ + pythonRelaxDepsHook setuptools wheel ]; + pythonRelaxDeps = [ + "aiohttp" + "attrs" + "awesomeversion" + "bcrypt" + "ciso8601" + "cryptography" + "home-assistant-bluetooth" + "httpx" + "ifaddr" + "orjson" + "pip" + "PyJWT" + "pyOpenSSL" + "PyYAML" + "requests" + "typing-extensions" + "voluptuous-serialize" + "yarl" + ]; + # copy tests early, so patches apply as they would to the git repo prePatch = '' cp --no-preserve=mode --recursive ${gitSrc}/tests ./ @@ -374,33 +396,7 @@ in python.pkgs.buildPythonApplication rec { }) ]; - postPatch = let - relaxedConstraints = [ - "aiohttp" - "attrs" - "awesomeversion" - "bcrypt" - "ciso8601" - "cryptography" - "home-assistant-bluetooth" - "httpx" - "ifaddr" - "orjson" - "pip" - "PyJWT" - "pyOpenSSL" - "PyYAML" - "requests" - "typing-extensions" - "voluptuous-serialize" - "yarl" - ]; - in '' - sed -r -i \ - ${lib.concatStringsSep "\n" (map (package: - ''-e 's/${package}[<>=]+.*/${package}",/g' \'' - ) relaxedConstraints)} - pyproject.toml + postPatch = '' substituteInPlace tests/test_config.py --replace '"/usr"' '"/build/media"' sed -i 's/setuptools[~=]/setuptools>/' pyproject.toml From 742ea5dcc81eed1c24ef1c50cbebab75376562a2 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 27 Nov 2023 19:07:15 +0100 Subject: [PATCH 2/3] home-assistant: propagate pyotp and pyqrcode These dependencies are not documented, but rather installed at runtime as needed. Propagate them to fix the OTP use case, where QR Codes need to be generated, to e.g. scan them to your phone. --- pkgs/servers/home-assistant/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/home-assistant/default.nix b/pkgs/servers/home-assistant/default.nix index 4b0b4ee83b66..21c503c8874d 100644 --- a/pkgs/servers/home-assistant/default.nix +++ b/pkgs/servers/home-assistant/default.nix @@ -432,6 +432,9 @@ in python.pkgs.buildPythonApplication rec { voluptuous voluptuous-serialize yarl + # REQUIREMENTS in homeassistant/auth/mfa_modules/totp.py and homeassistant/auth/mfa_modules/notify.py + pyotp + pyqrcode # Implicit dependency via homeassistant/requirements.py setuptools ]; @@ -458,8 +461,6 @@ in python.pkgs.buildPythonApplication rec { respx syrupy tomli - # required through tests/auth/mfa_modules/test_otp.py - pyotp # Sneakily imported in tests/conftest.py paho-mqtt ] ++ lib.concatMap (component: getPackages component python.pkgs) [ From c150877925aacf41aa51d28bc82693ad2da1b541 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 27 Nov 2023 19:08:54 +0100 Subject: [PATCH 3/3] home-assistant: prune test configuration The qwikswitch dependency is not required anymore for this test. Also prune some tests, that are not failing any more. --- pkgs/servers/home-assistant/default.nix | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pkgs/servers/home-assistant/default.nix b/pkgs/servers/home-assistant/default.nix index 21c503c8874d..7f6fca8a090b 100644 --- a/pkgs/servers/home-assistant/default.nix +++ b/pkgs/servers/home-assistant/default.nix @@ -467,8 +467,6 @@ in python.pkgs.buildPythonApplication rec { # some components are needed even if tests in tests/components are disabled "default_config" "hue" - # for tests/test_config.py::test_merge_id_schema - "qwikswitch" ]; pytestFlagsArray = [ @@ -481,12 +479,6 @@ in python.pkgs.buildPythonApplication rec { "--showlocals" # AssertionError: assert 1 == 0 "--deselect tests/test_config.py::test_merge" - # AssertionError: assert 2 == 1 - "--deselect=tests/helpers/test_translation.py::test_caching" - # AssertionError: assert None == RegistryEntry - "--deselect=tests/helpers/test_entity_registry.py::test_get_or_create_updates_data" - # AssertionError: assert 2 == 1 - "--deselect=tests/helpers/test_entity_values.py::test_override_single_value" # AssertionError: assert 'WARNING' not in '2023-11-10 ...nt abc[L]>\n'" "--deselect=tests/helpers/test_script.py::test_multiple_runs_repeat_choose" # tests are located in tests/