Skip to content

Commit

Permalink
Dynamically build package description
Browse files Browse the repository at this point in the history
This allows it to include missing link to release notes and to
avoid problematic lines in README that PyPI doesn't like.
  • Loading branch information
unho committed Dec 20, 2016
1 parent 4cca191 commit 12c261d
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions setup.py
Expand Up @@ -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():
Expand Down Expand Up @@ -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 <http://docs.translatehouse.org/projects/pootle/"
"en/latest/releases/%s.html>`_") % get_main_version()
]
return "\n".join(initial_title + readme_lines[2:-4] + release_notes)


check_pep440_versions()


Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 12c261d

Please sign in to comment.