summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/aiocache/default.nix
blob: c4af88bf2cbf94655a200127347dfee606d01c4a (plain)
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
{
  lib,
  aiohttp,
  aiomcache,
  buildPythonPackage,
  fetchFromGitHub,
  marshmallow,
  memcachedTestHook,
  msgpack,
  pytest-asyncio,
  pytest-cov-stub,
  pytest-mock,
  pytestCheckHook,
  pythonAtLeast,
  redis,
  redisTestHook,
  setuptools,
}:

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

  src = fetchFromGitHub {
    owner = "aio-libs";
    repo = "aiocache";
    tag = "v${version}";
    hash = "sha256-4QYCRXMWlt9fsiWgUTc2pKzXG7AG/zGmd4HT5ggIZNM=";
  };

  build-system = [ setuptools ];

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

  nativeCheckInputs = [
    aiohttp
    marshmallow
    memcachedTestHook
    pytest-asyncio
    pytest-cov-stub
    pytest-mock
    pytestCheckHook
    redisTestHook
  ]
  ++ lib.concatAttrValues optional-dependencies;

  pytestFlags = [
    "-Wignore::DeprecationWarning"
    # Tests can time out and leave redis/valkey in an unusable state for later tests
    "-x"
  ];

  disabledTests = [
    # Test calls apache benchmark and fails, no usable output
    "test_concurrency_error_rates"
    # susceptible to timing out / short ttl
    "test_cached_stampede"
    "test_locking_dogpile_lease_expiration"
    "test_set_ttl_handle"
    "test_set_cancel_previous_ttl_handle"
  ]
  ++ lib.optionals (pythonAtLeast "3.13") [
    # https://github.com/aio-libs/aiocache/issues/863
    "test_cache_write_doesnt_wait_for_future"
  ];

  disabledTestPaths = [
    # Benchmark and performance tests are not relevant for Nixpkgs
    "tests/performance/"
    # Full of timing-sensitive tests
    "tests/ut/backends/test_redis.py"

    # TypeError: object MagicMock can't be used in 'await' expression
    "tests/ut/backends/test_redis.py::TestRedisBackend::test_close"
  ];

  __darwinAllowLocalNetworking = true;

  pythonImportsCheck = [ "aiocache" ];

  meta = {
    description = "Asyncio cache supporting multiple backends (memory, redis, memcached, etc.)";
    homepage = "https://github.com/aio-libs/aiocache";
    changelog = "https://github.com/aio-libs/aiocache/releases/tag/v${version}";
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [ fab ];
  };
}