diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-06-18 15:31:41 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-06-18 15:31:41 -0500 |
commit | 8b2a09c266f001e428948dfba06b3db1b9beba25 (patch) | |
tree | 56a346c16f8685ccbf11836b710ff1a9ea3138a1 /release.py | |
parent | 6873d6f71022031b7f4684a25bf8358a14a3ff9f (diff) | |
download | python-setuptools-bitbucket-8b2a09c266f001e428948dfba06b3db1b9beba25.tar.gz |
Update release script to run under Python 3
Diffstat (limited to 'release.py')
-rw-r--r-- | release.py | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -11,13 +11,22 @@ import subprocess import shutil import os import sys -import urllib2 import getpass import collections import itertools import re try: + import urllib.request as urllib_request +except ImportError: + import urllib2 as urllib_request + +try: + input = raw_input +except NameError: + pass + +try: import keyring except Exception: pass @@ -27,7 +36,7 @@ PACKAGE_INDEX = 'https://pypi.python.org/pypi' def set_versions(): global VERSION - version = raw_input("Release as version [%s]> " % VERSION) or VERSION + version = input("Release as version [%s]> " % VERSION) or VERSION if version != VERSION: VERSION = bump_versions(version) @@ -99,11 +108,11 @@ def add_milestone_and_version(version): for type in 'milestones', 'versions': url = (base + '/1.0/repositories/{repo}/issues/{type}' .format(repo = get_repo_name(), type=type)) - req = urllib2.Request(url = url, headers = headers, + req = urllib_request.Request(url = url, headers = headers, data='name='+version) try: - urllib2.urlopen(req) - except urllib2.HTTPError as e: + urllib_request.urlopen(req) + except urllib_request.HTTPError as e: print(e.fp.read()) def bump_versions(target_ver): @@ -116,7 +125,10 @@ def bump_versions(target_ver): def bump_version(filename, target_ver): with open(filename, 'rb') as f: - lines = [line.replace(VERSION, target_ver) for line in f] + lines = [ + line.replace(VERSION.encode('ascii'), target_ver.encode('ascii')) + for line in f + ] with open(filename, 'wb') as f: f.writelines(lines) |