1{
2 lib,
3 stdenv,
4 aiofiles,
5 aioquic,
6 beautifulsoup4,
7 buildPythonPackage,
8 fetchFromGitHub,
9 gunicorn,
10 html5tagger,
11 httptools,
12 multidict,
13 pytest-asyncio,
14 pytestCheckHook,
15 pythonOlder,
16 sanic-ext,
17 sanic-routing,
18 sanic-testing,
19 setuptools,
20 tracerite,
21 typing-extensions,
22 ujson,
23 uvicorn,
24 uvloop,
25 websockets,
26}:
27
28buildPythonPackage rec {
29 pname = "sanic";
30 version = "25.3.0";
31 pyproject = true;
32
33 disabled = pythonOlder "3.7";
34
35 src = fetchFromGitHub {
36 owner = "sanic-org";
37 repo = "sanic";
38 tag = "v${version}";
39 hash = "sha256-tucLXWYPpALQrPYf+aiovKHYf2iouu6jezvNdukEu9w=";
40 };
41
42 build-system = [ setuptools ];
43
44 dependencies = [
45 aiofiles
46 httptools
47 html5tagger
48 multidict
49 sanic-routing
50 tracerite
51 typing-extensions
52 ujson
53 uvloop
54 websockets
55 ];
56
57 optional-dependencies = {
58 ext = [ sanic-ext ];
59 http3 = [ aioquic ];
60 };
61
62 nativeCheckInputs = [
63 beautifulsoup4
64 gunicorn
65 pytest-asyncio
66 pytestCheckHook
67 sanic-testing
68 uvicorn
69 ]
70 ++ optional-dependencies.http3;
71
72 doCheck = !stdenv.hostPlatform.isDarwin;
73
74 preCheck = ''
75 # Some tests depends on sanic on PATH
76 PATH="$out/bin:$PATH"
77 PYTHONPATH=$PWD:$PYTHONPATH
78
79 # needed for relative paths for some packages
80 cd tests
81 '';
82
83 disabledTests = [
84 # EOFError: Ran out of input
85 "test_server_run_with_repl"
86 # InvalidStatusCode: server rejected WebSocket connection: HTTP 400
87 "test_websocket_route_with_subprotocols"
88 # nic.exceptions.SanicException: Cannot setup Sanic Simple Server without a path to a directory
89 "test_load_app_simple"
90 # ModuleNotFoundError: No module named '/build/source/tests/tests/static'
91 "test_input_is_dir"
92 # Racy, e.g. Address already in use
93 "test_logger_vhosts"
94 ];
95
96 disabledTestPaths = [
97 # We are not interested in benchmarks
98 "benchmark/"
99 # We are also not interested in typing
100 "typing/test_typing.py"
101 # occasionally hangs
102 "test_multiprocessing.py"
103 ];
104
105 # Avoid usage of nixpkgs-review in darwin since tests will compete usage
106 # for the same local port
107 __darwinAllowLocalNetworking = true;
108
109 pythonImportsCheck = [ "sanic" ];
110
111 meta = with lib; {
112 description = "Web server and web framework";
113 homepage = "https://github.com/sanic-org/sanic/";
114 changelog = "https://github.com/sanic-org/sanic/releases/tag/${src.tag}";
115 license = licenses.mit;
116 maintainers = with maintainers; [ p0lyw0lf ];
117 mainProgram = "sanic";
118 };
119}