1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pytestCheckHook,
6 pythonOlder,
7 aiohttp,
8 attrs,
9 multidict,
10 colorlog,
11 pynacl,
12 pytest-cov-stub,
13 pytest-randomly,
14 pytest-asyncio,
15 mock,
16}:
17buildPythonPackage rec {
18 pname = "hikari";
19 version = "2.1.0";
20 format = "setuptools";
21
22 src = fetchFromGitHub {
23 owner = "hikari-py";
24 repo = "hikari";
25 tag = version;
26 hash = "sha256-/A3D3nG1lSCQU92dM+6YroxWlGKrv47ntkZaJZTAJUA=";
27 # The git commit is part of the `hikari.__git_sha1__` original output;
28 # leave that output the same in nixpkgs. Use the `.git` directory
29 # to retrieve the commit SHA, and remove the directory afterwards,
30 # since it is not needed after that.
31 leaveDotGit = true;
32 postFetch = ''
33 cd "$out"
34 git rev-parse HEAD > $out/COMMIT
35 find "$out" -name .git -print0 | xargs -0 rm -rf
36 '';
37 };
38
39 propagatedBuildInputs = [
40 aiohttp
41 attrs
42 multidict
43 colorlog
44 ];
45
46 pythonRelaxDeps = true;
47
48 optional-dependencies = {
49 server = [ pynacl ];
50 };
51
52 nativeCheckInputs = [
53 pytestCheckHook
54 pytest-asyncio
55 pytest-cov-stub
56 pytest-randomly
57 mock
58 ];
59
60 pythonImportsCheck = [ "hikari" ];
61
62 disabled = pythonOlder "3.7";
63
64 postPatch = ''
65 substituteInPlace hikari/_about.py \
66 --replace-fail "__git_sha1__: typing.Final[str] = \"HEAD\"" "__git_sha1__: typing.Final[str] = \"$(cat $src/COMMIT)\""
67 # XXX: Remove once pytest-asyncio is updated to 0.24+
68 substituteInPlace pyproject.toml \
69 --replace-fail "asyncio_default_fixture_loop_scope = \"func\"" ""
70 '';
71
72 meta = {
73 description = "Discord API wrapper for Python written with asyncio";
74 homepage = "https://www.hikari-py.dev/";
75 changelog = "https://github.com/hikari-py/hikari/releases/tag/${version}";
76 license = lib.licenses.mit;
77 maintainers = with lib.maintainers; [
78 tomodachi94
79 sigmanificient
80 ];
81 };
82}