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