Run setup.py gen_tl when installing (may fix #271)

This commit is contained in:
Lonami Exo 2017-09-29 12:40:03 +02:00
parent 7838f8561b
commit c134d9ba27

View File

@ -42,8 +42,7 @@ class TempWorkDir:
os.chdir(self.original) os.chdir(self.original)
def main(): def gen_tl():
if len(argv) >= 2 and argv[1] == 'gen_tl':
from telethon_generator.tl_generator import TLGenerator from telethon_generator.tl_generator import TLGenerator
generator = TLGenerator('telethon/tl') generator = TLGenerator('telethon/tl')
if generator.tlobjects_exist(): if generator.tlobjects_exist():
@ -56,6 +55,11 @@ def main():
) )
print('Done.') print('Done.')
def main():
if len(argv) >= 2 and argv[1] == 'gen_tl':
gen_tl()
elif len(argv) >= 2 and argv[1] == 'clean_tl': elif len(argv) >= 2 and argv[1] == 'clean_tl':
from telethon_generator.tl_generator import TLGenerator from telethon_generator.tl_generator import TLGenerator
print('Cleaning...') print('Cleaning...')
@ -78,8 +82,11 @@ def main():
else: else:
if not TelegramClient: if not TelegramClient:
print('Run `python3', argv[0], 'gen_tl` first.') gen_tl()
quit() from telethon import TelegramClient as TgClient
version = TgClient.__version__
else:
version = TelegramClient.__version__
# Get the long description from the README file # Get the long description from the README file
with open('README.rst', encoding='utf-8') as f: with open('README.rst', encoding='utf-8') as f:
@ -89,7 +96,7 @@ def main():
name='Telethon', name='Telethon',
# Versions should comply with PEP440. # Versions should comply with PEP440.
version=TelegramClient.__version__, version=version,
description="Full-featured Telegram client library for Python 3", description="Full-featured Telegram client library for Python 3",
long_description=long_description, long_description=long_description,