1{
2 lib,
3 aiohttp,
4 aiomcache,
5 buildPythonPackage,
6 fetchFromGitHub,
7 marshmallow,
8 msgpack,
9 pkgs,
10 pytest-asyncio,
11 pytest-cov-stub,
12 pytest-mock,
13 pytestCheckHook,
14 pythonOlder,
15 redis,
16 setuptools,
17}:
18
19buildPythonPackage rec {
20 pname = "aiocache";
21 version = "0.12.3";
22 pyproject = true;
23
24 disabled = pythonOlder "3.8";
25
26 src = fetchFromGitHub {
27 owner = "aio-libs";
28 repo = "aiocache";
29 rev = "refs/tags/v${version}";
30 hash = "sha256-4QYCRXMWlt9fsiWgUTc2pKzXG7AG/zGmd4HT5ggIZNM=";
31 };
32
33 build-system = [ setuptools ];
34
35 optional-dependencies = {
36 redis = [ redis ];
37 memcached = [ aiomcache ];
38 msgpack = [ msgpack ];
39 };
40
41 nativeCheckInputs = [
42 aiohttp
43 marshmallow
44 pytest-asyncio
45 pytest-cov-stub
46 pytest-mock
47 pytestCheckHook
48 ] ++ lib.flatten (lib.attrValues optional-dependencies);
49
50 pytestFlagsArray = [
51 "-W"
52 "ignore::DeprecationWarning"
53 # TypeError: object MagicMock can't be used in 'await' expression
54 "--deselect=tests/ut/backends/test_redis.py::TestRedisBackend::test_close"
55 ];
56
57 disabledTests = [
58 # Test calls apache benchmark and fails, no usable output
59 "test_concurrency_error_rates"
60 ];
61
62 disabledTestPaths = [
63 # Benchmark and performance tests are not relevant for Nixpkgs
64 "tests/performance/"
65 ];
66
67 preCheck = ''
68 ${lib.getBin pkgs.redis}/bin/redis-server &
69 REDIS_PID=$!
70
71 ${lib.getBin pkgs.memcached}/bin/memcached &
72 MEMCACHED_PID=$!
73 '';
74
75 postCheck = ''
76 kill $REDIS_PID
77 kill $MEMCACHED_PID
78 '';
79
80 __darwinAllowLocalNetworking = true;
81
82 pythonImportsCheck = [ "aiocache" ];
83
84 meta = with lib; {
85 description = "Python API Rate Limit Decorator";
86 homepage = "https://github.com/aio-libs/aiocache";
87 changelog = "https://github.com/aio-libs/aiocache/releases/tag/v${version}";
88 license = licenses.bsd3;
89 maintainers = with maintainers; [ fab ];
90 };
91}