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, sanic-routing
16, sanic-testing
17, ujson
18, uvicorn
19, uvloop
20, websockets
21}:
22
23buildPythonPackage rec {
24 pname = "sanic";
25 version = "21.9.1";
26
27 src = fetchFromGitHub {
28 owner = "sanic-org";
29 repo = pname;
30 rev = "v${version}";
31 sha256 = "sha256-TRrJr/L8AXLAARPjhBi2FxNh+jvxxdeMN24cT1njmqY=";
32 };
33
34 postPatch = ''
35 # Loosen dependency requirements.
36 substituteInPlace setup.py \
37 --replace '"pytest==6.2.5"' '"pytest"' \
38 --replace '"gunicorn==20.0.4"' '"gunicorn"' \
39 --replace '"pytest-sanic",' "" \
40 # Patch a request headers test to allow brotli encoding
41 # (we build httpx with brotli support, upstream doesn't).
42 substituteInPlace tests/test_headers.py \
43 --replace "deflate\r\n" "deflate, br\r\n"
44 '';
45
46 propagatedBuildInputs = [
47 aiofiles
48 httptools
49 multidict
50 sanic-routing
51 ujson
52 uvloop
53 websockets
54 ];
55
56 checkInputs = [
57 beautifulsoup4
58 gunicorn
59 pytest-asyncio
60 pytest-benchmark
61 pytest-sugar
62 pytestCheckHook
63 sanic-testing
64 uvicorn
65 ];
66
67 inherit doCheck;
68
69 preCheck = ''
70 # Some tests depends on sanic on PATH
71 PATH="$out/bin:$PATH"
72 '';
73
74 disabledTests = [
75 # Tests are flaky
76 "test_keep_alive_client_timeout"
77 "test_check_timeouts_request_timeout"
78 "test_check_timeouts_response_timeout"
79 "test_reloader_live"
80 "test_zero_downtime"
81 # Not working from 21.9.1
82 "test_create_server_main"
83 "test_create_server_main_convenience"
84 "test_debug"
85 "test_auto_reload"
86 "test_no_exceptions_when_cancel_pending_request"
87 "test_ipv6_address_is_not_wrapped"
88 # These appear to be very sensitive to output of commands
89 "test_access_logs"
90 "test_auto_reload"
91 "test_host_port"
92 "test_no_exceptions_when_cancel_pending_request"
93 "test_num_workers"
94 "test_server_run"
95 "test_version"
96 ];
97
98 # avoid usage of nixpkgs-review in darwin since tests will compete usage
99 # for the same local port
100 __darwinAllowLocalNetworking = true;
101
102 pythonImportsCheck = [ "sanic" ];
103
104 meta = with lib; {
105 description = "Web server and web framework";
106 homepage = "https://github.com/sanic-org/sanic/";
107 license = licenses.mit;
108 maintainers = with maintainers; [ costrouc AluisioASG ];
109 };
110}