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 tag = "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 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 ]
83 ++ optional-dependencies.json
84 ++ optional-dependencies.security;
85
86 preCheck = ''
87 export HOME=$(mktemp -d);
88 '';
89
90 enabledTestPaths = [
91 # Integration tests require local DBs
92 "tests/unit"
93 ];
94
95 disabledTests = [
96 # Tests are flaky in the sandbox
97 "test_remove_expired_responses"
98 # Tests that broke with urllib 2.0.5
99 "test_request_only_if_cached__stale_if_error__expired"
100 "test_stale_if_error__error_code"
101 ];
102
103 pythonImportsCheck = [ "requests_cache" ];
104
105 meta = with lib; {
106 description = "Persistent cache for requests library";
107 homepage = "https://github.com/reclosedev/requests-cache";
108 changelog = "https://github.com/requests-cache/requests-cache/blob/v${version}/HISTORY.md";
109 license = licenses.bsd3;
110 maintainers = with maintainers; [ fab ];
111 };
112}