about summary refs log tree commit diff
path: root/pkgs/development/python-modules/requests-cache/default.nix
blob: cf282e472eb439a06c6fdc68184a127227da6a50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
  lib,
  attrs,
  buildPythonPackage,
  bson,
  boto3,
  botocore,
  cattrs,
  fetchFromGitHub,
  itsdangerous,
  platformdirs,
  poetry-core,
  psutil,
  pymongo,
  pytestCheckHook,
  pytest-rerunfailures,
  pytest-xdist,
  pythonOlder,
  pyyaml,
  redis,
  requests,
  requests-mock,
  responses,
  rich,
  tenacity,
  time-machine,
  timeout-decorator,
  ujson,
  urllib3,
  url-normalize,
}:

buildPythonPackage rec {
  pname = "requests-cache";
  version = "1.2.0";
  pyproject = true;

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "requests-cache";
    repo = "requests-cache";
    rev = "refs/tags/v${version}";
    hash = "sha256-w1ptKi/MH3kGZxLMUNq/Gs6btGx+n2fG4nfQUXCXmiY=";
  };

  nativeBuildInputs = [ poetry-core ];

  propagatedBuildInputs = [
    attrs
    cattrs
    platformdirs
    requests
    urllib3
    url-normalize
  ];

  passthru.optional-dependencies = {
    dynamodb = [
      boto3
      botocore
    ];
    mongodbo = [ pymongo ];
    redis = [ redis ];
    bson = [ bson ];
    json = [ ujson ];
    security = [ itsdangerous ];
    yaml = [ pyyaml ];
  };

  nativeCheckInputs = [
    psutil
    pytestCheckHook
    pytest-rerunfailures
    pytest-xdist
    requests-mock
    responses
    rich
    tenacity
    time-machine
    timeout-decorator
  ] ++ passthru.optional-dependencies.json ++ passthru.optional-dependencies.security;

  preCheck = ''
    export HOME=$(mktemp -d);
  '';

  pytestFlagsArray = [
    # Integration tests require local DBs
    "tests/unit"
  ];

  disabledTests = [
    # Tests are flaky in the sandbox
    "test_remove_expired_responses"
    # Tests that broke with urllib 2.0.5
    "test_request_only_if_cached__stale_if_error__expired"
    "test_stale_if_error__error_code"
  ];

  pythonImportsCheck = [ "requests_cache" ];

  meta = with lib; {
    description = "Persistent cache for requests library";
    homepage = "https://github.com/reclosedev/requests-cache";
    changelog = "https://github.com/requests-cache/requests-cache/blob/v${version}/HISTORY.md";
    license = licenses.bsd3;
    maintainers = with maintainers; [ fab ];
  };
}