1{ 2 lib, 3 asgiref, 4 buildPythonPackage, 5 fetchFromGitHub, 6 fetchpatch, 7 flask, 8 hiro, 9 limits, 10 ordered-set, 11 pymemcache, 12 pymongo, 13 pytest-cov-stub, 14 pytest-mock, 15 pytestCheckHook, 16 pythonOlder, 17 redis, 18 rich, 19 setuptools, 20 typing-extensions, 21}: 22 23buildPythonPackage rec { 24 pname = "flask-limiter"; 25 version = "3.12"; 26 pyproject = true; 27 28 disabled = pythonOlder "3.10"; 29 30 src = fetchFromGitHub { 31 owner = "alisaifee"; 32 repo = "flask-limiter"; 33 tag = version; 34 hash = "sha256-3GFbLQExd4c3Cyr7UDX/zOAfedOluXMwCbBhOgoKfn0="; 35 }; 36 37 patches = [ 38 # permit use of rich < 15 -- remove when updating past 3.12 39 (fetchpatch { 40 url = "https://github.com/alisaifee/flask-limiter/commit/008a5c89f249e18e5375f16d79efc3ac518e9bcc.patch"; 41 hash = "sha256-dvTPVnuPs7xCRfUBBA1bgeWGuevFUZ+Kgl9MBHdgfKU="; 42 }) 43 ]; 44 45 postPatch = '' 46 # flask-restful is unmaintained and breaks regularly, don't depend on it 47 substituteInPlace tests/test_views.py \ 48 --replace-fail "import flask_restful" "" 49 ''; 50 51 build-system = [ setuptools ]; 52 53 dependencies = [ 54 flask 55 limits 56 ordered-set 57 rich 58 ]; 59 60 optional-dependencies = { 61 redis = limits.optional-dependencies.redis; 62 memcached = limits.optional-dependencies.memcached; 63 mongodb = limits.optional-dependencies.mongodb; 64 }; 65 66 nativeCheckInputs = [ 67 asgiref 68 pytest-cov-stub 69 pytest-mock 70 pytestCheckHook 71 hiro 72 redis 73 pymemcache 74 pymongo 75 ]; 76 77 disabledTests = [ 78 # flask-restful is unmaintained and breaks regularly 79 "test_flask_restful_resource" 80 81 # Requires running a docker instance 82 "test_clear_limits" 83 "test_constructor_arguments_over_config" 84 "test_custom_key_prefix" 85 "test_custom_key_prefix_with_headers" 86 "test_fallback_to_memory_backoff_check" 87 "test_fallback_to_memory_config" 88 "test_fallback_to_memory_with_global_override" 89 "test_redis_request_slower_than_fixed_window" 90 "test_redis_request_slower_than_moving_window" 91 "test_reset_unsupported" 92 93 # Requires redis 94 "test_fallback_to_memory" 95 ]; 96 97 disabledTestPaths = [ 98 # requires running redis/memcached/mongodb 99 "tests/test_storage.py" 100 ]; 101 102 pythonImportsCheck = [ "flask_limiter" ]; 103 104 meta = with lib; { 105 description = "Rate limiting for flask applications"; 106 homepage = "https://flask-limiter.readthedocs.org/"; 107 changelog = "https://github.com/alisaifee/flask-limiter/blob/${src.tag}/HISTORY.rst"; 108 license = licenses.mit; 109 maintainers = [ ]; 110 }; 111}