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