sesh: 2.7.0 -> 2.8.0 (#371799)
[NixPkgs.git] / pkgs / development / python-modules / limits / default.nix
blob4c792674a9d2f12fbcfc18aee1e75316a723f66b
2   lib,
3   aetcd,
4   buildPythonPackage,
5   coredis,
6   deprecated,
7   etcd3,
8   fetchFromGitHub,
9   fetchpatch2,
10   flaky,
11   hiro,
12   importlib-resources,
13   motor,
14   packaging,
15   pymemcache,
16   pymongo,
17   pytest-asyncio,
18   pytest-benchmark,
19   pytest-lazy-fixture,
20   pytestCheckHook,
21   pythonOlder,
22   redis,
23   setuptools,
24   typing-extensions,
27 buildPythonPackage rec {
28   pname = "limits";
29   version = "3.13.0";
30   pyproject = true;
32   disabled = pythonOlder "3.8";
34   src = fetchFromGitHub {
35     owner = "alisaifee";
36     repo = "limits";
37     tag = version;
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.
41     postFetch = ''
42       rm "$out/limits/_version.py"
43     '';
44     hash = "sha256-y5iMx+AC52ZgGvAvThRaeKFqCGkwmukyZsJ+nzR2AFM=";
45   };
47   patches = [
48     (fetchpatch2 {
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=";
53     })
54     ./remove-fixed-start-from-async-tests.patch
55     ./only-test-in-memory.patch
56   ];
58   postPatch = ''
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
68   '';
70   build-system = [ setuptools ];
72   dependencies = [
73     deprecated
74     importlib-resources
75     packaging
76     typing-extensions
77   ];
79   optional-dependencies = {
80     redis = [ redis ];
81     rediscluster = [ redis ];
82     memcached = [ pymemcache ];
83     mongodb = [ pymongo ];
84     etcd = [ etcd3 ];
85     async-redis = [ coredis ];
86     # async-memcached = [
87     #   emcache  # Missing module
88     # ];
89     async-mongodb = [ motor ];
90     async-etcd = [ aetcd ];
91   };
93   env = {
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";
97   };
99   doCheck = pythonOlder "3.12"; # SystemError in protobuf
101   nativeCheckInputs = [
102     flaky
103     hiro
104     pytest-asyncio
105     pytest-benchmark
106     pytest-lazy-fixture
107     pytestCheckHook
108   ] ++ lib.flatten (lib.attrValues optional-dependencies);
110   disabledTests = [ "test_moving_window_memcached" ];
112   pythonImportsCheck = [ "limits" ];
114   meta = with lib; {
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;
119     maintainers = [ ];
120   };