1{ lib
2, buildPythonPackage
3, deprecated
4, fetchFromGitHub
5, hiro
6, packaging
7, pymemcache
8, pymongo
9, pytest-asyncio
10, pytest-lazy-fixture
11, pytestCheckHook
12, pythonOlder
13, redis
14, setuptools
15, typing-extensions
16}:
17
18buildPythonPackage rec {
19 pname = "limits";
20 version = "2.7.0";
21 format = "setuptools";
22
23 disabled = pythonOlder "3.7";
24
25 src = fetchFromGitHub {
26 owner = "alisaifee";
27 repo = pname;
28 rev = version;
29 # Upstream uses versioneer, which relies on git attributes substitution.
30 # This leads to non-reproducible archives on github. Remove the substituted
31 # file here, and recreate it later based on our version info.
32 postFetch = ''
33 rm "$out/limits/_version.py"
34 '';
35 hash = "sha256-TBZElCogPtoR2qX1YjBgpYh99LhrvLHFtr2ogemo9/c=";
36 };
37
38 propagatedBuildInputs = [
39 deprecated
40 packaging
41 setuptools
42 typing-extensions
43 ];
44
45 checkInputs = [
46 hiro
47 pymemcache
48 pymongo
49 pytest-asyncio
50 pytest-lazy-fixture
51 pytestCheckHook
52 redis
53 ];
54
55 postPatch = ''
56 substituteInPlace pytest.ini \
57 --replace "--cov=limits" "" \
58 --replace "-K" ""
59
60 substituteInPlace setup.py \
61 --replace "versioneer.get_version()" "'${version}'"
62
63 # Recreate _version.py, deleted at fetch time due to non-reproducibility.
64 echo 'def get_versions(): return {"version": "${version}"}' > limits/_version.py
65 '';
66
67 pythonImportsCheck = [
68 "limits"
69 ];
70
71 pytestFlagsArray = [
72 # All other tests require a running Docker instance
73 "tests/test_limits.py"
74 "tests/test_ratelimit_parser.py"
75 "tests/test_limit_granularities.py"
76 ];
77
78 meta = with lib; {
79 description = "Rate limiting using various strategies and storage backends such as redis & memcached";
80 homepage = "https://github.com/alisaifee/limits";
81 license = licenses.mit;
82 maintainers = with maintainers; [ ];
83 };
84}