From 1d9aa5420b712dc64ee4b150220e7f72f417aeb6 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 15 Nov 2024 10:40:03 +0100 Subject: [PATCH] python312Packages.mqtt2influxdb: refactor - enable tests - set version manually --- .../python-modules/mqtt2influxdb/default.nix | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/pkgs/development/python-modules/mqtt2influxdb/default.nix b/pkgs/development/python-modules/mqtt2influxdb/default.nix index 6f6bc9049e8b..fde57c49be0c 100644 --- a/pkgs/development/python-modules/mqtt2influxdb/default.nix +++ b/pkgs/development/python-modules/mqtt2influxdb/default.nix @@ -8,21 +8,31 @@ py-expression-eval, pyaml, pycron, + pytestCheckHook, schema, + setuptools, }: + buildPythonPackage rec { pname = "mqtt2influxdb"; version = "1.5.2"; - format = "setuptools"; + pyproject = true; src = fetchFromGitHub { owner = "hardwario"; repo = "bch-mqtt2influxdb"; - rev = "v${version}"; - sha256 = "YDgMoxnH4vCCa7b857U6iVBhYLxk8ZjytGziryn24bg="; + rev = "refs/tags/v${version}"; + hash = "sha256-YDgMoxnH4vCCa7b857U6iVBhYLxk8ZjytGziryn24bg="; }; - propagatedBuildInputs = [ + postPatch = '' + substituteInPlace setup.py \ + --replace-fail "find_version('mqtt2influxdb', '__init__.py')," "'${version}'," + ''; + + build-system = [ setuptools ]; + + dependencies = [ influxdb jsonpath-ng paho-mqtt @@ -32,14 +42,18 @@ buildPythonPackage rec { schema ]; + nativeCheckInputs = [ pytestCheckHook ]; + pythonImportsCheck = [ "mqtt2influxdb" ]; + pytestFlagsArray = [ "tests/test.py" ]; + meta = with lib; { - homepage = "https://github.com/hardwario/bch-mqtt2influxdb"; description = "Flexible MQTT to InfluxDB Bridge"; - mainProgram = "mqtt2influxdb"; - platforms = platforms.linux; + homepage = "https://github.com/hardwario/bch-mqtt2influxdb"; + changelog = "https://github.com/hardwario/bch-mqtt2influxdb/releases/tag/v${version}"; license = licenses.mit; maintainers = with maintainers; [ cynerd ]; + mainProgram = "mqtt2influxdb"; }; }