1{ lib
2, fetchFromGitHub
3, buildPythonPackage
4, pythonOlder
5, withVoice ? true, libopus
6, aiohttp
7, websockets
8, pynacl
9}:
10
11buildPythonPackage rec {
12 pname = "discord.py";
13 version = "1.2.5";
14 disabled = pythonOlder "3.5.3";
15
16 # only distributes wheels on pypi now
17 src = fetchFromGitHub {
18 owner = "Rapptz";
19 repo = pname;
20 rev = "v${version}";
21 sha256 = "17l6mlfi9ikqndpmi4pwlvb53g132cycyfm9nzdyiqr96k8ly4ig";
22 };
23
24 propagatedBuildInputs = [ aiohttp websockets ];
25 patchPhase = ''
26 substituteInPlace "requirements.txt" \
27 --replace "aiohttp>=3.3.0,<3.6.0" "aiohttp~=3.3" \
28 --replace "websockets>=6.0,<7.0" "websockets>=6"
29 '' + lib.optionalString withVoice ''
30 substituteInPlace "discord/opus.py" \
31 --replace "ctypes.util.find_library('opus')" "'${libopus}/lib/libopus.so.0'"
32 '';
33
34
35 # only have integration tests with discord
36 doCheck = false;
37
38 pythonImportsCheck = [
39 "discord"
40 "discord.file"
41 "discord.member"
42 "discord.user"
43 "discord.state"
44 "discord.guild"
45 "discord.webhook"
46 "discord.ext.commands.bot"
47 ];
48
49 meta = {
50 description = "A python wrapper for the Discord API";
51 homepage = "https://discordpy.rtfd.org/";
52 license = lib.licenses.mit;
53 };
54}