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