about summary refs log tree commit diff
path: root/pkgs/development/python-modules/python-telegram/default.nix
blob: cfe1dbd671bfb3f546bffafb66227f801e7a6dee (plain) (blame)
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
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  pytestCheckHook,
  pythonOlder,
  setuptools-scm,
  setuptools,
  tdlib,
  telegram-text,
}:

buildPythonPackage rec {
  pname = "python-telegram";
  version = "0.19.0";
  pyproject = true;

  disabled = pythonOlder "3.9";

  src = fetchFromGitHub {
    owner = "alexander-akhmetov";
    repo = "python-telegram";
    rev = "refs/tags/${version}";
    hash = "sha256-JnU59DZXpnaZXIY/apXQ2gBgiwT12rJIeVqzaP0l7Zk=";
  };

  postPatch = ''
    # Remove bundled libtdjson
    rm -fr telegram/lib

    substituteInPlace telegram/tdjson.py \
      --replace-fail "ctypes.util.find_library(\"tdjson\")" \
                "\"${tdlib}/lib/libtdjson${stdenv.hostPlatform.extensions.sharedLibrary}\""
  '';

  build-inputs = [ setuptools ];

  dependencies = [
    setuptools-scm
    telegram-text
  ];

  nativeCheckInputs = [ pytestCheckHook ];

  disabledTests = [ "TestGetTdjsonTdlibPath" ];

  pythonImportsCheck = [ "telegram.client" ];

  meta = with lib; {
    description = "Python client for the Telegram's tdlib";
    homepage = "https://github.com/alexander-akhmetov/python-telegram";
    changelog = "https://github.com/alexander-akhmetov/python-telegram/releases/tag/${version}";
    license = licenses.mit;
    maintainers = with maintainers; [ sikmir ];
  };
}