From 3800886ba44cc1db612ed97227dc80bf4984779a Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 23 Apr 2024 21:08:55 +0200 Subject: [PATCH] home-assistant.intents: return to source build Closes: home-assistant/intents-package#3 --- pkgs/servers/home-assistant/intents.nix | 54 ++++++++++++++++++++----- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/pkgs/servers/home-assistant/intents.nix b/pkgs/servers/home-assistant/intents.nix index b7b1578033e2..744adc8b4973 100644 --- a/pkgs/servers/home-assistant/intents.nix +++ b/pkgs/servers/home-assistant/intents.nix @@ -1,33 +1,67 @@ { lib , buildPythonPackage -, fetchPypi +, fetchFromGitHub , pythonOlder # build-system , setuptools + +# codegen +, hassil +, python +, pyyaml +, voluptuous +, regex +, jinja2 + +# tests +, pytest-xdist +, pytestCheckHook }: buildPythonPackage rec { pname = "home-assistant-intents"; version = "2024.4.3"; - format = "wheel"; + pyproject = true; disabled = pythonOlder "3.9"; - src = fetchPypi { - inherit version format; - pname = "home_assistant_intents"; - dist = "py3"; - python = "py3"; - hash = "sha256-GraYVtioKIoKlPRBhhhzlbBfI6heXAaA1MQpUqAgEDQ="; + src = fetchFromGitHub { + owner = "home-assistant"; + repo = "intents-package"; + rev = "refs/tags/${version}"; + hash = "sha256-hcstD1qkngZAl/jKLez+4qDs/ZIandkVkY2jrvZqph8="; + fetchSubmodules = true; }; + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail "setuptools~=62.3" "setuptools" \ + --replace-fail "wheel~=0.37.1" "wheel" + ''; + build-system = [ setuptools + + # build-time codegen; https://github.com/home-assistant/intents/blob/main/requirements.txt#L1-L5 + hassil + pyyaml + voluptuous + regex + jinja2 ]; - # sdist/wheel do not ship tests - doCheck = false; + postInstall = '' + # https://github.com/home-assistant/intents-package/blob/main/script/package#L23-L24 + PACKAGE_DIR=$out/${python.sitePackages}/home_assistant_intents + ${python.pythonOnBuildForHost.interpreter} script/merged_output.py $PACKAGE_DIR/data + ${python.pythonOnBuildForHost.interpreter} script/write_languages.py $PACKAGE_DIR/data > $PACKAGE_DIR/languages.py + ''; + + nativeCheckInputs = [ + pytest-xdist + pytestCheckHook + ]; pytestFlagsArray = [ "intents/tests"