about summary refs log tree commit diff
path: root/pkgs/development/python-modules/aiocache/default.nix
blob: 5d78252791b30d8d528fa2c3c4d7c6c8d8b1eba2 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{ lib
, aiohttp
, aiomcache
, buildPythonPackage
, fetchFromGitHub
, marshmallow
, msgpack
, pkgs
, pythonOlder
, pytest-asyncio
, pytest-mock
, pytestCheckHook
, redis
, setuptools
}:

buildPythonPackage rec {
  pname = "aiocache";
  version = "0.12.2";
  pyproject = true;

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "aio-libs";
    repo = "aiocache";
    rev = "refs/tags/v${version}";
    hash = "sha256-yvXDNJL8uxReaU81klVWudJwh1hmvg5GeeILcNpm/YA=";
  };

  postPatch = ''
    substituteInPlace setup.cfg \
      --replace-fail "--cov=aiocache --cov=tests/ --cov-report term" ""
  '';

  build-system = [
    setuptools
  ];

  optional-dependencies = {
    redis = [
      redis
    ];
    memcached = [
      aiomcache
    ];
    msgpack = [
      msgpack
    ];
  };

  nativeCheckInputs = [
    aiohttp
    marshmallow
    pytest-asyncio
    pytest-mock
    pytestCheckHook
  ] ++ lib.flatten (lib.attrValues optional-dependencies);

  pytestFlagsArray = [
    "-W" "ignore::DeprecationWarning"
    # TypeError: object MagicMock can't be used in 'await' expression
    "--deselect=tests/ut/backends/test_redis.py::TestRedisBackend::test_close"
  ];

  disabledTests = [
    # calls apache benchmark and fails, no usable output
    "test_concurrency_error_rates"
  ];

  preCheck = ''
    ${lib.getBin pkgs.redis}/bin/redis-server &
    REDIS_PID=$!

    ${lib.getBin pkgs.memcached}/bin/memcached &
    MEMCACHED_PID=$!
  '';

  postCheck = ''
    kill $REDIS_PID
    kill $MEMCACHED_PID
  '';

  __darwinAllowLocalNetworking = true;

  pythonImportsCheck = [
    "aiocache"
  ];

  meta = with lib; {
    description = "Python API Rate Limit Decorator";
    homepage = "https://github.com/aio-libs/aiocache";
    changelog = "https://github.com/aio-libs/aiocache/releases/tag/v${version}";
    license = with licenses; [ bsd3 ];
    maintainers = with maintainers; [ fab ];
  };
}