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