From d32968e367e1b3da3c881760fff83bdf9fc4da9e Mon Sep 17 00:00:00 2001 From: Tomo <68489118+Tomodachi94@users.noreply.github.com> Date: Wed, 17 May 2023 21:24:35 -0700 Subject: [PATCH] python3Packages.hikari: init at 2.0.0.dev124 Code for patching the Git commit hash in `postFetch` borrowed from here: https://github.com/NixOS/nixpkgs/blob/dec7d29544716eadebcc0959c846651fd3b09781/pkgs/misc/fastly/default.nix#L25-L29 --- .../python-modules/hikari/default.nix | 80 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 82 insertions(+) create mode 100644 pkgs/development/python-modules/hikari/default.nix diff --git a/pkgs/development/python-modules/hikari/default.nix b/pkgs/development/python-modules/hikari/default.nix new file mode 100644 index 000000000000..e76d7780c0bf --- /dev/null +++ b/pkgs/development/python-modules/hikari/default.nix @@ -0,0 +1,80 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, pytestCheckHook +, pythonOlder +, pythonRelaxDepsHook +, pytest-runner +, aiohttp +, attrs +, multidict +, colorlog +, pynacl +, pytest-cov +, pytest-randomly +, pytest-asyncio +, mock +}: +buildPythonPackage rec { + pname = "hikari"; + version = "2.0.0.dev124"; + + src = fetchFromGitHub { + owner = "hikari-py"; + repo = "hikari"; + rev = version; + hash = "sha256-zDgU3Ol/I3YNnwXm+aBh20KwonW746p5TObuwuWORog="; + # The git commit is part of the `hikari.__git_sha1__` original output; + # leave that output the same in nixpkgs. Use the `.git` directory + # to retrieve the commit SHA, and remove the directory afterwards, + # since it is not needed after that. + leaveDotGit = true; + postFetch = '' + cd "$out" + git rev-parse HEAD > $out/COMMIT + find "$out" -name .git -print0 | xargs -0 rm -rf + ''; + }; + + nativeBuildInputs = [ + pythonRelaxDepsHook + ]; + + propagatedBuildInputs = [ + aiohttp + attrs + multidict + colorlog + ]; + + pythonRelaxDeps = true; + + passthru.optional-dependencies = { + server = [ pynacl ]; + }; + + nativeCheckInputs = [ + pytestCheckHook + pytest-runner + pytest-asyncio + pytest-cov + pytest-randomly + mock + ]; + + pythonImportChecks = [ "hikari" ]; + + disabled = pythonOlder "3.7"; + + postPatch = '' + substituteInPlace hikari/_about.py --replace "__git_sha1__: typing.Final[str] = \"HEAD\"" "__git_sha1__: typing.Final[str] = \"$(cat $src/COMMIT)\"" + ''; + + meta = with lib; { + description = "Discord API wrapper for Python written with asyncio"; + homepage = "https://www.hikari-py.dev/"; + changelog = "https://github.com/hikari-py/hikari/releases/tag/${version}"; + license = licenses.mit; + maintainers = with maintainers; [ tomodachi94 ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 94a27ec09da6..3f8028097a7d 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5297,6 +5297,8 @@ self: super: with self; { hijri-converter = callPackage ../development/python-modules/hijri-converter { }; + hikari = callPackage ../development/python-modules/hikari { }; + hikvision = callPackage ../development/python-modules/hikvision { }; hiredis = callPackage ../development/python-modules/hiredis { };