1{
2 lib,
3 buildPythonPackage,
4 docopt,
5 fetchFromGitHub,
6 hypothesis,
7 passlib,
8 poetry-core,
9 pytest-logdog,
10 pytest-asyncio,
11 pytestCheckHook,
12 pythonAtLeast,
13 pythonOlder,
14 pyyaml,
15 setuptools,
16 transitions,
17 websockets,
18}:
19
20buildPythonPackage {
21 pname = "amqtt";
22 version = "unstable-2022-05-29";
23 format = "pyproject";
24
25 disabled = pythonOlder "3.7";
26
27 src = fetchFromGitHub {
28 owner = "Yakifo";
29 repo = "amqtt";
30 rev = "09ac98d39a711dcff0d8f22686916e1c2495144b";
31 hash = "sha256-8T1XhBSOiArlUQbQ41LsUogDgOurLhf+M8mjIrrAC4s=";
32 };
33
34 postPatch = ''
35 substituteInPlace pyproject.toml \
36 --replace 'transitions = "^0.8.0"' 'transitions = "*"' \
37 --replace 'websockets = ">=9.0,<11.0"' 'websockets = "*"'
38 '';
39
40 nativeBuildInputs = [ poetry-core ];
41
42 propagatedBuildInputs = [
43 docopt
44 passlib
45 pyyaml
46 setuptools
47 transitions
48 websockets
49 ];
50
51 nativeCheckInputs = [
52 hypothesis
53 pytest-logdog
54 pytest-asyncio
55 pytestCheckHook
56 ];
57
58 pytestFlags = [ "--asyncio-mode=auto" ];
59
60 disabledTests = lib.optionals (pythonAtLeast "3.12") [
61 # stuck in epoll
62 "test_publish_qos0"
63 "test_publish_qos1"
64 "test_publish_qos1_retry"
65 "test_publish_qos2"
66 "test_publish_qos2_retry"
67 "test_receive_qos0"
68 "test_receive_qos1"
69 "test_receive_qos2"
70 "test_start_stop"
71 ];
72
73 disabledTestPaths = [
74 # Test are not ported from hbmqtt yet
75 "tests/test_client.py"
76 ];
77
78 preCheck = ''
79 # Some tests need amqtt
80 export PATH=$out/bin:$PATH
81 '';
82
83 pythonImportsCheck = [ "amqtt" ];
84
85 meta = with lib; {
86 description = "Python MQTT client and broker implementation";
87 homepage = "https://amqtt.readthedocs.io/";
88 license = with licenses; [ mit ];
89 maintainers = with maintainers; [ fab ];
90 };
91}