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