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