From 146e5982348b6c2ad464c03273de6681bb259f65 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 6 Jul 2026 03:16:57 +0200 Subject: [PATCH 1/2] python3Packages.tmodbus: init at 0.4.1 --- .../python-modules/tmodbus/default.nix | 117 ++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 119 insertions(+) create mode 100644 pkgs/development/python-modules/tmodbus/default.nix diff --git a/pkgs/development/python-modules/tmodbus/default.nix b/pkgs/development/python-modules/tmodbus/default.nix new file mode 100644 index 000000000000..c2add12f2075 --- /dev/null +++ b/pkgs/development/python-modules/tmodbus/default.nix @@ -0,0 +1,117 @@ +{ + buildPythonPackage, + fetchFromGitHub, + hatchling, + hatch-vcs, + lib, + pytest-asyncio, + pytestCheckHook, + rustPlatform, + serialx, + socat, + tenacity, +}: + +let + version = "0.4.1"; + + src = fetchFromGitHub { + owner = "wlcrs"; + repo = "tmodbus"; + tag = "v${version}"; + hash = "sha256-pVP2QaCYkeeKhlEha7qIyNhbN1DfVyRxTSZBloEMXxc="; + }; + + rmodbus-server = rustPlatform.buildRustPackage (finalAttrs: { + pname = "rmodbus-server"; + version = "0.1.0"; + + inherit src; + + sourceRoot = "${src.name}/integration_tests/rmodbus"; + + cargoHash = "sha256-t7lJ7zC5+z1E/EDWTPR6cbGhcy/RmtXQXon+FiXRZlI="; + + meta = { + description = "Rust Modbus server"; + license = lib.licenses.bsd3; + mainProgram = "server"; + }; + }); + + tokio-modbus-server = rustPlatform.buildRustPackage (finalAttrs: { + pname = "tokio-modbus-server"; + version = "0.1.0"; + + inherit src; + + sourceRoot = "${src.name}/integration_tests/tokio"; + + cargoHash = "sha256-grYnQxf0CH7hkFq1zTMxw6brtHfCheh/O2EtPPPpVqA="; + + meta = { + description = "Rust Tokio Modbus server"; + license = lib.licenses.bsd3; + mainProgram = "tokio-server"; + }; + }); +in + +buildPythonPackage (finalAttrs: { + pname = "tmodbus"; + inherit version src; + pyproject = true; + + __structuredAttrs = true; + + postPatch = '' + substituteInPlace \ + integration_tests/tokio/test_tokio_client.py \ + integration_tests/rmodbus/test_rmodbus_client.py \ + --replace-fail "/usr/bin/socat" "${lib.getExe socat}" + + mkdir -p integration_tests/{rmodbus,tokio}/target/release + ln -s ${lib.getExe' rmodbus-server "ascii-server"} integration_tests/rmodbus/target/release/ + ln -s ${lib.getExe rmodbus-server} integration_tests/rmodbus/target/release/ + ln -s ${lib.getExe tokio-modbus-server} integration_tests/tokio/target/release/ + ''; + + build-system = [ + hatch-vcs + hatchling + ]; + + optional-dependencies = { + async-serial = [ + serialx + ]; + smart = [ + tenacity + ]; + }; + + nativeCheckInputs = [ + pytest-asyncio + pytestCheckHook + ] + ++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies; + + pythonImportsCheck = [ + "tmodbus" + ]; + + passthru = { + inherit rmodbus-server tokio-modbus-server; + }; + + meta = { + description = "Modern Python Modbus library"; + homepage = "https://github.com/wlcrs/tmodbus"; + changelog = "https://github.com/wlcrs/tmodbus/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ hexa ]; + badPlatforms = [ + "aarch64-darwin" # tests fail, no indication they should work + ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index e546436a9bc9..c95ad1659460 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -20321,6 +20321,8 @@ self: super: with self; { tmdbsimple = callPackage ../development/python-modules/tmdbsimple { }; + tmodbus = callPackage ../development/python-modules/tmodbus { }; + tnefparse = callPackage ../development/python-modules/tnefparse { }; todoist = callPackage ../development/python-modules/todoist { }; From 3d8a6e75ec65db9465255645a763d57920f64311 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 6 Jul 2026 03:28:48 +0200 Subject: [PATCH 2/2] python3Packages.modbus-connection: init at 3.3.0 --- .../modbus-connection/default.nix | 63 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 65 insertions(+) create mode 100644 pkgs/development/python-modules/modbus-connection/default.nix diff --git a/pkgs/development/python-modules/modbus-connection/default.nix b/pkgs/development/python-modules/modbus-connection/default.nix new file mode 100644 index 000000000000..ee941c0f623b --- /dev/null +++ b/pkgs/development/python-modules/modbus-connection/default.nix @@ -0,0 +1,63 @@ +{ + buildPythonPackage, + fetchFromGitHub, + hatchling, + lib, + pymodbus, + pyprojectVersionPatchHook, + pytest-asyncio, + pytestCheckHook, + tmodbus, +}: + +buildPythonPackage (finalAttrs: { + pname = "modbus-connection"; + version = "3.3.0"; + pyproject = true; + __structuredAttrs = true; + + src = fetchFromGitHub { + owner = "home-assistant-libs"; + repo = "modbus-connection"; + tag = finalAttrs.version; + hash = "sha256-IEdOLd+BjX2b6bQS7hw33CyuDFVJ5dO0BaHLLhGp3LE="; + }; + + nativeBuildInputs = [ + pyprojectVersionPatchHook + ]; + + build-system = [ + hatchling + ]; + + optional-dependencies = { + pymodbus = [ + pymodbus + ] + ++ pymodbus.optional-dependencies.serial; + tmodbus = [ + tmodbus + ] + ++ tmodbus.optional-dependencies.async-serial + ++ tmodbus.optional-dependencies.smart; + }; + + nativeCheckInputs = [ + pytest-asyncio + pytestCheckHook + ] + ++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies; + + pythonImportsCheck = [ + "modbus_connection" + ]; + + meta = { + description = "Small, backend-neutral Modbus connection abstraction"; + homepage = "https://github.com/home-assistant-libs/modbus-connection"; + changelog = "https://github.com/home-assistant-libs/modbus-connection/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ hexa ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c95ad1659460..d2f71262370e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10689,6 +10689,8 @@ self: super: with self; { modal = callPackage ../development/python-modules/modal { }; + modbus-connection = callPackage ../development/python-modules/modbus-connection { }; + modbus-tk = callPackage ../development/python-modules/modbus-tk { }; moddb = callPackage ../development/python-modules/moddb { };