2021-06-28 23:13:55 +00:00
|
|
|
{ lib
|
2021-12-06 16:07:01 +00:00
|
|
|
, stdenv
|
2021-06-28 23:13:55 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
2023-08-22 20:05:09 +00:00
|
|
|
, fetchpatch
|
2024-02-29 20:09:43 +00:00
|
|
|
, pythonAtLeast
|
2023-08-10 07:59:29 +00:00
|
|
|
|
|
|
|
# build-system
|
|
|
|
, setuptools
|
2023-08-22 20:05:09 +00:00
|
|
|
, wheel
|
2023-08-10 07:59:29 +00:00
|
|
|
|
|
|
|
# propagates
|
|
|
|
, aiofiles
|
|
|
|
, html5tagger
|
2021-06-28 23:13:55 +00:00
|
|
|
, httptools
|
|
|
|
, multidict
|
|
|
|
, sanic-routing
|
2023-08-10 07:59:29 +00:00
|
|
|
, tracerite
|
|
|
|
, typing-extensions
|
2021-06-28 23:13:55 +00:00
|
|
|
, ujson
|
|
|
|
, uvloop
|
|
|
|
, websockets
|
2023-08-10 07:59:29 +00:00
|
|
|
|
|
|
|
# optionals
|
2022-11-21 17:40:18 +00:00
|
|
|
, aioquic
|
2023-08-10 07:59:29 +00:00
|
|
|
|
|
|
|
# tests
|
|
|
|
, doCheck ? !stdenv.isDarwin # on Darwin, tests fail but pkg still works
|
|
|
|
|
|
|
|
, beautifulsoup4
|
|
|
|
, gunicorn
|
|
|
|
, pytest-asyncio
|
|
|
|
, pytestCheckHook
|
|
|
|
, pythonOlder
|
|
|
|
, sanic-testing
|
|
|
|
, uvicorn
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "sanic";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "23.12.1";
|
2023-01-20 10:41:00 +00:00
|
|
|
format = "pyproject";
|
2021-12-26 17:43:05 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "sanic-org";
|
|
|
|
repo = pname;
|
2022-12-02 08:20:57 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-TizjibqoLNMX0m5oPyncKgFnltXOLZUIPSzVIeKU25w=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
setuptools
|
2023-08-22 20:05:09 +00:00
|
|
|
wheel
|
2023-01-20 10:41:00 +00:00
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = [
|
2021-06-28 23:13:55 +00:00
|
|
|
aiofiles
|
|
|
|
httptools
|
2023-08-10 07:59:29 +00:00
|
|
|
html5tagger
|
2021-06-28 23:13:55 +00:00
|
|
|
multidict
|
|
|
|
sanic-routing
|
2023-08-10 07:59:29 +00:00
|
|
|
tracerite
|
|
|
|
typing-extensions
|
2021-06-28 23:13:55 +00:00
|
|
|
ujson
|
|
|
|
uvloop
|
|
|
|
websockets
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
passthru.optional-dependencies = {
|
|
|
|
ext = [
|
|
|
|
# TODO: sanic-ext
|
|
|
|
];
|
|
|
|
http3 = [
|
|
|
|
aioquic
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2021-06-28 23:13:55 +00:00
|
|
|
beautifulsoup4
|
|
|
|
gunicorn
|
|
|
|
pytest-asyncio
|
|
|
|
pytestCheckHook
|
|
|
|
sanic-testing
|
|
|
|
uvicorn
|
2023-08-10 07:59:29 +00:00
|
|
|
] ++ passthru.optional-dependencies.http3;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-12 07:09:13 +00:00
|
|
|
inherit doCheck;
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
preCheck = ''
|
|
|
|
# Some tests depends on sanic on PATH
|
|
|
|
PATH="$out/bin:$PATH"
|
2022-02-10 20:34:41 +00:00
|
|
|
PYTHONPATH=$PWD:$PYTHONPATH
|
|
|
|
|
|
|
|
# needed for relative paths for some packages
|
|
|
|
cd tests
|
2023-02-22 10:55:15 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2022-05-18 14:49:53 +00:00
|
|
|
# OSError: [Errno 24] Too many open files
|
|
|
|
ulimit -n 1024
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
# uvloop usage is buggy
|
|
|
|
#SANIC_NO_UVLOOP = true;
|
|
|
|
|
|
|
|
pytestFlagsArray = [
|
|
|
|
"--asyncio-mode=auto"
|
2023-01-20 10:41:00 +00:00
|
|
|
"-vvv"
|
2022-02-10 20:34:41 +00:00
|
|
|
];
|
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
disabledTests = [
|
2022-11-21 17:40:18 +00:00
|
|
|
# Require networking
|
|
|
|
"test_full_message"
|
2023-01-20 10:41:00 +00:00
|
|
|
# Server mode mismatch (debug vs production)
|
2021-12-06 16:07:01 +00:00
|
|
|
"test_num_workers"
|
2022-06-16 17:23:12 +00:00
|
|
|
# Racy tests
|
|
|
|
"test_keep_alive_client_timeout"
|
|
|
|
"test_keep_alive_server_timeout"
|
|
|
|
"test_zero_downtime"
|
2023-01-20 10:41:00 +00:00
|
|
|
# sanic.exceptions.SanicException: Cannot setup Sanic Simple Server without a path to a directory
|
2022-12-02 08:20:57 +00:00
|
|
|
"test_load_app_simple"
|
2023-01-20 10:41:00 +00:00
|
|
|
# create defunct python processes
|
|
|
|
"test_reloader_live"
|
|
|
|
"test_reloader_live_with_dir"
|
|
|
|
"test_reload_listeners"
|
|
|
|
# crash the python interpreter
|
|
|
|
"test_host_port_localhost"
|
|
|
|
"test_host_port"
|
|
|
|
"test_server_run"
|
|
|
|
# NoneType object is not subscriptable
|
|
|
|
"test_serve_app_implicit"
|
|
|
|
# AssertionError: assert [] == ['Restarting a process', 'Begin restart termination', 'Starting a process']
|
|
|
|
"test_default_reload_shutdown_order"
|
|
|
|
# App not found.
|
|
|
|
"test_input_is_dir"
|
2023-11-16 04:20:00 +00:00
|
|
|
# HTTP 500 with Websocket subprotocols
|
|
|
|
"test_websocket_route_with_subprotocols"
|
|
|
|
# Socket closes early
|
|
|
|
"test_no_exceptions_when_cancel_pending_request"
|
2024-02-29 20:09:43 +00:00
|
|
|
] ++ lib.optionals (pythonAtLeast "3.12") [
|
|
|
|
# AttributeError: 'has_calls' is not a valid assertion. Use a spec for the mock if 'has_calls' is meant to be an attribute.
|
|
|
|
"test_ws_frame_put_message_into_queue"
|
2020-12-09 12:39:15 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
disabledTestPaths = [
|
2022-06-16 17:23:12 +00:00
|
|
|
# We are not interested in benchmarks
|
|
|
|
"benchmark/"
|
2023-08-10 07:59:29 +00:00
|
|
|
# We are also not interested in typing
|
|
|
|
"typing/test_typing.py"
|
2022-02-10 20:34:41 +00:00
|
|
|
# unable to create async loop
|
|
|
|
"test_app.py"
|
|
|
|
"test_asgi.py"
|
|
|
|
# occasionally hangs
|
|
|
|
"test_multiprocessing.py"
|
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# avoid usage of nixpkgs-review in darwin since tests will compete usage
|
|
|
|
# for the same local port
|
2021-01-09 10:05:03 +00:00
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
pythonImportsCheck = [ "sanic" ];
|
2021-03-12 07:09:13 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
2021-06-28 23:13:55 +00:00
|
|
|
description = "Web server and web framework";
|
2024-04-21 15:54:59 +00:00
|
|
|
mainProgram = "sanic";
|
2021-05-03 20:48:10 +00:00
|
|
|
homepage = "https://github.com/sanic-org/sanic/";
|
2022-12-02 08:20:57 +00:00
|
|
|
changelog = "https://github.com/sanic-org/sanic/releases/tag/v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2023-08-04 22:07:22 +00:00
|
|
|
maintainers = with maintainers; [ AluisioASG ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|