From 5b971598f0a928185d0d9b4f3bc4ffe024a62fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alu=C3=ADsio=20Augusto=20Silva=20Gon=C3=A7alves?= Date: Tue, 27 Apr 2021 10:34:36 -0300 Subject: [PATCH 1/4] python3Packages.pytest-sanic: mark as broken with sanic >= 21.3.0 pytest-sanic is incompatible with the current version of Sanic, see sanic-org/sanic#2095 and yunstanford/pytest-sanic#50. While it is broken, we also need it to run Sanic's tests (for which case it works just fine). --- pkgs/development/python-modules/pytest-sanic/default.nix | 4 ++++ pkgs/top-level/python-packages.nix | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/pkgs/development/python-modules/pytest-sanic/default.nix b/pkgs/development/python-modules/pytest-sanic/default.nix index 84330cfd62e5..ae1c56f95b75 100644 --- a/pkgs/development/python-modules/pytest-sanic/default.nix +++ b/pkgs/development/python-modules/pytest-sanic/default.nix @@ -46,5 +46,9 @@ buildPythonPackage rec { homepage = "https://github.com/yunstanford/pytest-sanic/"; license = licenses.asl20; maintainers = [ maintainers.costrouc ]; + # pytest-sanic is incompatible with Sanic 21.3, see + # https://github.com/sanic-org/sanic/issues/2095 and + # https://github.com/yunstanford/pytest-sanic/issues/50. + broken = lib.versionAtLeast sanic.version "21.3.0"; }; } diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 10c07d8d4b42..9c4186355228 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7195,6 +7195,14 @@ in { samsungtvws = callPackage ../development/python-modules/samsungtvws { }; + sanic = callPackage ../development/python-modules/sanic { + # pytest-sanic is doing ok for the sole purpose of testing Sanic. + pytest-sanic = self.pytest-sanic.overridePythonAttrs (oldAttrs: { + doCheck = false; + meta.broken = false; + }); + }; + sanic-auth = callPackage ../development/python-modules/sanic-auth { }; sanic = callPackage ../development/python-modules/sanic { }; From 550bb02269300f2c3611f9a3cefefa38a9fb9a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alu=C3=ADsio=20Augusto=20Silva=20Gon=C3=A7alves?= Date: Tue, 27 Apr 2021 10:28:30 -0300 Subject: [PATCH 2/4] python3Packages.sanic-routing: init at 0.6.2 --- .../python-modules/sanic-routing/default.nix | 28 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/python-modules/sanic-routing/default.nix diff --git a/pkgs/development/python-modules/sanic-routing/default.nix b/pkgs/development/python-modules/sanic-routing/default.nix new file mode 100644 index 000000000000..76eb72dc7086 --- /dev/null +++ b/pkgs/development/python-modules/sanic-routing/default.nix @@ -0,0 +1,28 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, pytestCheckHook +, pytest-asyncio +}: + +buildPythonPackage rec { + pname = "sanic-routing"; + version = "0.6.2"; + + src = fetchFromGitHub { + owner = "sanic-org"; + repo = "sanic-routing"; + rev = "v${version}"; + hash = "sha256-ZMl8PB9E401pUfUJ4tW7nBx1TgPQQtx9erVni3zP+lo="; + }; + + checkInputs = [ pytestCheckHook pytest-asyncio ]; + pythonImportsCheck = [ "sanic_routing" ]; + + meta = with lib; { + description = "Core routing component for the Sanic web framework"; + homepage = "https://github.com/sanic-org/sanic-routing"; + license = licenses.mit; + maintainers = with maintainers; [ AluisioASG ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 9c4186355228..1128faed290f 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7205,7 +7205,7 @@ in { sanic-auth = callPackage ../development/python-modules/sanic-auth { }; - sanic = callPackage ../development/python-modules/sanic { }; + sanic-routing = callPackage ../development/python-modules/sanic-routing { }; sapi-python-client = callPackage ../development/python-modules/sapi-python-client { }; From 192b28a75f5bc29378af96784c996d65288bd16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alu=C3=ADsio=20Augusto=20Silva=20Gon=C3=A7alves?= Date: Tue, 27 Apr 2021 10:50:24 -0300 Subject: [PATCH 3/4] python3Packages.sanic-testing: init at 0.3.1 --- .../python-modules/sanic-testing/default.nix | 40 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 42 insertions(+) create mode 100644 pkgs/development/python-modules/sanic-testing/default.nix diff --git a/pkgs/development/python-modules/sanic-testing/default.nix b/pkgs/development/python-modules/sanic-testing/default.nix new file mode 100644 index 000000000000..fa1dfc6870b5 --- /dev/null +++ b/pkgs/development/python-modules/sanic-testing/default.nix @@ -0,0 +1,40 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, pytestCheckHook +, httpcore +, httpx +, pytest-asyncio +, sanic +, websockets +}: + +buildPythonPackage rec { + pname = "sanic-testing"; + version = "0.3.1"; + + src = fetchFromGitHub { + owner = "sanic-org"; + repo = "sanic-testing"; + rev = "v${version}"; + hash = "sha256-hBAq+/BKs0a01M89Nb8HaClqxB+W5PTfjVzef/m9SWs="; + }; + + propagatedBuildInputs = [ httpx sanic websockets httpcore ]; + + # `sanic` is explicitly set to null when building `sanic` itself + # to prevent infinite recursion. In that case we skip running + # the package at all. + doCheck = sanic != null; + dontUsePythonImportsCheck = sanic == null; + + checkInputs = [ pytestCheckHook pytest-asyncio ]; + pythonImportsCheck = [ "sanic_testing" ]; + + meta = with lib; { + description = "Core testing clients for the Sanic web framework"; + homepage = "https://github.com/sanic-org/sanic-testing"; + license = licenses.mit; + maintainers = with maintainers; [ AluisioASG ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 1128faed290f..65faa170d6f7 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7207,6 +7207,8 @@ in { sanic-routing = callPackage ../development/python-modules/sanic-routing { }; + sanic-testing = callPackage ../development/python-modules/sanic-testing { }; + sapi-python-client = callPackage ../development/python-modules/sapi-python-client { }; sarge = callPackage ../development/python-modules/sarge { }; From bd815d21219840d1aa688083179323ad0161fff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alu=C3=ADsio=20Augusto=20Silva=20Gon=C3=A7alves?= Date: Tue, 27 Apr 2021 10:31:42 -0300 Subject: [PATCH 4/4] python3Packages.sanic: 21.3.2 -> 21.3.4 While we're at it, revise the dependencies lists; there's been a couple of break-ups with 21.3.0. --- .../python-modules/sanic/default.nix | 34 ++++++++++--------- pkgs/top-level/python-packages.nix | 3 ++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/pkgs/development/python-modules/sanic/default.nix b/pkgs/development/python-modules/sanic/default.nix index e5995ed0b1e8..31dcc86e0bc4 100644 --- a/pkgs/development/python-modules/sanic/default.nix +++ b/pkgs/development/python-modules/sanic/default.nix @@ -1,42 +1,44 @@ { lib, buildPythonPackage, fetchPypi, doCheck ? true -, aiofiles, httptools, httpx, multidict, ujson, uvloop, websockets -, pytestCheckHook, beautifulsoup4, gunicorn, httpcore, uvicorn -, pytest-asyncio, pytest-benchmark, pytest-dependency, pytest-sanic, pytest-sugar, pytestcov +, aiofiles, httptools, multidict, sanic-routing, ujson, uvloop, websockets +, pytestCheckHook, beautifulsoup4, gunicorn, uvicorn, sanic-testing +, pytest-benchmark, pytest-sanic, pytest-sugar, pytestcov }: buildPythonPackage rec { pname = "sanic"; - version = "21.3.2"; + version = "21.3.4"; src = fetchPypi { inherit pname version; - sha256 = "84a04c5f12bf321bed3942597787f1854d15c18f157aebd7ced8c851ccc49e08"; + sha256 = "1cbd12b9138b3ca69656286b0be91fff02b826e8cb72dd76a2ca8c5eb1288d8e"; }; postPatch = '' + # Loosen dependency requirements. substituteInPlace setup.py \ - --replace '"multidict==5.0.0"' '"multidict"' \ - --replace '"httpx==0.15.4"' '"httpx"' \ - --replace '"httpcore==0.3.0"' '"httpcore"' \ - --replace '"pytest==5.2.1"' '"pytest"' + --replace '"pytest==5.2.1"' '"pytest"' \ + --replace '"gunicorn==20.0.4"' '"gunicorn"' \ + --replace '"pytest-sanic",' "" + # Patch a request headers test to allow brotli encoding + # (we build httpx with brotli support, upstream doesn't). + substituteInPlace tests/test_headers.py \ + --replace "deflate\r\n" "deflate, br\r\n" ''; propagatedBuildInputs = [ - aiofiles httptools httpx multidict ujson uvloop websockets + sanic-routing httptools uvloop ujson aiofiles websockets multidict ]; checkInputs = [ - pytestCheckHook beautifulsoup4 gunicorn httpcore uvicorn - pytest-asyncio pytest-benchmark pytest-dependency pytest-sanic pytest-sugar pytestcov + sanic-testing gunicorn pytestcov beautifulsoup4 pytest-sanic pytest-sugar + pytest-benchmark pytestCheckHook uvicorn ]; inherit doCheck; disabledTests = [ "test_gunicorn" # No "examples" directory in pypi distribution. - "test_logo" # Fails to filter out "DEBUG asyncio:selector_events.py:59 Using selector: EpollSelector" "test_zero_downtime" # No "examples.delayed_response.app" module in pypi distribution. - "test_reloader_live" # OSError: [Errno 98] error while attempting to bind on address ('127.0.0.1', 42104) ]; __darwinAllowLocalNetworking = true; @@ -45,8 +47,8 @@ buildPythonPackage rec { meta = with lib; { description = "A microframework based on uvloop, httptools, and learnings of flask"; - homepage = "https://github.com/channelcat/sanic/"; + homepage = "https://github.com/sanic-org/sanic/"; license = licenses.mit; - maintainers = [ maintainers.costrouc ]; + maintainers = with maintainers; [ costrouc AluisioASG ]; }; } diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 65faa170d6f7..90f766ed4592 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7201,6 +7201,9 @@ in { doCheck = false; meta.broken = false; }); + # Don't pass any `sanic` to avoid dependency loops. `sanic-testing` + # has special logic to disable tests when this is the case. + sanic-testing = self.sanic-testing.override { sanic = null; }; }; sanic-auth = callPackage ../development/python-modules/sanic-auth { };