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