btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / development / python-modules / discordpy / default.nix
blob73d8cdc7abd4eaed16dcf1af544788b746b54e2a
2   lib,
3   stdenv,
4   aiohttp,
5   buildPythonPackage,
6   fetchFromGitHub,
7   libopus,
8   pynacl,
9   withVoice ? true,
10   ffmpeg,
11   setuptools,
14 let
15   pname = "discord.py";
16   version = "2.4.0";
18 buildPythonPackage {
19   inherit pname version;
20   pyproject = true;
22   src = fetchFromGitHub {
23     owner = "Rapptz";
24     repo = "discord.py";
25     rev = "refs/tags/v${version}";
26     hash = "sha256-GIwXx7bRCH2+G3zlilJ/Tb8el50SDbxGGX2/1bqL3+U=";
27   };
29   build-system = [ setuptools ];
31   dependencies = [ aiohttp ] ++ lib.optionals withVoice [ pynacl ];
33   patchPhase = lib.optionalString withVoice ''
34     substituteInPlace "discord/opus.py" \
35       --replace-fail "ctypes.util.find_library('opus')" "'${libopus}/lib/libopus${stdenv.hostPlatform.extensions.sharedLibrary}'"
37     substituteInPlace "discord/player.py" \
38       --replace-fail "executable: str = 'ffmpeg'" "executable: str = '${lib.getExe ffmpeg}'"
39   '';
41   # Only have integration tests with discord
42   doCheck = false;
44   pythonImportsCheck = [
45     "discord"
46     "discord.types"
47     "discord.ui"
48     "discord.webhook"
49     "discord.app_commands"
50     "discord.ext.commands"
51     "discord.ext.tasks"
52   ];
54   meta = {
55     description = "Python wrapper for the Discord API";
56     homepage = "https://discordpy.rtfd.org/";
57     changelog = "https://github.com/Rapptz/discord.py/blob/v${version}/docs/whats_new.rst";
58     license = lib.licenses.mit;
59     maintainers = with lib.maintainers; [ getpsyched ];
60   };