2021-04-05 15:23:46 +00:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
2022-09-14 18:05:37 +00:00
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
, flask
|
|
|
|
, limits
|
2023-01-20 10:41:00 +00:00
|
|
|
, ordered-set
|
2022-09-14 18:05:37 +00:00
|
|
|
, rich
|
|
|
|
, typing-extensions
|
|
|
|
|
|
|
|
, asgiref
|
|
|
|
, hiro
|
2021-04-05 15:23:46 +00:00
|
|
|
, pymemcache
|
2022-09-14 18:05:37 +00:00
|
|
|
, pytest-mock
|
2021-04-05 15:23:46 +00:00
|
|
|
, pytestCheckHook
|
|
|
|
, redis
|
2022-09-14 18:05:37 +00:00
|
|
|
, pymongo
|
2021-04-05 15:23:46 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "Flask-Limiter";
|
2023-01-20 10:41:00 +00:00
|
|
|
version = "3.1.0";
|
|
|
|
format = "setuptools";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "alisaifee";
|
|
|
|
repo = "flask-limiter";
|
2023-01-20 10:41:00 +00:00
|
|
|
rev = "refs/tags/${version}";
|
|
|
|
hash = "sha256-eAJRqyAH1j1NHYfagRZM2fPE6hm9+tJHD8FMqvgvMBI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace requirements/main.txt \
|
|
|
|
--replace "rich>=12,<13" "rich"
|
|
|
|
|
|
|
|
sed -i "/--cov/d" pytest.ini
|
|
|
|
|
|
|
|
# flask-restful is unmaintained and breaks regularly, don't depend on it
|
|
|
|
sed -i "/import flask_restful/d" tests/test_views.py
|
|
|
|
'';
|
|
|
|
|
2022-09-14 18:05:37 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
flask
|
|
|
|
limits
|
2023-01-20 10:41:00 +00:00
|
|
|
ordered-set
|
2022-09-14 18:05:37 +00:00
|
|
|
rich
|
|
|
|
typing-extensions
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2022-09-14 18:05:37 +00:00
|
|
|
asgiref
|
|
|
|
pytest-mock
|
2021-04-05 15:23:46 +00:00
|
|
|
pytestCheckHook
|
|
|
|
hiro
|
|
|
|
redis
|
|
|
|
pymemcache
|
2022-09-14 18:05:37 +00:00
|
|
|
pymongo
|
2021-04-05 15:23:46 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
disabledTests = [
|
2022-09-14 18:05:37 +00:00
|
|
|
# flask-restful is unmaintained and breaks regularly
|
|
|
|
"test_flask_restful_resource"
|
|
|
|
|
|
|
|
# Requires running a docker instance
|
|
|
|
"test_clear_limits"
|
2021-04-05 15:23:46 +00:00
|
|
|
"test_constructor_arguments_over_config"
|
2022-09-14 18:05:37 +00:00
|
|
|
"test_custom_key_prefix"
|
|
|
|
"test_custom_key_prefix_with_headers"
|
2021-04-05 15:23:46 +00:00
|
|
|
"test_fallback_to_memory_backoff_check"
|
2022-09-14 18:05:37 +00:00
|
|
|
"test_fallback_to_memory_config"
|
2021-04-05 15:23:46 +00:00
|
|
|
"test_fallback_to_memory_with_global_override"
|
|
|
|
"test_redis_request_slower_than_fixed_window"
|
|
|
|
"test_redis_request_slower_than_moving_window"
|
2022-09-14 18:05:37 +00:00
|
|
|
"test_reset_unsupported"
|
|
|
|
|
|
|
|
# Requires redis
|
|
|
|
"test_fallback_to_memory"
|
|
|
|
];
|
|
|
|
|
|
|
|
disabledTestPaths = [
|
|
|
|
# requires running redis/memcached/mongodb
|
|
|
|
"tests/test_storage.py"
|
2021-04-05 15:23:46 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
pythonImportsCheck = [ "flask_limiter" ];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Rate limiting for flask applications";
|
|
|
|
homepage = "https://flask-limiter.readthedocs.org/";
|
|
|
|
license = licenses.mit;
|
|
|
|
};
|
|
|
|
}
|