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 ] ++ lib.flatten (lib.attrValues optional-dependencies);
50
51 pytestFlagsArray = [
52 "-W"
53 "ignore::DeprecationWarning"
54 # TypeError: object MagicMock can't be used in 'await' expression
55 "--deselect=tests/ut/backends/test_redis.py::TestRedisBackend::test_close"
56 # Tests can time out and leave redis/valkey in an unusable state for later tests
57 "-x"
58 ];
59
60 disabledTests =
61 [
62 # Test calls apache benchmark and fails, no usable output
63 "test_concurrency_error_rates"
64 # susceptible to timing out / short ttl
65 "test_cached_stampede"
66 "test_locking_dogpile_lease_expiration"
67 "test_set_ttl_handle"
68 "test_set_cancel_previous_ttl_handle"
69 ]
70 ++ lib.optionals (pythonAtLeast "3.13") [
71 # https://github.com/aio-libs/aiocache/issues/863
72 "test_cache_write_doesnt_wait_for_future"
73 ];
74
75 disabledTestPaths = [
76 # Benchmark and performance tests are not relevant for Nixpkgs
77 "tests/performance/"
78 # Full of timing-sensitive tests
79 "tests/ut/backends/test_redis.py"
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}