1{ lib
2, fetchurl
3, buildPythonPackage
4, pythonOlder
5, withVoice ? true, libopus
6, asyncio
7, aiohttp
8, websockets
9, pynacl
10}:
11
12let
13 pname = "discord.py";
14 version = "0.16.11";
15in buildPythonPackage rec {
16 name = "${pname}-${version}";
17
18 src = fetchurl {
19 url = "mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${name}.tar.gz";
20 sha256 = "eb3c6faa7d4570cce05533d0742bbcb768629e2b3ba9e1cc79c05833db91ac4d";
21 };
22
23 propagatedBuildInputs = [ asyncio aiohttp websockets pynacl ];
24 patchPhase = ''
25 substituteInPlace "requirements.txt" \
26 --replace "aiohttp>=1.0.0,<1.1.0" "aiohttp"
27 '' + lib.optionalString withVoice ''
28 substituteInPlace "discord/opus.py" \
29 --replace "ctypes.util.find_library('opus')" "'${libopus}/lib/libopus.so.0'"
30 '';
31
32 disabled = pythonOlder "3.5";
33
34 # No tests in archive
35 doCheck = false;
36
37 meta = {
38 description = "A python wrapper for the Discord API";
39 homepage = "https://discordpy.rtfd.org/";
40 license = lib.licenses.mit;
41 };
42}