summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/disnake/default.nix
blob: 12ebfea8648930d0526bb6451e76719de6cb708e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
  lib,
  setuptools,
  aiohttp,
  buildPythonPackage,
  fetchFromGitHub,
  libopus,
  pynacl,
  withVoice ? true,
  ffmpeg,
}:

buildPythonPackage rec {
  pname = "disnake";
  version = "2.10.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "DisnakeDev";
    repo = "disnake";
    tag = "v${version}";
    hash = "sha256-MQxYkUA3uclmY2cKBr4DsBg79ovsH1EsMOjiVPGaLVE=";
  };

  build-system = [ setuptools ];

  dependencies = [
    aiohttp
  ]
  ++ lib.optionals withVoice [
    libopus
    pynacl
    ffmpeg
  ];

  postPatch = lib.optionalString withVoice ''
    substituteInPlace "disnake/opus.py" \
      --replace-fail 'ctypes.util.find_library("opus")' "'${libopus}/lib/libopus.so.0'"
    substituteInPlace "disnake/player.py" \
      --replace-fail 'executable: str = "ffmpeg"' 'executable: str="${ffmpeg}/bin/ffmpeg"'
  '';

  # Only have integration tests with discord
  doCheck = false;

  pythonImportsCheck = [
    "disnake"
    "disnake.file"
    "disnake.member"
    "disnake.user"
    "disnake.state"
    "disnake.guild"
    "disnake.webhook"
    "disnake.ext.commands.bot"
  ];

  meta = {
    description = "API wrapper for Discord written in Python";
    homepage = "https://disnake.dev/";
    changelog = "https://github.com/DisnakeDev/disnake/blob/v${version}/docs/whats_new.rst";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ infinidoge ];
  };
}