From a3e33b69bac863837e63dfeac5fcd25f34c47ef1 Mon Sep 17 00:00:00 2001 From: Simon Chatterjee Date: Mon, 9 Sep 2019 19:15:41 +0100 Subject: [PATCH 1/4] pythonPackages.uvicorn: fix propagated LICENSE.md --- pkgs/development/python-modules/uvicorn/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/development/python-modules/uvicorn/default.nix b/pkgs/development/python-modules/uvicorn/default.nix index 9f7efef1e84..a525846be76 100644 --- a/pkgs/development/python-modules/uvicorn/default.nix +++ b/pkgs/development/python-modules/uvicorn/default.nix @@ -43,6 +43,12 @@ buildPythonPackage rec { pytest ''; + # LICENCE.md gets propagated without this, causing collisions + # see https://github.com/encode/uvicorn/issues/392 + postInstall = '' + rm $out/LICENSE.md + ''; + meta = with lib; { homepage = https://www.uvicorn.org/; description = "The lightning-fast ASGI server"; From 8b263a4530e1af5c46222f33a16c6e9d3764f21b Mon Sep 17 00:00:00 2001 From: Simon Chatterjee Date: Sun, 8 Sep 2019 20:10:03 +0100 Subject: [PATCH 2/4] pythonPackages.sanic: 19.3.1 -> 19.6.3 The new version depend on two packages that are not currently in nixpkgs, and marked as already deprecated by their author. So just include them locally. Also, adapt to the fact that the version of websockets in nixpkgs is 8.x, when sanic wants 7.x. --- .../python-modules/sanic/default.nix | 79 ++++++++++++++++++- 1 file changed, 75 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/sanic/default.nix b/pkgs/development/python-modules/sanic/default.nix index 6aae4c11fdd..5c1e0e81246 100644 --- a/pkgs/development/python-modules/sanic/default.nix +++ b/pkgs/development/python-modules/sanic/default.nix @@ -15,15 +15,76 @@ , pytest-sanic , pytest-sugar , pytest-benchmark + +# required just httpcore / requests-async +, h11 +, h2 +, certifi +, chardet +, idna +, requests +, rfc3986 +, uvicorn }: +let + + # This version of sanic depends on two packages that have been deprecated by + # their development teams: + # + # - requests-async [where first line of pypi says to use `http3` instead now] + # - httpcore [where the homepage redirects to `http3` now] + # + # Since no other packages in nixpkg depend on these right now, define these + # packages just as local dependencies here, to avoid bloat. + + httpcore = buildPythonPackage rec { + pname = "httpcore"; + version = "0.3.0"; + src = fetchPypi { + inherit pname version; + sha256 = "0n3bamaixxhcm27gf1ws3g6rkamvqx87087c88r6hyyl52si1ycn"; + }; + + propagatedBuildInputs = [ certifi chardet h11 h2 idna rfc3986 ]; + + # relax pinned old version of h11 + postConfigure = '' + substituteInPlace setup.py \ + --replace "h11==0.8.*" "h11" + ''; + + # LICENCE.md gets propagated without this, causing collisions + postInstall = '' + rm $out/LICENSE.md + ''; + }; + + requests-async = buildPythonPackage rec { + pname = "requests-async"; + version = "0.5.0"; + src = fetchPypi { + inherit pname version; + sha256 = "8731420451383196ecf2fd96082bfc8ae5103ada90aba185888499d7784dde6f"; + }; + + propagatedBuildInputs = [ requests httpcore ]; + + # LICENCE.md gets propagated without this, causing collisions + postInstall = '' + rm $out/LICENSE.md + ''; + }; + +in + buildPythonPackage rec { pname = "sanic"; - version = "19.3.1"; + version = "19.6.3"; src = fetchPypi { inherit pname version; - sha256 = "ce434eb154872ca64493a6c3a288f11fd10bca0de7be7bf9f1d0d063185e51ec"; + sha256 = "0b1qqsvdjkibrw5kgr0pm7n7jzb1403132wjmb0lx3k5wyvqfi95"; }; propagatedBuildInputs = [ @@ -31,6 +92,7 @@ buildPythonPackage rec { aiofiles websockets multidict + requests-async uvloop ujson ]; @@ -44,11 +106,20 @@ buildPythonPackage rec { pytest-sanic pytest-sugar pytest-benchmark + uvicorn ]; + # Sanic says it needs websockets 7.x, but the changelog for 8.x is actually + # nearly compatible with sanic's use. So relax this constraint, with a small + # required code change. postConfigure = '' - substituteInPlace setup.py \ - --replace "websockets>=6.0,<7.0" "websockets" + substituteInPlace setup.py --replace \ + "websockets>=7.0,<8.0" \ + "websockets>=7.0,<9.0" + substituteInPlace sanic/websocket.py --replace \ + "self.websocket.subprotocol = subprotocol" \ + "self.websocket.subprotocol = subprotocol + self.websocket.is_client = False" ''; # 10/500 tests ignored due to missing directory and From 1cb9d4d85bd9f23aff05f60adda7280e7bd05c9c Mon Sep 17 00:00:00 2001 From: Simon Chatterjee Date: Wed, 11 Sep 2019 20:39:28 +0100 Subject: [PATCH 3/4] pythonPackages.datasette: 0.28 -> 0.29.3 Patch donated by @wd51, and removes sanic dependency. --- .../python-modules/datasette/default.nix | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkgs/development/python-modules/datasette/default.nix b/pkgs/development/python-modules/datasette/default.nix index 48de7e86b92..828976f0e9f 100644 --- a/pkgs/development/python-modules/datasette/default.nix +++ b/pkgs/development/python-modules/datasette/default.nix @@ -3,7 +3,6 @@ , fetchFromGitHub , click , click-default-group -, sanic , jinja2 , hupper , pint @@ -14,17 +13,20 @@ , black , aiohttp , beautifulsoup4 +, uvicorn +, asgiref +, aiofiles }: buildPythonPackage rec { pname = "datasette"; - version = "0.28"; + version = "0.29.3"; src = fetchFromGitHub { owner = "simonw"; repo = "datasette"; rev = version; - sha256 = "1m2s03gyq0ghjc3s0b5snpinisddywpgii2f0zqa3v4ljmzanx7h"; + sha256 = "0cib7pd4z240ncck0pskzvizblhwkr42fsjpd719wdxy4scs7yqa"; }; buildInputs = [ pytestrunner ]; @@ -32,11 +34,12 @@ buildPythonPackage rec { propagatedBuildInputs = [ click click-default-group - sanic jinja2 hupper pint pluggy + uvicorn + aiofiles ]; checkInputs = [ @@ -45,6 +48,7 @@ buildPythonPackage rec { aiohttp beautifulsoup4 black + asgiref ]; postConfigure = '' @@ -52,8 +56,9 @@ buildPythonPackage rec { --replace "click-default-group==1.2" "click-default-group" \ --replace "Sanic==0.7.0" "Sanic" \ --replace "hupper==1.0" "hupper" \ - --replace "pint==0.8.1" "pint" \ - --replace "Jinja2==2.10.1" "Jinja2" + --replace "pint~=0.8.1" "pint" \ + --replace "Jinja2==2.10.1" "Jinja2" \ + --replace "uvicorn~=0.8.4" "uvicorn" ''; # many tests require network access From ee96f91d2c28e177c6af7307aff5f6ed2be15f13 Mon Sep 17 00:00:00 2001 From: Simon Chatterjee Date: Sun, 29 Sep 2019 21:00:32 +0100 Subject: [PATCH 4/4] pythonPackages.websocket: disable failing tests on darwin --- pkgs/development/python-modules/websockets/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/python-modules/websockets/default.nix b/pkgs/development/python-modules/websockets/default.nix index 589a8089fca..9202d02ad5b 100644 --- a/pkgs/development/python-modules/websockets/default.nix +++ b/pkgs/development/python-modules/websockets/default.nix @@ -3,6 +3,7 @@ , buildPythonPackage , pythonOlder , pytest +, stdenv }: buildPythonPackage rec { @@ -18,6 +19,9 @@ buildPythonPackage rec { disabled = pythonOlder "3.3"; + # Tests fail on Darwin with `OSError: AF_UNIX path too long` + doCheck = !stdenv.isDarwin; + meta = with lib; { description = "WebSocket implementation in Python 3"; homepage = "https://github.com/aaugustin/websockets";