1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch,
7 pytestCheckHook,
8 pythonOlder,
9 setuptools,
10}:
11
12buildPythonPackage rec {
13 pname = "token-bucket";
14 version = "0.3.0";
15 pyproject = true;
16
17 disabled = pythonOlder "3.7";
18
19 src = fetchFromGitHub {
20 owner = "falconry";
21 repo = "token-bucket";
22 tag = version;
23 hash = "sha256-dazqJRpC8FUHOhgKFzDnIl5CT2L74J2o2Hsm0IQf4Cg=";
24 };
25
26 patches = [
27 # Replace imp with importlib, https://github.com/falconry/token-bucket/pull/24
28 (fetchpatch {
29 name = "remove-imp.patch";
30 url = "https://github.com/falconry/token-bucket/commit/10a3c9f4de00f4933349f66b4c72b6c96db6e766.patch";
31 hash = "sha256-Hk5+i3xzeA3F1kXRaRarWT9mff2lT2WNmTfTZvYzGYI=";
32 })
33 ];
34
35 postPatch = ''
36 substituteInPlace setup.py \
37 --replace "'pytest-runner'" ""
38 '';
39
40 nativeBuildInputs = [ setuptools ];
41
42 nativeCheckInputs = [ pytestCheckHook ];
43
44 doCheck = !stdenv.hostPlatform.isDarwin;
45
46 meta = with lib; {
47 description = "Token Bucket Implementation for Python Web Apps";
48 homepage = "https://github.com/falconry/token-bucket";
49 changelog = "https://github.com/falconry/token-bucket/releases/tag/${version}";
50 license = licenses.asl20;
51 maintainers = with maintainers; [ hexa ];
52 };
53}