From 12c261def6a16061dfc28f65ad866209ca109f40 Mon Sep 17 00:00:00 2001 From: Leandro Regueiro Date: Tue, 20 Dec 2016 20:02:05 +0100 Subject: [PATCH] Dynamically build package description This allows it to include missing link to release notes and to avoid problematic lines in README that PyPI doesn't like. --- setup.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 756e77f6f0d..b157834e2ec 100755 --- a/setup.py +++ b/setup.py @@ -21,6 +21,7 @@ from pootle import __version__ from pootle.constants import DJANGO_MINIMUM_REQUIRED_VERSION +from pootle.core.utils.version import get_main_version def check_pep440_versions(): @@ -267,6 +268,26 @@ def get_check_description(name, filterfunc): print("Checks templates written to %r" % (filename)) +def parse_long_description(filename): + readme_lines = open( + os.path.join(os.path.dirname(__file__), filename) + ).read().split("\n") + pootle = "Pootle" + notes = "Release notes" + initial_title = [ # PyPI doesn't like |logo| + pootle, + "="*len(pootle) + ] + release_notes = [ # Missing in README. + notes, + "-"*len(notes), + "", + ("- `Release notes `_") % get_main_version() + ] + return "\n".join(initial_title + readme_lines[2:-4] + release_notes) + + check_pep440_versions() @@ -308,9 +329,7 @@ def get_check_description(name, filterfunc): version=__version__, description="An online collaborative localization tool.", - long_description=open( - os.path.join(os.path.dirname(__file__), 'README.rst') - ).read(), + long_description=parse_long_description('README.rst'), author="Translate", author_email="dev@translate.org.za",