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