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