summaryrefslogtreecommitdiff
path: root/release.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2013-05-13 07:07:03 -0400
committerJason R. Coombs <jaraco@jaraco.com>2013-05-13 07:07:03 -0400
commit8f05565451ef38cc10074582ad826941f8f8c899 (patch)
tree3b13af466ad891a3481fd420c63f612a7621b44e /release.py
parenta0d19667eaa92bd95f2bebfcb50a68d0921282eb (diff)
parent068ab0e3a6e5146137ee9f913e3b1fbc5b337c22 (diff)
downloadpython-setuptools-git-8f05565451ef38cc10074582ad826941f8f8c899.tar.gz
Merge with Distribute 0.6.39
--HG-- rename : distribute_setup.py => ez_setup.py
Diffstat (limited to 'release.py')
-rw-r--r--release.py75
1 files changed, 70 insertions, 5 deletions
diff --git a/release.py b/release.py
index 46720a8e..2dc51ae8 100644
--- a/release.py
+++ b/release.py
@@ -14,13 +14,17 @@ import sys
import urllib2
import getpass
import collections
+import itertools
+import re
try:
import keyring
except Exception:
pass
-VERSION = '0.6.36'
+VERSION = '0.6.40'
+PACKAGE_INDEX = 'https://pypi.python.org/pypi'
+PACKAGE_INDEX = 'https://pypi.python.org/pypi'
def get_next_version():
digits = map(int, VERSION.split('.'))
@@ -50,7 +54,7 @@ def get_mercurial_creds(system='https://bitbucket.org', username=None):
# todo: consider getting this from .hgrc
username = username or getpass.getuser()
keyring_username = '@@'.join((username, system))
- system = '@'.join((keyring_username, 'Mercurial'))
+ system = 'Mercurial'
password = (
keyring.get_password(system, keyring_username)
if 'keyring' in globals()
@@ -110,13 +114,20 @@ 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')
- cmd = [sys.executable, 'setup.py', '-q', 'egg_info', '-RD', '-b', '',
- 'sdist', 'register', 'upload']
+ cmd = [
+ sys.executable, 'setup.py', '-q',
+ 'egg_info', '-RD', '-b', '',
+ 'sdist',
+ 'register', '-r', PACKAGE_INDEX,
+ 'upload', '-r', PACKAGE_INDEX,
+ ]
if has_docs:
- cmd.append('upload_docs')
+ cmd.extend(['upload_docs', '-r', PACKAGE_INDEX])
subprocess.check_call(cmd)
upload_bootstrap_script()
@@ -166,5 +177,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()