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