1{
2 lib,
3 aiohttp,
4 buildPythonPackage,
5 click,
6 fetchFromGitHub,
7 prompt-toolkit,
8 pygments,
9 pyserial,
10 pytest-asyncio,
11 pytest-xdist,
12 pytestCheckHook,
13 pythonOlder,
14 redis,
15 setuptools,
16 sqlalchemy,
17 twisted,
18 typer,
19}:
20
21buildPythonPackage rec {
22 pname = "pymodbus";
23 version = "3.6.9";
24 pyproject = true;
25
26 disabled = pythonOlder "3.9";
27
28 src = fetchFromGitHub {
29 owner = "pymodbus-dev";
30 repo = "pymodbus";
31 rev = "refs/tags/v${version}";
32 hash = "sha256-ScqxDO0hif8p3C6+vvm7FgSEQjCXBwUPOc7Y/3OfkoI=";
33 };
34
35 postPatch = ''
36 substituteInPlace pyproject.toml \
37 --replace-fail "--cov-report html " ""
38 '';
39
40 build-system = [ setuptools ];
41
42 passthru.optional-dependencies = {
43 repl = [
44 aiohttp
45 typer
46 prompt-toolkit
47 pygments
48 click
49 ];
50 serial = [ pyserial ];
51 };
52
53 nativeCheckInputs = [
54 pytest-asyncio
55 pytest-xdist
56 pytestCheckHook
57 redis
58 sqlalchemy
59 twisted
60 ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
61
62 preCheck = ''
63 pushd test
64 '';
65
66 postCheck = ''
67 popd
68 '';
69
70 pythonImportsCheck = [ "pymodbus" ];
71
72 disabledTests =
73 [
74 # Tests often hang
75 "test_connected"
76 ]
77 ++ lib.optionals (lib.versionAtLeast aiohttp.version "3.9.0") [
78 "test_split_serial_packet"
79 "test_serial_poll"
80 "test_simulator"
81 ];
82
83 meta = with lib; {
84 description = "Python implementation of the Modbus protocol";
85 longDescription = ''
86 Pymodbus is a full Modbus protocol implementation using twisted,
87 torndo or asyncio for its asynchronous communications core. It can
88 also be used without any third party dependencies if a more
89 lightweight project is needed.
90 '';
91 homepage = "https://github.com/pymodbus-dev/pymodbus";
92 changelog = "https://github.com/pymodbus-dev/pymodbus/releases/tag/v${version}";
93 license = with licenses; [ bsd3 ];
94 maintainers = with maintainers; [ fab ];
95 mainProgram = "pymodbus.simulator";
96 };
97}