1{
2 lib,
3 stdenv,
4 aiohttp,
5 buildPythonPackage,
6 setuptools,
7 eventlet,
8 fetchFromGitHub,
9 iana-etc,
10 libredirect,
11 mock,
12 pytest-asyncio,
13 pytestCheckHook,
14 requests,
15 simple-websocket,
16 tornado,
17 websocket-client,
18}:
19
20buildPythonPackage rec {
21 pname = "python-engineio";
22 version = "4.12.3";
23 pyproject = true;
24
25 src = fetchFromGitHub {
26 owner = "miguelgrinberg";
27 repo = "python-engineio";
28 tag = "v${version}";
29 hash = "sha256-VcL8Od1EM/cbbeOVyXlsXYt8Bms636XbtunrTblkGDQ=";
30 };
31
32 build-system = [ setuptools ];
33
34 dependencies = [ simple-websocket ];
35
36 optional-dependencies = {
37 client = [
38 requests
39 websocket-client
40 ];
41 asyncio_client = [ aiohttp ];
42 };
43
44 nativeCheckInputs = [
45 eventlet
46 libredirect.hook
47 mock
48 tornado
49 pytest-asyncio
50 pytestCheckHook
51 ]
52 ++ lib.flatten (builtins.attrValues optional-dependencies);
53
54 preCheck = lib.optionalString stdenv.hostPlatform.isLinux ''
55 echo "nameserver 127.0.0.1" > resolv.conf
56 export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf)
57 '';
58
59 postCheck = ''
60 unset NIX_REDIRECTS LD_PRELOAD
61 '';
62
63 disabledTests = [
64 # Assertion issue
65 "test_async_mode_eventlet"
66 # Somehow effective log level does not change?
67 "test_logger"
68 ];
69
70 pythonImportsCheck = [ "engineio" ];
71
72 meta = with lib; {
73 description = "Python based Engine.IO client and server";
74 longDescription = ''
75 Engine.IO is a lightweight transport protocol that enables real-time
76 bidirectional event-based communication between clients and a server.
77 '';
78 homepage = "https://github.com/miguelgrinberg/python-engineio/";
79 changelog = "https://github.com/miguelgrinberg/python-engineio/blob/${src.tag}/CHANGES.md";
80 license = licenses.mit;
81 maintainers = with maintainers; [ mic92 ];
82 };
83}