Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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.0";
25 pyproject = true;
26
27 src = fetchFromGitHub {
28 owner = "pymodbus-dev";
29 repo = "pymodbus";
30 tag = "v${version}";
31 hash = "sha256-bwTc2tzgGNcsDDeHkjq9ZeTuYLc7u76WbMvzOmzOTI4=";
32 };
33
34 build-system = [ setuptools ];
35
36 optional-dependencies = {
37 repl = [ pymodbus-repl ];
38 serial = [ pyserial ];
39 simulator = [ aiohttp ];
40 };
41
42 nativeCheckInputs = [
43 pytest-asyncio
44 pytest-cov-stub
45 pytest-xdist
46 pytestCheckHook
47 redis
48 sqlalchemy
49 twisted
50 ]
51 ++ lib.flatten (builtins.attrValues optional-dependencies);
52
53 preCheck = ''
54 pushd test
55 '';
56
57 postCheck = ''
58 popd
59 '';
60
61 pythonImportsCheck = [ "pymodbus" ];
62
63 disabledTests = [
64 # Tests often hang
65 "test_connected"
66 ]
67 ++ lib.optionals (lib.versionAtLeast aiohttp.version "3.9.0") [
68 "test_split_serial_packet"
69 "test_serial_poll"
70 "test_simulator"
71 ];
72
73 disabledTestPaths = [
74 # Don't test the examples
75 "examples/"
76 ];
77
78 meta = with lib; {
79 description = "Python implementation of the Modbus protocol";
80 longDescription = ''
81 Pymodbus is a full Modbus protocol implementation using twisted,
82 torndo or asyncio for its asynchronous communications core. It can
83 also be used without any third party dependencies if a more
84 lightweight project is needed.
85 '';
86 homepage = "https://github.com/pymodbus-dev/pymodbus";
87 changelog = "https://github.com/pymodbus-dev/pymodbus/releases/tag/${src.tag}";
88 license = licenses.bsd3;
89 maintainers = with maintainers; [ fab ];
90 mainProgram = "pymodbus.simulator";
91 };
92}