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