1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, fetchpatch
5, poetry-core
6, importlib-metadata
7, pytest-asyncio
8, pytestCheckHook
9, pythonOlder
10, toml
11}:
12
13buildPythonPackage rec {
14 pname = "aiolimiter";
15 version = "1.0.0";
16 format = "pyproject";
17
18 disabled = pythonOlder "3.7";
19
20 src = fetchFromGitHub {
21 owner = "mjpieters";
22 repo = pname;
23 rev = "v${version}";
24 sha256 = "sha256-4wByVZoOLhrXFx9oK19GBmRcjGoJolQ3Gwx9vQV/n8s=";
25 };
26
27 nativeBuildInputs = [
28 poetry-core
29 ];
30
31 propagatedBuildInputs = lib.optionals (pythonOlder "3.8") [
32 importlib-metadata
33 ];
34
35 checkInputs = [
36 pytest-asyncio
37 pytestCheckHook
38 toml
39 ];
40
41 patches = [
42 # Switch to poetry-core, https://github.com/mjpieters/aiolimiter/pull/77
43 (fetchpatch {
44 name = "switch-to-peotry-core.patch";
45 url = "https://github.com/mjpieters/aiolimiter/commit/84a85eff42621b0daff8fcf6bb485db313faae0b.patch";
46 sha256 = "sha256-xUfJwLvMF2Xt/V1bKBFn/fjn1uyw7bGNo9RpWxtyr50=";
47 })
48 ];
49
50 postPatch = ''
51 substituteInPlace tox.ini \
52 --replace " --cov=aiolimiter --cov-config=tox.ini --cov-report term-missing" ""
53 '';
54
55 pythonImportsCheck = [
56 "aiolimiter"
57 ];
58
59 meta = with lib; {
60 description = "Implementation of a rate limiter for asyncio";
61 homepage = "https://github.com/mjpieters/aiolimiter";
62 license = with licenses; [ mit ];
63 maintainers = with maintainers; [ fab ];
64 };
65}