1{
2 lib,
3 aiohttp,
4 aiomcache,
5 buildPythonPackage,
6 fetchFromGitHub,
7 marshmallow,
8 memcachedTestHook,
9 msgpack,
10 pytest-asyncio,
11 pytest-cov-stub,
12 pytest-mock,
13 pytestCheckHook,
14 pythonAtLeast,
15 redis,
16 redisTestHook,
17 setuptools,
18}:
19
20buildPythonPackage rec {
21 pname = "aiocache";
22 version = "0.12.3";
23 pyproject = true;
24
25 src = fetchFromGitHub {
26 owner = "aio-libs";
27 repo = "aiocache";
28 tag = "v${version}";
29 hash = "sha256-4QYCRXMWlt9fsiWgUTc2pKzXG7AG/zGmd4HT5ggIZNM=";
30 };
31
32 build-system = [ setuptools ];
33
34 optional-dependencies = {
35 redis = [ redis ];
36 memcached = [ aiomcache ];
37 msgpack = [ msgpack ];
38 };
39
40 nativeCheckInputs = [
41 aiohttp
42 marshmallow
43 memcachedTestHook
44 pytest-asyncio
45 pytest-cov-stub
46 pytest-mock
47 pytestCheckHook
48 redisTestHook
49 ]
50 ++ lib.flatten (lib.attrValues optional-dependencies);
51
52 pytestFlags = [
53 "-Wignore::DeprecationWarning"
54 # Tests can time out and leave redis/valkey in an unusable state for later tests
55 "-x"
56 ];
57
58 disabledTests = [
59 # Test calls apache benchmark and fails, no usable output
60 "test_concurrency_error_rates"
61 # susceptible to timing out / short ttl
62 "test_cached_stampede"
63 "test_locking_dogpile_lease_expiration"
64 "test_set_ttl_handle"
65 "test_set_cancel_previous_ttl_handle"
66 ]
67 ++ lib.optionals (pythonAtLeast "3.13") [
68 # https://github.com/aio-libs/aiocache/issues/863
69 "test_cache_write_doesnt_wait_for_future"
70 ];
71
72 disabledTestPaths = [
73 # Benchmark and performance tests are not relevant for Nixpkgs
74 "tests/performance/"
75 # Full of timing-sensitive tests
76 "tests/ut/backends/test_redis.py"
77
78 # TypeError: object MagicMock can't be used in 'await' expression
79 "tests/ut/backends/test_redis.py::TestRedisBackend::test_close"
80 ];
81
82 __darwinAllowLocalNetworking = true;
83
84 pythonImportsCheck = [ "aiocache" ];
85
86 meta = {
87 description = "Asyncio cache supporting multiple backends (memory, redis, memcached, etc.)";
88 homepage = "https://github.com/aio-libs/aiocache";
89 changelog = "https://github.com/aio-libs/aiocache/releases/tag/v${version}";
90 license = lib.licenses.bsd3;
91 maintainers = with lib.maintainers; [ fab ];
92 };
93}