Turn version and readme into function

This commit is contained in:
Dan 2018-08-25 14:00:04 +02:00
parent 1e56f70b93
commit c9a946bc02

View File

@ -37,13 +37,17 @@ if len(argv) > 1 and argv[1] != "sdist":
docs_compiler.start()
error_compiler.start()
with open("pyrogram/__init__.py", encoding="utf-8") as f:
version = re.findall(r"__version__ = \"(.+)\"", f.read())[0]
# PyPI doesn't like raw html
with open("README.rst", encoding="utf-8") as f:
def get_version():
with open("pyrogram/__init__.py", encoding="utf-8") as f:
return re.findall(r"__version__ = \"(.+)\"", f.read())[0]
def get_readme():
# PyPI doesn't like raw html
with open("README.rst", encoding="utf-8") as f:
readme = re.sub(r"\.\. \|.+\| raw:: html(?:\s{4}.+)+\n\n", "", f.read())
readme = re.sub(r"\|header\|", "|logo|\n\n|description|\n\n|scheme| |tgcrypto|", readme)
return re.sub(r"\|header\|", "|logo|\n\n|description|\n\n|scheme| |tgcrypto|", readme)
class Clean(Command):
@ -73,9 +77,9 @@ class Clean(Command):
setup(
name="Pyrogram",
version=version,
version=get_version(),
description="Telegram MTProto API Client Library for Python",
long_description=readme,
long_description=get_readme(),
url="https://github.com/pyrogram",
download_url="https://github.com/pyrogram/pyrogram/releases/latest",
author="Dan Tès",