27 buildPythonPackage rec {
32 disabled = pythonOlder "3.8";
34 src = fetchFromGitHub {
38 # Upstream uses versioneer, which relies on git attributes substitution.
39 # This leads to non-reproducible archives on github. Remove the substituted
40 # file here, and recreate it later based on our version info.
42 rm "$out/limits/_version.py"
44 hash = "sha256-y5iMx+AC52ZgGvAvThRaeKFqCGkwmukyZsJ+nzR2AFM=";
49 name = "fix-incompatibility-with-latest-pytest-asyncio.patch";
50 url = "https://github.com/alisaifee/limits/commit/f6dcdb253cd44ca8dc7380c481da1afd8b57af6b.patch";
51 excludes = [ "requirements/test.txt" ];
52 hash = "sha256-NwtN8WHNrwsRcIq18pRjzzGmm7XCzn6O5y+jo9Qr6iQ=";
54 ./remove-fixed-start-from-async-tests.patch
55 ./only-test-in-memory.patch
59 substituteInPlace pytest.ini \
60 --replace-fail "--cov=limits" "" \
61 --replace-fail "-K" ""
63 substituteInPlace setup.py \
64 --replace-fail "versioneer.get_version()" "'${version}'"
66 # Recreate _version.py, deleted at fetch time due to non-reproducibility.
67 echo 'def get_versions(): return {"version": "${version}"}' > limits/_version.py
70 build-system = [ setuptools ];
79 optional-dependencies = {
81 rediscluster = [ redis ];
82 memcached = [ pymemcache ];
83 mongodb = [ pymongo ];
85 async-redis = [ coredis ];
87 # emcache # Missing module
89 async-mongodb = [ motor ];
90 async-etcd = [ aetcd ];
94 # make protobuf compatible with old versions
95 # https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
96 PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION = "python";
99 doCheck = pythonOlder "3.12"; # SystemError in protobuf
101 nativeCheckInputs = [
108 ] ++ lib.flatten (lib.attrValues optional-dependencies);
110 disabledTests = [ "test_moving_window_memcached" ];
112 pythonImportsCheck = [ "limits" ];
115 description = "Rate limiting using various strategies and storage backends such as redis & memcached";
116 homepage = "https://github.com/alisaifee/limits";
117 changelog = "https://github.com/alisaifee/limits/releases/tag/${version}";
118 license = licenses.mit;