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