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