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