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