1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
{
lib,
buildPythonPackage,
fetchFromGitHub,
# build-system
poetry-core,
# optional dependencies
filelock,
psycopg,
psycopg-pool,
redis,
# test
pytestCheckHook,
pytest-asyncio,
pytest-xdist,
redisTestHook,
}:
buildPythonPackage rec {
pname = "pyrate-limiter";
version = "3.9.0";
pyproject = true;
src = fetchFromGitHub {
owner = "vutran1710";
repo = "PyrateLimiter";
tag = "v${version}";
hash = "sha256-CAN3OWxXQaAzrh2q6z0OxPs4i02L/g2ISYFdUMHsHpg=";
};
postPatch = ''
# tests cause too many connections to the postgres server and crash/timeout
sed -i "/create_postgres_bucket,/d" tests/conftest.py
'';
build-system = [ poetry-core ];
optional-dependencies = {
all = [
filelock
redis
psycopg
psycopg-pool
];
};
# Show each test name and track the slowest
# This helps with identifying bottlenecks in the test suite
# that are causing the build to time out on Hydra.
pytestFlags = [
"--durations=10"
"-vv"
];
nativeCheckInputs = [
pytestCheckHook
pytest-asyncio
pytest-xdist
redisTestHook
]
++ lib.concatAttrValues optional-dependencies;
disabledTestPaths = [
# Slow: > 1.5 seconds/test run standalone on a fast machine
# (Apple M3 Max with highest performance settings and 36GB RAM)
# and/or hang under load
# https://github.com/vutran1710/PyrateLimiter/issues/245
# https://github.com/vutran1710/PyrateLimiter/issues/247
"tests/test_bucket_all.py"
"tests/test_bucket_factory.py"
"tests/test_limiter.py"
"tests/test_multiprocessing.py"
];
pythonImportsCheck = [ "pyrate_limiter" ];
meta = {
description = "Python Rate-Limiter using Leaky-Bucket Algorimth Family";
homepage = "https://github.com/vutran1710/PyrateLimiter";
changelog = "https://github.com/vutran1710/PyrateLimiter/blob/${src.tag}/CHANGELOG.md";
license = lib.licenses.mit;
maintainers = [ ];
};
}
|