From e89509b4a75dd077a7c87da186aac829c6ba4f99 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Mon, 22 Oct 2012 20:32:42 +0300 Subject: Automatically link issues in CHANGES.txt uploaded to PyPI --HG-- branch : distribute extra : rebase_source : c5311107dd7fa43d90d6588d898bb40900d348e8 --- setup.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 09a5c4fc..13c9be7c 100755 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ import sys import os import textwrap +import re # Allow to run setup.py from another directory. os.chdir(os.path.dirname(os.path.abspath(__file__))) @@ -130,6 +131,22 @@ if _being_installed(): from distribute_setup import _before_install _before_install() +# return contents of reStructureText file with linked issue references +def _linkified(rstfile): + bitroot = 'http://bitbucket.org/tarek/distribute' + revision = re.compile(r'\b(issue\s*#?\d+)\b', re.M | re.I) + + rstext = open(rstfile).read() + + anchors = revision.findall(rstext) # ['Issue #43', ...] + anchors = sorted(set(anchors)) + rstext = revision.sub(r'`\1`_', rstext) + rstext += "\n" + for x in anchors: + issue = re.findall(r'\d+', x)[0] + rstext += '.. _`%s`: %s/issue/%s\n' % (x, bitroot, issue) + rstext += "\n" + return rstext dist = setup( name="distribute", @@ -139,7 +156,7 @@ dist = setup( author="The fellowship of the packaging", author_email="distutils-sig@python.org", license="PSF or ZPL", - long_description = open('README.txt').read() + open('CHANGES.txt').read(), + long_description = open('README.txt').read() + _linkified('CHANGES.txt'), keywords = "CPAN PyPI distutils eggs package management", url = "http://packages.python.org/distribute", test_suite = 'setuptools.tests', -- cgit v1.2.3