at 24.11-pre 2.5 kB view raw
1{ 2 lib, 3 aetcd, 4 buildPythonPackage, 5 coredis, 6 deprecated, 7 etcd3, 8 fetchFromGitHub, 9 hiro, 10 importlib-resources, 11 motor, 12 packaging, 13 pymemcache, 14 pymongo, 15 pytest-asyncio, 16 pytest-lazy-fixture, 17 pytestCheckHook, 18 pythonOlder, 19 redis, 20 setuptools, 21 typing-extensions, 22}: 23 24buildPythonPackage rec { 25 pname = "limits"; 26 version = "3.12.0"; 27 pyproject = true; 28 29 disabled = pythonOlder "3.7"; 30 31 src = fetchFromGitHub { 32 owner = "alisaifee"; 33 repo = "limits"; 34 rev = "refs/tags/${version}"; 35 # Upstream uses versioneer, which relies on git attributes substitution. 36 # This leads to non-reproducible archives on github. Remove the substituted 37 # file here, and recreate it later based on our version info. 38 postFetch = '' 39 rm "$out/limits/_version.py" 40 ''; 41 hash = "sha256-EH2/75tcKuS11XKuo4lCQrFe4/XJZpcWhuGlSuhIk18="; 42 }; 43 44 postPatch = '' 45 substituteInPlace pytest.ini \ 46 --replace-fail "--cov=limits" "" \ 47 --replace-fail "-K" "" 48 49 substituteInPlace setup.py \ 50 --replace-fail "versioneer.get_version()" "'${version}'" 51 52 # Recreate _version.py, deleted at fetch time due to non-reproducibility. 53 echo 'def get_versions(): return {"version": "${version}"}' > limits/_version.py 54 ''; 55 56 nativeBuildInputs = [ setuptools ]; 57 58 propagatedBuildInputs = [ 59 deprecated 60 importlib-resources 61 packaging 62 typing-extensions 63 ]; 64 65 passthru.optional-dependencies = { 66 redis = [ redis ]; 67 rediscluster = [ redis ]; 68 memcached = [ pymemcache ]; 69 mongodb = [ pymongo ]; 70 etcd = [ etcd3 ]; 71 async-redis = [ coredis ]; 72 # async-memcached = [ 73 # emcache # Missing module 74 # ]; 75 async-mongodb = [ motor ]; 76 async-etcd = [ aetcd ]; 77 }; 78 79 doCheck = pythonOlder "3.12"; # SystemError in protobuf 80 81 nativeCheckInputs = [ 82 hiro 83 pytest-asyncio 84 pytest-lazy-fixture 85 pytestCheckHook 86 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies); 87 88 pythonImportsCheck = [ "limits" ]; 89 90 pytestFlagsArray = [ 91 # All other tests require a running Docker instance 92 "tests/test_limits.py" 93 "tests/test_ratelimit_parser.py" 94 "tests/test_limit_granularities.py" 95 ]; 96 97 meta = with lib; { 98 description = "Rate limiting using various strategies and storage backends such as redis & memcached"; 99 homepage = "https://github.com/alisaifee/limits"; 100 changelog = "https://github.com/alisaifee/limits/releases/tag/${version}"; 101 license = licenses.mit; 102 maintainers = with maintainers; [ ]; 103 }; 104}