blob: 83aed0f2f795e8fe8112774ea3eff4c41359d965 [file] [log] [blame]
Skyler Greyb30f5dd2023-09-01 21:02:44 +00001{ lib
2, aiohttp
3, buildPythonPackage
4, fetchFromGitHub
5, libopus
6, pynacl
7, pythonOlder
8, withVoice ? true
9, ffmpeg
10}:
11
12buildPythonPackage rec {
13 pname = "discord.py";
14 version = "2.0.0";
15 format = "setuptools";
16
17 disabled = pythonOlder "3.8";
18
19 src = fetchFromGitHub {
20 owner = "Rapptz";
21 repo = pname;
22 rev = "refs/tags/v${version}";
23 hash = "sha256-Rh3gijm67LVyOaliP7w3YwKviKydnxXvu4snNrM5H1c=";
24 };
25
26 propagatedBuildInputs = [
27 aiohttp
28 ] ++ lib.optionals withVoice [
29 libopus
30 pynacl
31 ffmpeg
32 ];
33
34 patchPhase = ''
35 substituteInPlace "discord/opus.py" \
36 --replace "ctypes.util.find_library('opus')" "'${libopus}/lib/libopus.so.0'"
37 '' + lib.optionalString withVoice ''
38 substituteInPlace "discord/player.py" \
39 --replace "executable='ffmpeg'" "executable='${ffmpeg}/bin/ffmpeg'"
40 '';
41
42 # Only have integration tests with discord
43 doCheck = false;
44
45 pythonImportsCheck = [
46 "discord"
47 "discord.file"
48 "discord.member"
49 "discord.user"
50 "discord.state"
51 "discord.guild"
52 "discord.webhook"
53 "discord.ext.commands.bot"
54 ];
55
56 meta = with lib; {
57 description = "Python wrapper for the Discord API";
58 homepage = "https://discordpy.rtfd.org/";
59 changelog = "https://github.com/Rapptz/discord.py/blob/v${version}/docs/whats_new.rst";
60 license = licenses.mit;
61 maintainers = with maintainers; [ minion3665 ];
62 };
63}
64