Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.03 139 lines 3.2 kB view raw
1{ lib 2, buildPythonPackage 3, fetchPypi 4, httptools 5, aiofiles 6, websockets 7, multidict 8, uvloop 9, ujson 10, pytest 11, gunicorn 12, pytestcov 13, aiohttp 14, beautifulsoup4 15, pytest-sanic 16, pytest-sugar 17, pytest-benchmark 18 19# required just httpcore / requests-async 20, h11 21, h2 22, certifi 23, chardet 24, idna 25, requests 26, rfc3986 27, uvicorn 28}: 29 30let 31 32 # This version of sanic depends on two packages that have been deprecated by 33 # their development teams: 34 # 35 # - requests-async [where first line of pypi says to use `http3` instead now] 36 # - httpcore [where the homepage redirects to `http3` now] 37 # 38 # Since no other packages in nixpkg depend on these right now, define these 39 # packages just as local dependencies here, to avoid bloat. 40 41 httpcore = buildPythonPackage rec { 42 pname = "httpcore"; 43 version = "0.3.0"; 44 src = fetchPypi { 45 inherit pname version; 46 sha256 = "0n3bamaixxhcm27gf1ws3g6rkamvqx87087c88r6hyyl52si1ycn"; 47 }; 48 49 propagatedBuildInputs = [ certifi chardet h11 h2 idna rfc3986 ]; 50 51 # relax pinned old version of h11 52 postConfigure = '' 53 substituteInPlace setup.py \ 54 --replace "h11==0.8.*" "h11" 55 ''; 56 57 # LICENCE.md gets propagated without this, causing collisions 58 postInstall = '' 59 rm $out/LICENSE.md 60 ''; 61 }; 62 63 requests-async = buildPythonPackage rec { 64 pname = "requests-async"; 65 version = "0.5.0"; 66 src = fetchPypi { 67 inherit pname version; 68 sha256 = "8731420451383196ecf2fd96082bfc8ae5103ada90aba185888499d7784dde6f"; 69 }; 70 71 propagatedBuildInputs = [ requests httpcore ]; 72 73 # LICENCE.md gets propagated without this, causing collisions 74 postInstall = '' 75 rm $out/LICENSE.md 76 ''; 77 }; 78 79in 80 81buildPythonPackage rec { 82 pname = "sanic"; 83 version = "19.6.3"; 84 85 src = fetchPypi { 86 inherit pname version; 87 sha256 = "0b1qqsvdjkibrw5kgr0pm7n7jzb1403132wjmb0lx3k5wyvqfi95"; 88 }; 89 90 propagatedBuildInputs = [ 91 httptools 92 aiofiles 93 websockets 94 multidict 95 requests-async 96 uvloop 97 ujson 98 ]; 99 100 checkInputs = [ 101 pytest 102 gunicorn 103 pytestcov 104 aiohttp 105 beautifulsoup4 106 pytest-sanic 107 pytest-sugar 108 pytest-benchmark 109 uvicorn 110 ]; 111 112 # Sanic says it needs websockets 7.x, but the changelog for 8.x is actually 113 # nearly compatible with sanic's use. So relax this constraint, with a small 114 # required code change. 115 postConfigure = '' 116 substituteInPlace setup.py --replace \ 117 "websockets>=7.0,<8.0" \ 118 "websockets>=7.0,<9.0" 119 substituteInPlace sanic/websocket.py --replace \ 120 "self.websocket.subprotocol = subprotocol" \ 121 "self.websocket.subprotocol = subprotocol 122 self.websocket.is_client = False" 123 ''; 124 125 # 10/500 tests ignored due to missing directory and 126 # requiring network access 127 checkPhase = '' 128 pytest --ignore tests/test_blueprints.py \ 129 --ignore tests/test_routes.py \ 130 --ignore tests/test_worker.py 131 ''; 132 133 meta = with lib; { 134 description = "A microframework based on uvloop, httptools, and learnings of flask"; 135 homepage = http://github.com/channelcat/sanic/; 136 license = licenses.mit; 137 maintainers = [ maintainers.costrouc ]; 138 }; 139}