1{ lib
2, stdenv
3, aiofiles
4, beautifulsoup4
5, buildPythonPackage
6, doCheck ? true
7, fetchFromGitHub
8, gunicorn
9, httptools
10, multidict
11, pytest-asyncio
12, pytest-benchmark
13, pytest-sugar
14, pytestCheckHook
15, pythonOlder
16, pythonAtLeast
17, sanic-routing
18, sanic-testing
19, ujson
20, uvicorn
21, uvloop
22, websockets
23, aioquic
24}:
25
26buildPythonPackage rec {
27 pname = "sanic";
28 version = "22.6.2";
29 format = "setuptools";
30
31 disabled = pythonOlder "3.7";
32
33 src = fetchFromGitHub {
34 owner = "sanic-org";
35 repo = pname;
36 rev = "v${version}";
37 hash = "sha256-krEQd0ak9Uua+r+pYmLStlizgE4HmZBO8Q0I2/gWAwU=";
38 };
39
40 propagatedBuildInputs = [
41 aiofiles
42 aioquic
43 httptools
44 multidict
45 sanic-routing
46 ujson
47 uvloop
48 websockets
49 ];
50
51 checkInputs = [
52 beautifulsoup4
53 gunicorn
54 pytest-asyncio
55 pytestCheckHook
56 sanic-testing
57 uvicorn
58 ];
59
60 inherit doCheck;
61
62 preCheck = ''
63 # Some tests depends on sanic on PATH
64 PATH="$out/bin:$PATH"
65 PYTHONPATH=$PWD:$PYTHONPATH
66
67 # needed for relative paths for some packages
68 cd tests
69 '' + lib.optionalString stdenv.isDarwin ''
70 # OSError: [Errno 24] Too many open files
71 ulimit -n 1024
72 '';
73
74 # uvloop usage is buggy
75 #SANIC_NO_UVLOOP = true;
76
77 pytestFlagsArray = [
78 "--asyncio-mode=auto"
79 ];
80
81 disabledTests = [
82 # Require networking
83 "test_full_message"
84 # Fails to parse cmdline arguments
85 "test_dev"
86 "test_auto_reload"
87 "test_host_port_ipv6_loopback"
88 "test_num_workers"
89 "test_debug"
90 "test_access_logs"
91 "test_noisy_exceptions"
92 # OSError: foo
93 "test_bad_headers"
94 "test_create_server_trigger_events"
95 "test_json_body_requests"
96 "test_missing_startup_raises_exception"
97 "test_no_body_requests"
98 "test_oserror_warning"
99 "test_running_multiple_offset_warning"
100 "test_streaming_body_requests"
101 "test_trigger_before_events_create_server"
102 "test_keep_alive_connection_context"
103 # Racy tests
104 "test_keep_alive_client_timeout"
105 "test_keep_alive_server_timeout"
106 "test_zero_downtime"
107 # broke with ujson 5.4 upgrade
108 # https://github.com/sanic-org/sanic/pull/2504
109 "test_json_response_json"
110 ];
111
112 disabledTestPaths = [
113 # We are not interested in benchmarks
114 "benchmark/"
115 # unable to create async loop
116 "test_app.py"
117 "test_asgi.py"
118 # occasionally hangs
119 "test_multiprocessing.py"
120 ];
121
122 # avoid usage of nixpkgs-review in darwin since tests will compete usage
123 # for the same local port
124 __darwinAllowLocalNetworking = true;
125
126 pythonImportsCheck = [ "sanic" ];
127
128 meta = with lib; {
129 broken = stdenv.isDarwin;
130 description = "Web server and web framework";
131 homepage = "https://github.com/sanic-org/sanic/";
132 license = licenses.mit;
133 maintainers = with maintainers; [ costrouc AluisioASG ];
134 };
135}