2022-05-18 14:49:53 +00:00
|
|
|
{ lib
|
2024-02-29 20:09:43 +00:00
|
|
|
, aetcd
|
2022-05-18 14:49:53 +00:00
|
|
|
, buildPythonPackage
|
2024-02-29 20:09:43 +00:00
|
|
|
, coredis
|
2022-05-18 14:49:53 +00:00
|
|
|
, deprecated
|
2023-03-15 16:39:30 +00:00
|
|
|
, etcd3
|
2024-02-29 20:09:43 +00:00
|
|
|
, fetchFromGitHub
|
2022-05-18 14:49:53 +00:00
|
|
|
, hiro
|
2023-07-15 17:15:38 +00:00
|
|
|
, importlib-resources
|
2024-02-29 20:09:43 +00:00
|
|
|
, motor
|
2022-05-18 14:49:53 +00:00
|
|
|
, packaging
|
|
|
|
, pymemcache
|
|
|
|
, pymongo
|
|
|
|
, pytest-asyncio
|
|
|
|
, pytest-lazy-fixture
|
|
|
|
, pytestCheckHook
|
|
|
|
, pythonOlder
|
|
|
|
, redis
|
|
|
|
, setuptools
|
|
|
|
, typing-extensions
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "limits";
|
2024-01-13 08:15:51 +00:00
|
|
|
version = "3.7.0";
|
2024-02-29 20:09:43 +00:00
|
|
|
pyproject = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "alisaifee";
|
2024-02-29 20:09:43 +00:00
|
|
|
repo = "limits";
|
2023-01-20 10:41:00 +00:00
|
|
|
rev = "refs/tags/${version}";
|
2022-05-18 14:49:53 +00:00
|
|
|
# Upstream uses versioneer, which relies on git attributes substitution.
|
|
|
|
# This leads to non-reproducible archives on github. Remove the substituted
|
|
|
|
# file here, and recreate it later based on our version info.
|
2022-06-16 17:23:12 +00:00
|
|
|
postFetch = ''
|
2022-05-18 14:49:53 +00:00
|
|
|
rm "$out/limits/_version.py"
|
|
|
|
'';
|
2024-01-13 08:15:51 +00:00
|
|
|
hash = "sha256-0h3ofungHkjycUvNJ3jf+VB/GSrshgUDECN2YoPGzzg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace pytest.ini \
|
|
|
|
--replace-fail "--cov=limits" "" \
|
|
|
|
--replace-fail "-K" ""
|
|
|
|
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace-fail "versioneer.get_version()" "'${version}'"
|
|
|
|
|
|
|
|
# Recreate _version.py, deleted at fetch time due to non-reproducibility.
|
|
|
|
echo 'def get_versions(): return {"version": "${version}"}' > limits/_version.py
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
setuptools
|
|
|
|
];
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
deprecated
|
2023-07-15 17:15:38 +00:00
|
|
|
importlib-resources
|
2022-05-18 14:49:53 +00:00
|
|
|
packaging
|
|
|
|
typing-extensions
|
|
|
|
];
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
passthru.optional-dependencies = {
|
|
|
|
redis = [
|
|
|
|
redis
|
|
|
|
];
|
|
|
|
rediscluster = [
|
|
|
|
redis
|
|
|
|
];
|
|
|
|
memcached = [
|
|
|
|
pymemcache
|
|
|
|
];
|
|
|
|
mongodb = [
|
|
|
|
pymongo
|
|
|
|
];
|
|
|
|
etcd = [
|
|
|
|
etcd3
|
|
|
|
];
|
|
|
|
async-redis = [
|
|
|
|
coredis
|
|
|
|
];
|
|
|
|
# async-memcached = [
|
|
|
|
# emcache # Missing module
|
|
|
|
# ];
|
|
|
|
async-mongodb = [
|
|
|
|
motor
|
|
|
|
];
|
|
|
|
async-etcd = [
|
|
|
|
aetcd
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2022-05-18 14:49:53 +00:00
|
|
|
hiro
|
|
|
|
pytest-asyncio
|
|
|
|
pytest-lazy-fixture
|
|
|
|
pytestCheckHook
|
2024-02-29 20:09:43 +00:00
|
|
|
] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"limits"
|
|
|
|
];
|
|
|
|
|
|
|
|
pytestFlagsArray = [
|
|
|
|
# All other tests require a running Docker instance
|
|
|
|
"tests/test_limits.py"
|
|
|
|
"tests/test_ratelimit_parser.py"
|
|
|
|
"tests/test_limit_granularities.py"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2022-09-14 18:05:37 +00:00
|
|
|
description = "Rate limiting using various strategies and storage backends such as redis & memcached";
|
|
|
|
homepage = "https://github.com/alisaifee/limits";
|
2024-02-29 20:09:43 +00:00
|
|
|
changelog = "https://github.com/alisaifee/limits/releases/tag/${version}";
|
2022-05-18 14:49:53 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|