Skyler Grey | fe1740c | 2023-10-21 01:24:18 +0000 | [diff] [blame] | 1 | { lib, aiohttp, buildPythonPackage, fetchFromGitHub, libopus, pynacl |
| 2 | , pythonOlder, withVoice ? true, ffmpeg }: |
Skyler Grey | b30f5dd | 2023-09-01 21:02:44 +0000 | [diff] [blame] | 3 | |
| 4 | buildPythonPackage rec { |
| 5 | pname = "discord.py"; |
| 6 | version = "2.0.0"; |
| 7 | format = "setuptools"; |
| 8 | |
| 9 | disabled = pythonOlder "3.8"; |
| 10 | |
| 11 | src = fetchFromGitHub { |
| 12 | owner = "Rapptz"; |
| 13 | repo = pname; |
| 14 | rev = "refs/tags/v${version}"; |
| 15 | hash = "sha256-Rh3gijm67LVyOaliP7w3YwKviKydnxXvu4snNrM5H1c="; |
| 16 | }; |
| 17 | |
Skyler Grey | fe1740c | 2023-10-21 01:24:18 +0000 | [diff] [blame] | 18 | propagatedBuildInputs = [ aiohttp ] |
| 19 | ++ lib.optionals withVoice [ libopus pynacl ffmpeg ]; |
Skyler Grey | b30f5dd | 2023-09-01 21:02:44 +0000 | [diff] [blame] | 20 | |
| 21 | patchPhase = '' |
| 22 | substituteInPlace "discord/opus.py" \ |
| 23 | --replace "ctypes.util.find_library('opus')" "'${libopus}/lib/libopus.so.0'" |
| 24 | '' + lib.optionalString withVoice '' |
| 25 | substituteInPlace "discord/player.py" \ |
| 26 | --replace "executable='ffmpeg'" "executable='${ffmpeg}/bin/ffmpeg'" |
| 27 | ''; |
| 28 | |
| 29 | # Only have integration tests with discord |
| 30 | doCheck = false; |
| 31 | |
| 32 | pythonImportsCheck = [ |
| 33 | "discord" |
| 34 | "discord.file" |
| 35 | "discord.member" |
| 36 | "discord.user" |
| 37 | "discord.state" |
| 38 | "discord.guild" |
| 39 | "discord.webhook" |
| 40 | "discord.ext.commands.bot" |
| 41 | ]; |
| 42 | |
| 43 | meta = with lib; { |
| 44 | description = "Python wrapper for the Discord API"; |
| 45 | homepage = "https://discordpy.rtfd.org/"; |
Skyler Grey | fe1740c | 2023-10-21 01:24:18 +0000 | [diff] [blame] | 46 | changelog = |
| 47 | "https://github.com/Rapptz/discord.py/blob/v${version}/docs/whats_new.rst"; |
Skyler Grey | b30f5dd | 2023-09-01 21:02:44 +0000 | [diff] [blame] | 48 | license = licenses.mit; |
| 49 | maintainers = with maintainers; [ minion3665 ]; |
| 50 | }; |
| 51 | } |
| 52 | |