1{
2 lib,
3 attrs,
4 buildPythonPackage,
5 bson,
6 boto3,
7 botocore,
8 cattrs,
9 fetchFromGitHub,
10 itsdangerous,
11 platformdirs,
12 poetry-core,
13 psutil,
14 pymongo,
15 pytestCheckHook,
16 pytest-rerunfailures,
17 pytest-xdist,
18 pythonOlder,
19 pyyaml,
20 redis,
21 requests,
22 requests-mock,
23 responses,
24 rich,
25 tenacity,
26 time-machine,
27 timeout-decorator,
28 ujson,
29 urllib3,
30 url-normalize,
31}:
32
33buildPythonPackage rec {
34 pname = "requests-cache";
35 version = "1.2.1";
36 pyproject = true;
37
38 disabled = pythonOlder "3.8";
39
40 src = fetchFromGitHub {
41 owner = "requests-cache";
42 repo = "requests-cache";
43 rev = "refs/tags/v${version}";
44 hash = "sha256-juRCcBUr+Ko6kVPpUapwRbUGqWLKaRiCqppOc3S5FMU=";
45 };
46
47 nativeBuildInputs = [ poetry-core ];
48
49 propagatedBuildInputs = [
50 attrs
51 cattrs
52 platformdirs
53 requests
54 urllib3
55 url-normalize
56 ];
57
58 passthru.optional-dependencies = {
59 dynamodb = [
60 boto3
61 botocore
62 ];
63 mongodbo = [ pymongo ];
64 redis = [ redis ];
65 bson = [ bson ];
66 json = [ ujson ];
67 security = [ itsdangerous ];
68 yaml = [ pyyaml ];
69 };
70
71 nativeCheckInputs = [
72 psutil
73 pytestCheckHook
74 pytest-rerunfailures
75 pytest-xdist
76 requests-mock
77 responses
78 rich
79 tenacity
80 time-machine
81 timeout-decorator
82 ] ++ passthru.optional-dependencies.json ++ passthru.optional-dependencies.security;
83
84 preCheck = ''
85 export HOME=$(mktemp -d);
86 '';
87
88 pytestFlagsArray = [
89 # Integration tests require local DBs
90 "tests/unit"
91 ];
92
93 disabledTests = [
94 # Tests are flaky in the sandbox
95 "test_remove_expired_responses"
96 # Tests that broke with urllib 2.0.5
97 "test_request_only_if_cached__stale_if_error__expired"
98 "test_stale_if_error__error_code"
99 ];
100
101 pythonImportsCheck = [ "requests_cache" ];
102
103 meta = with lib; {
104 description = "Persistent cache for requests library";
105 homepage = "https://github.com/reclosedev/requests-cache";
106 changelog = "https://github.com/requests-cache/requests-cache/blob/v${version}/HISTORY.md";
107 license = licenses.bsd3;
108 maintainers = with maintainers; [ fab ];
109 };
110}