aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2013-05-05 09:50:36 -0400
committerJason R. Coombs <jaraco@jaraco.com>2013-05-05 09:50:36 -0400
commit92952a515bca3813de6d5e27638a8e7fcd0117a7 (patch)
tree2d2be34aec550ecde84c1825f4c9d31a51f9573b
parentb78ecd63d5c206a5cd0b065656a4493ffe496fe5 (diff)
downloadexternal_python_setuptools-92952a515bca3813de6d5e27638a8e7fcd0117a7.tar.gz
external_python_setuptools-92952a515bca3813de6d5e27638a8e7fcd0117a7.tar.bz2
external_python_setuptools-92952a515bca3813de6d5e27638a8e7fcd0117a7.zip
Moved link generation routine from setup.py to release.py. The new routine requires Python 2.6 for izip_longest and chain.from_iterable, so it's not suitable for setup.py. Also, there's no reason that every installer needs to compute the links - they can be resolved in advance during the release process.
--HG-- branch : distribute extra : rebase_source : 9f4af99f70fdfa00290be2261a921af9a76ba597
-rw-r--r--.hgignore1
-rw-r--r--release.py58
-rwxr-xr-xsetup.py53
3 files changed, 62 insertions, 50 deletions
diff --git a/.hgignore b/.hgignore
index 21ec620a..4e5d0bcf 100644
--- a/.hgignore
+++ b/.hgignore
@@ -11,3 +11,4 @@ bin
include
\.Python
*.swp
+CHANGES (links).txt
diff --git a/release.py b/release.py
index 13df4d69..aeb989d5 100644
--- a/release.py
+++ b/release.py
@@ -14,6 +14,8 @@ import sys
import urllib2
import getpass
import collections
+import itertools
+import re
try:
import keyring
@@ -110,6 +112,8 @@ def do_release():
subprocess.check_call(['hg', 'update', VERSION])
+ linkify('CHANGES.txt', 'CHANGES (links).txt')
+
has_docs = build_docs()
if os.path.isdir('./dist'):
shutil.rmtree('./dist')
@@ -166,5 +170,59 @@ def upload_bootstrap_script():
except:
print("Unable to upload bootstrap script. Ask Tarek to do it.")
+def linkify(source, dest):
+ with open(source) as source:
+ out = _linkified_text(source.read())
+ with open(dest, 'w') as dest:
+ dest.write(out)
+
+def _linkified(rst_path):
+ "return contents of reStructureText file with linked issue references"
+ rst_file = open(rst_path)
+ rst_content = rst_file.read()
+ rst_file.close()
+
+ return _linkified_text(rst_content)
+
+def _linkified_text(rst_content):
+ # first identify any existing HREFs so they're not changed
+ HREF_pattern = re.compile('`.*?`_', re.MULTILINE | re.DOTALL)
+
+ # split on the HREF pattern, returning the parts to be linkified
+ plain_text_parts = HREF_pattern.split(rst_content)
+ anchors = []
+ linkified_parts = [_linkified_part(part, anchors)
+ for part in plain_text_parts]
+ pairs = itertools.izip_longest(
+ linkified_parts,
+ HREF_pattern.findall(rst_content),
+ fillvalue='',
+ )
+ rst_content = ''.join(flatten(pairs))
+
+ anchors = sorted(anchors)
+
+ bitroot = 'http://bitbucket.org/tarek/distribute'
+ rst_content += "\n"
+ for x in anchors:
+ issue = re.findall(r'\d+', x)[0]
+ rst_content += '.. _`%s`: %s/issue/%s\n' % (x, bitroot, issue)
+ rst_content += "\n"
+ return rst_content
+
+def flatten(listOfLists):
+ "Flatten one level of nesting"
+ return itertools.chain.from_iterable(listOfLists)
+
+
+def _linkified_part(text, anchors):
+ """
+ Linkify a part and collect any anchors generated
+ """
+ revision = re.compile(r'\b(issue\s+#?\d+)\b', re.M | re.I)
+
+ anchors.extend(revision.findall(text)) # ['Issue #43', ...]
+ return revision.sub(r'`\1`_', text)
+
if __name__ == '__main__':
do_release()
diff --git a/setup.py b/setup.py
index 1db770e9..e79fb659 100755
--- a/setup.py
+++ b/setup.py
@@ -133,58 +133,11 @@ if _being_installed():
from distribute_setup import _before_install
_before_install()
-def _linkified(rst_path):
- "return contents of reStructureText file with linked issue references"
- rst_file = open(rst_path)
- rst_content = rst_file.read()
- rst_file.close()
-
- return _linkified_text(rst_content)
-
-def _linkified_text(rst_content):
- # first identify any existing HREFs so they're not changed
- HREF_pattern = re.compile('`.*?`_', re.MULTILINE | re.DOTALL)
-
- # split on the HREF pattern, returning the parts to be linkified
- plain_text_parts = HREF_pattern.split(rst_content)
- anchors = []
- linkified_parts = [_linkified_part(part, anchors)
- for part in plain_text_parts]
- pairs = itertools.izip_longest(
- linkified_parts,
- HREF_pattern.findall(rst_content),
- fillvalue='',
- )
- rst_content = ''.join(flatten(pairs))
-
- anchors = sorted(anchors)
-
- bitroot = 'http://bitbucket.org/tarek/distribute'
- rst_content += "\n"
- for x in anchors:
- issue = re.findall(r'\d+', x)[0]
- rst_content += '.. _`%s`: %s/issue/%s\n' % (x, bitroot, issue)
- rst_content += "\n"
- return rst_content
-
-import itertools
-def flatten(listOfLists):
- "Flatten one level of nesting"
- return itertools.chain.from_iterable(listOfLists)
-
-
-def _linkified_part(text, anchors):
- """
- Linkify a part and collect any anchors generated
- """
- revision = re.compile(r'\b(issue\s+#?\d+)\b', re.M | re.I)
-
- anchors.extend(revision.findall(text)) # ['Issue #43', ...]
- return revision.sub(r'`\1`_', text)
-
readme_file = open('README.txt')
-long_description = readme_file.read() + _linkified('CHANGES.txt')
+changes_file = open('CHANGES (links).txt')
+long_description = readme_file.read() + changes_file.read()
readme_file.close()
+changes_file.close()
dist = setup(
name="distribute",