From c134d9ba2714ad84cf0338a28b3e27f116771031 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 29 Sep 2017 12:40:03 +0200 Subject: [PATCH] Run setup.py gen_tl when installing (may fix #271) --- setup.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/setup.py b/setup.py index 509c2064..695ad1a5 100755 --- a/setup.py +++ b/setup.py @@ -42,19 +42,23 @@ class TempWorkDir: os.chdir(self.original) +def gen_tl(): + from telethon_generator.tl_generator import TLGenerator + generator = TLGenerator('telethon/tl') + if generator.tlobjects_exist(): + print('Detected previous TLObjects. Cleaning...') + generator.clean_tlobjects() + + print('Generating TLObjects...') + generator.generate_tlobjects( + 'telethon_generator/scheme.tl', import_depth=2 + ) + print('Done.') + + def main(): if len(argv) >= 2 and argv[1] == 'gen_tl': - from telethon_generator.tl_generator import TLGenerator - generator = TLGenerator('telethon/tl') - if generator.tlobjects_exist(): - print('Detected previous TLObjects. Cleaning...') - generator.clean_tlobjects() - - print('Generating TLObjects...') - generator.generate_tlobjects( - 'telethon_generator/scheme.tl', import_depth=2 - ) - print('Done.') + gen_tl() elif len(argv) >= 2 and argv[1] == 'clean_tl': from telethon_generator.tl_generator import TLGenerator @@ -78,8 +82,11 @@ def main(): else: if not TelegramClient: - print('Run `python3', argv[0], 'gen_tl` first.') - quit() + gen_tl() + from telethon import TelegramClient as TgClient + version = TgClient.__version__ + else: + version = TelegramClient.__version__ # Get the long description from the README file with open('README.rst', encoding='utf-8') as f: @@ -89,7 +96,7 @@ def main(): name='Telethon', # Versions should comply with PEP440. - version=TelegramClient.__version__, + version=version, description="Full-featured Telegram client library for Python 3", long_description=long_description,