1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 bidict,
12 python-engineio,
13
14 # optional-dependencies
15 aiohttp,
16 requests,
17 websocket-client,
18
19 # tests
20 msgpack,
21 pytest7CheckHook,
22 simple-websocket,
23 uvicorn,
24
25}:
26
27buildPythonPackage rec {
28 pname = "python-socketio";
29 version = "5.13.0";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "miguelgrinberg";
34 repo = "python-socketio";
35 tag = "v${version}";
36 hash = "sha256-iOipxGALYOXLvUwn6OSjLCMZoUl7u4S5eCktUgcs/X0=";
37 };
38
39 build-system = [ setuptools ];
40
41 dependencies = [
42 bidict
43 python-engineio
44 ];
45
46 optional-dependencies = {
47 client = [
48 requests
49 websocket-client
50 ];
51 asyncio_client = [ aiohttp ];
52 };
53
54 nativeCheckInputs = [
55 msgpack
56 pytest7CheckHook
57 uvicorn
58 simple-websocket
59 ]
60 ++ lib.flatten (lib.attrValues optional-dependencies);
61
62 pythonImportsCheck = [ "socketio" ];
63
64 disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
65 # Use fixed ports which leads to failures when building concurrently
66 "tests/async/test_admin.py"
67 "tests/common/test_admin.py"
68 ];
69
70 __darwinAllowLocalNetworking = true;
71
72 meta = {
73 description = "Python Socket.IO server and client";
74 longDescription = ''
75 Socket.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-socketio/";
79 changelog = "https://github.com/miguelgrinberg/python-socketio/blob/${src.tag}/CHANGES.md";
80 license = with lib.licenses; [ mit ];
81 maintainers = with lib.maintainers; [ mic92 ];
82 };
83}