about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/sanic/default.nix
blob: 5f610f6feab0a80800267c4ca87dc494b4bed8be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ lib, buildPythonPackage, fetchPypi, doCheck ? true
, 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.4";

  src = fetchPypi {
    inherit pname version;
    sha256 = "1cbd12b9138b3ca69656286b0be91fff02b826e8cb72dd76a2ca8c5eb1288d8e";
  };

  postPatch = ''
    # Loosen dependency requirements.
    substituteInPlace setup.py \
      --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 = [
    sanic-routing httptools uvloop ujson aiofiles websockets multidict
  ];

  checkInputs = [
    sanic-testing gunicorn pytestcov beautifulsoup4 pytest-sanic pytest-sugar
    pytest-benchmark pytestCheckHook uvicorn
  ];

  inherit doCheck;

  disabledTests = [
    # No "examples" directory in pypi distribution
    "test_gunicorn"
    "test_zero_downtime"
    # flaky
    "test_keep_alive_client_timeout"
    "test_check_timeouts_request_timeout"
    "test_check_timeouts_response_timeout"
    "test_reloader_live"
  ];

  __darwinAllowLocalNetworking = true;

  pythonImportsCheck = [ "sanic" ];

  meta = with lib; {
    description = "A microframework based on uvloop, httptools, and learnings of flask";
    homepage = "https://github.com/sanic-org/sanic/";
    license = licenses.mit;
    maintainers = with maintainers; [ costrouc AluisioASG ];
  };
}