1{ lib
2, stdenv
3, fetchpatch
4, buildPythonPackage
5, fetchPypi
6, pythonOlder
7, setuptools
8, tdlib
9}:
10
11buildPythonPackage rec {
12 pname = "python-telegram";
13 version = "0.15.0";
14 disabled = pythonOlder "3.6";
15
16 src = fetchPypi {
17 inherit pname version;
18 hash = "sha256-Na2NIiVgYexKbEqjN58hfkgxwFdCTL7Z7D3WEhL4wXA=";
19 };
20
21 patches = [
22 # Search for the system library first, and fallback to the embedded one if the system was not found
23 (fetchpatch {
24 url = "https://github.com/alexander-akhmetov/python-telegram/commit/b0af0985910ebb8940cff1b92961387aad683287.patch";
25 hash = "sha256-ZqsntaiC2y9l034gXDMeD2BLO/RcsbBII8FomZ65/24=";
26 })
27 ];
28
29 postPatch = ''
30 # Remove bundled libtdjson
31 rm -fr telegram/lib
32
33 substituteInPlace telegram/tdjson.py \
34 --replace "ctypes.util.find_library(\"libtdjson\")" \
35 "\"${tdlib}/lib/libtdjson${stdenv.hostPlatform.extensions.sharedLibrary}\""
36 '';
37
38 propagatedBuildInputs = [
39 setuptools
40 ];
41
42 pythonImportsCheck = [
43 "telegram.client"
44 ];
45
46 meta = with lib; {
47 description = "Python client for the Telegram's tdlib";
48 homepage = "https://github.com/alexander-akhmetov/python-telegram";
49 license = licenses.mit;
50 maintainers = with maintainers; [ sikmir ];
51 };
52}