1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchpatch,
6 openssl,
7 rsa,
8 pyaes,
9 cryptg,
10 pythonOlder,
11 setuptools,
12 pytest-asyncio,
13 pytestCheckHook,
14}:
15
16buildPythonPackage rec {
17 pname = "telethon";
18 version = "1.41.1";
19 pyproject = true;
20
21 disabled = pythonOlder "3.5";
22
23 src = fetchFromGitHub {
24 owner = "LonamiWebs";
25 repo = "Telethon";
26 tag = "v${version}";
27 hash = "sha256-V38enxg1ZW1zd87xRLr0GHv+t1NK7fwDFxXDqPvCf2U=";
28 };
29
30 patches = [
31 # https://github.com/LonamiWebs/Telethon/pull/4670
32 (fetchpatch {
33 url = "https://github.com/LonamiWebs/Telethon/commit/8e2a46568ef9193f5887aea1abf919ac4ca6d31e.patch";
34 name = "fix_async_test.patch";
35 hash = "sha256-oVpLnO4OxNam/mq945OskVEHkbS5TDSUXk/0xPHVv3I=";
36 })
37 ]
38 ++ lib.optionals (lib.versionOlder version "1.40.1") [
39 (fetchpatch {
40 url = "https://github.com/LonamiWebs/Telethon/commit/ae9c798e2c3648ff40dee1b3f371f5d66851642e.patch";
41 name = "fix_test_messages_test.patch";
42 hash = "sha256-8SJm8EE6w7zRQxt1NuTX6KP1MTYPiYO/maJ5tOA2I9w=";
43 })
44 ];
45
46 postPatch = ''
47 substituteInPlace telethon/crypto/libssl.py --replace-fail \
48 "ctypes.util.find_library('ssl')" "'${lib.getLib openssl}/lib/libssl.so'"
49 '';
50
51 build-system = [
52 setuptools
53 ];
54
55 dependencies = [
56 pyaes
57 rsa
58 ];
59
60 optional-dependencies = {
61 cryptg = [ cryptg ];
62 };
63
64 nativeCheckInputs = [
65 pytest-asyncio
66 pytestCheckHook
67 ];
68
69 meta = {
70 homepage = "https://github.com/LonamiWebs/Telethon";
71 description = "Full-featured Telegram client library for Python 3";
72 license = lib.licenses.mit;
73 changelog = "https://github.com/LonamiWebs/Telethon/blob/${src.tag}/readthedocs/misc/changelog.rst";
74 maintainers = with lib.maintainers; [ nyanloutre ];
75 };
76}