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