Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 pythonAtLeast, 7 8 # build-system 9 setuptools, 10 wheel, 11 12 # propagates 13 aiofiles, 14 html5tagger, 15 httptools, 16 multidict, 17 sanic-routing, 18 tracerite, 19 typing-extensions, 20 ujson, 21 uvloop, 22 websockets, 23 24 # optionals 25 aioquic, 26 27 # tests 28 doCheck ? !stdenv.isDarwin, # on Darwin, tests fail but pkg still works 29 30 beautifulsoup4, 31 gunicorn, 32 pytest-asyncio, 33 pytestCheckHook, 34 pythonOlder, 35 sanic-testing, 36 uvicorn, 37}: 38 39buildPythonPackage rec { 40 pname = "sanic"; 41 version = "23.12.1"; 42 format = "pyproject"; 43 44 disabled = pythonOlder "3.7"; 45 46 src = fetchFromGitHub { 47 owner = "sanic-org"; 48 repo = pname; 49 rev = "refs/tags/v${version}"; 50 hash = "sha256-TizjibqoLNMX0m5oPyncKgFnltXOLZUIPSzVIeKU25w="; 51 }; 52 53 nativeBuildInputs = [ 54 setuptools 55 wheel 56 ]; 57 58 propagatedBuildInputs = [ 59 aiofiles 60 httptools 61 html5tagger 62 multidict 63 sanic-routing 64 tracerite 65 typing-extensions 66 ujson 67 uvloop 68 websockets 69 ]; 70 71 passthru.optional-dependencies = { 72 ext = [ 73 # TODO: sanic-ext 74 ]; 75 http3 = [ aioquic ]; 76 }; 77 78 nativeCheckInputs = [ 79 beautifulsoup4 80 gunicorn 81 pytest-asyncio 82 pytestCheckHook 83 sanic-testing 84 uvicorn 85 ] ++ passthru.optional-dependencies.http3; 86 87 inherit doCheck; 88 89 preCheck = 90 '' 91 # Some tests depends on sanic on PATH 92 PATH="$out/bin:$PATH" 93 PYTHONPATH=$PWD:$PYTHONPATH 94 95 # needed for relative paths for some packages 96 cd tests 97 '' 98 + lib.optionalString stdenv.isDarwin '' 99 # OSError: [Errno 24] Too many open files 100 ulimit -n 1024 101 ''; 102 103 # uvloop usage is buggy 104 #SANIC_NO_UVLOOP = true; 105 106 pytestFlagsArray = [ 107 "--asyncio-mode=auto" 108 "-vvv" 109 ]; 110 111 disabledTests = 112 [ 113 # Require networking 114 "test_full_message" 115 # Server mode mismatch (debug vs production) 116 "test_num_workers" 117 # Racy tests 118 "test_keep_alive_client_timeout" 119 "test_keep_alive_server_timeout" 120 "test_zero_downtime" 121 # sanic.exceptions.SanicException: Cannot setup Sanic Simple Server without a path to a directory 122 "test_load_app_simple" 123 # create defunct python processes 124 "test_reloader_live" 125 "test_reloader_live_with_dir" 126 "test_reload_listeners" 127 # crash the python interpreter 128 "test_host_port_localhost" 129 "test_host_port" 130 "test_server_run" 131 # NoneType object is not subscriptable 132 "test_serve_app_implicit" 133 # AssertionError: assert [] == ['Restarting a process', 'Begin restart termination', 'Starting a process'] 134 "test_default_reload_shutdown_order" 135 # App not found. 136 "test_input_is_dir" 137 # HTTP 500 with Websocket subprotocols 138 "test_websocket_route_with_subprotocols" 139 # Socket closes early 140 "test_no_exceptions_when_cancel_pending_request" 141 ] 142 ++ lib.optionals (pythonAtLeast "3.12") [ 143 # AttributeError: 'has_calls' is not a valid assertion. Use a spec for the mock if 'has_calls' is meant to be an attribute. 144 "test_ws_frame_put_message_into_queue" 145 ]; 146 147 disabledTestPaths = [ 148 # We are not interested in benchmarks 149 "benchmark/" 150 # We are also not interested in typing 151 "typing/test_typing.py" 152 # unable to create async loop 153 "test_app.py" 154 "test_asgi.py" 155 # occasionally hangs 156 "test_multiprocessing.py" 157 ]; 158 159 # avoid usage of nixpkgs-review in darwin since tests will compete usage 160 # for the same local port 161 __darwinAllowLocalNetworking = true; 162 163 pythonImportsCheck = [ "sanic" ]; 164 165 meta = with lib; { 166 description = "Web server and web framework"; 167 mainProgram = "sanic"; 168 homepage = "https://github.com/sanic-org/sanic/"; 169 changelog = "https://github.com/sanic-org/sanic/releases/tag/v${version}"; 170 license = licenses.mit; 171 maintainers = with maintainers; [ AluisioASG ]; 172 }; 173}