From c9a946bc02ef8f1c44774fd3c05790d145b4e37c Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 25 Aug 2018 14:00:04 +0200 Subject: [PATCH] Turn version and readme into function --- setup.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index ee716857..f9153dfe 100644 --- a/setup.py +++ b/setup.py @@ -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: - 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) +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()) + 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",