1{ lib
2, fetchFromGitHub
3, pythonOlder
4, buildPythonPackage
5, setuptools
6
7# propagated
8, django
9, hiredis
10, lz4
11, msgpack
12, redis
13
14# testing
15, pkgs
16, pytest-django
17, pytest-mock
18, pytestCheckHook
19}:
20
21buildPythonPackage rec {
22 pname = "django-redis";
23 version = "5.4.0";
24 pyproject = true;
25
26 disabled = pythonOlder "3.6";
27
28 src = fetchFromGitHub {
29 owner = "jazzband";
30 repo = "django-redis";
31 rev = "refs/tags/${version}";
32 hash = "sha256-m7z3c7My24vrSSnyfDQ/LlWhy7pV4U0L8LATMvkfczc=";
33 };
34
35 postPatch = ''
36 sed -i '/-cov/d' setup.cfg
37 '';
38
39 nativeBuildInputs = [
40 setuptools
41 ];
42
43 propagatedBuildInputs = [
44 django
45 lz4
46 msgpack
47 redis
48 ];
49
50 passthru.optional-dependencies = {
51 hiredis = [
52 redis
53 ] ++ redis.optional-dependencies.hiredis;
54 };
55
56 pythonImportsCheck = [
57 "django_redis"
58 ];
59
60 DJANGO_SETTINGS_MODULE = "tests.settings.sqlite";
61
62 preCheck = ''
63 ${pkgs.redis}/bin/redis-server &
64 REDIS_PID=$!
65 '';
66
67 postCheck = ''
68 kill $REDIS_PID
69 '';
70
71 nativeCheckInputs = [
72 pytest-django
73 pytest-mock
74 pytestCheckHook
75 ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
76
77 pytestFlagsArray = [
78 "-W"
79 "ignore::DeprecationWarning"
80 ];
81
82 disabledTests = [
83 # ModuleNotFoundError: No module named 'test_cache_options'
84 "test_custom_key_function"
85 # ModuleNotFoundError: No module named 'test_client'
86 "test_delete_pattern_calls_delete_for_given_keys"
87 "test_delete_pattern_calls_get_client_given_no_client"
88 "test_delete_pattern_calls_make_pattern"
89 "test_delete_pattern_calls_pipeline_delete_and_execute"
90 "test_delete_pattern_calls_scan_iter"
91 "test_delete_pattern_calls_scan_iter_with_count_if_itersize_given"
92 ];
93
94 meta = with lib; {
95 description = "Full featured redis cache backend for Django";
96 homepage = "https://github.com/jazzband/django-redis";
97 changelog = "https://github.com/jazzband/django-redis/releases/tag/${version}";
98 license = licenses.bsd3;
99 maintainers = with maintainers; [ hexa ];
100 };
101}