1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4
5, flask
6, limits
7, ordered-set
8, rich
9, typing-extensions
10
11, asgiref
12, hiro
13, pymemcache
14, pytest-mock
15, pytestCheckHook
16, redis
17, pymongo
18}:
19
20buildPythonPackage rec {
21 pname = "flask-limiter";
22 version = "3.1.0";
23 format = "setuptools";
24
25 src = fetchFromGitHub {
26 owner = "alisaifee";
27 repo = "flask-limiter";
28 rev = "refs/tags/${version}";
29 hash = "sha256-eAJRqyAH1j1NHYfagRZM2fPE6hm9+tJHD8FMqvgvMBI=";
30 };
31
32 postPatch = ''
33 substituteInPlace requirements/main.txt \
34 --replace "rich>=12,<13" "rich"
35
36 sed -i "/--cov/d" pytest.ini
37
38 # flask-restful is unmaintained and breaks regularly, don't depend on it
39 sed -i "/import flask_restful/d" tests/test_views.py
40 '';
41
42 propagatedBuildInputs = [
43 flask
44 limits
45 ordered-set
46 rich
47 typing-extensions
48 ];
49
50 nativeCheckInputs = [
51 asgiref
52 pytest-mock
53 pytestCheckHook
54 hiro
55 redis
56 pymemcache
57 pymongo
58 ];
59
60 disabledTests = [
61 # flask-restful is unmaintained and breaks regularly
62 "test_flask_restful_resource"
63
64 # Requires running a docker instance
65 "test_clear_limits"
66 "test_constructor_arguments_over_config"
67 "test_custom_key_prefix"
68 "test_custom_key_prefix_with_headers"
69 "test_fallback_to_memory_backoff_check"
70 "test_fallback_to_memory_config"
71 "test_fallback_to_memory_with_global_override"
72 "test_redis_request_slower_than_fixed_window"
73 "test_redis_request_slower_than_moving_window"
74 "test_reset_unsupported"
75
76 # Requires redis
77 "test_fallback_to_memory"
78 ];
79
80 disabledTestPaths = [
81 # requires running redis/memcached/mongodb
82 "tests/test_storage.py"
83 ];
84
85 pythonImportsCheck = [ "flask_limiter" ];
86
87 meta = with lib; {
88 description = "Rate limiting for flask applications";
89 homepage = "https://flask-limiter.readthedocs.org/";
90 license = licenses.mit;
91 maintainers = with maintainers; [ ];
92 };
93}