aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Lacko <backup.rlacko@gmail.com>2013-10-09 15:14:22 +0200
committerRoman Lacko <backup.rlacko@gmail.com>2013-10-09 15:14:22 +0200
commitc3ad549f87b7b4112eba817e0bf3476822da1f24 (patch)
tree76ad1d49fc0f879848f5898c3a1e66a0a0e42856
parente0557526ded7d406ee77a68bebc2efb9610fec0a (diff)
Update ez_setup.py to latest version
-rw-r--r--ez_setup.py39
1 files changed, 26 insertions, 13 deletions
diff --git a/ez_setup.py b/ez_setup.py
index 837ef3f3..b02f3f17 100644
--- a/ez_setup.py
+++ b/ez_setup.py
@@ -29,7 +29,7 @@ try:
except ImportError:
USER_SITE = None
-DEFAULT_VERSION = "1.0"
+DEFAULT_VERSION = "1.1.6"
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
def _python_cmd(*args):
@@ -170,9 +170,10 @@ def has_powershell():
cmd = ['powershell', '-Command', 'echo test']
devnull = open(os.path.devnull, 'wb')
try:
- subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
- except:
- return False
+ try:
+ subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
+ except:
+ return False
finally:
devnull.close()
return True
@@ -187,9 +188,10 @@ def has_curl():
cmd = ['curl', '--version']
devnull = open(os.path.devnull, 'wb')
try:
- subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
- except:
- return False
+ try:
+ subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
+ except:
+ return False
finally:
devnull.close()
return True
@@ -204,9 +206,10 @@ def has_wget():
cmd = ['wget', '--version']
devnull = open(os.path.devnull, 'wb')
try:
- subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
- except:
- return False
+ try:
+ subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
+ except:
+ return False
finally:
devnull.close()
return True
@@ -251,7 +254,8 @@ def get_best_downloader():
return dl
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
- to_dir=os.curdir, delay=15):
+ to_dir=os.curdir, delay=15,
+ downloader_factory=get_best_downloader):
"""Download setuptools from a specified location and return its filename
`version` should be a valid setuptools version number that is available
@@ -259,6 +263,9 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
with a '/'). `to_dir` is the directory where the egg will be downloaded.
`delay` is the number of seconds to pause before an actual download
attempt.
+
+ ``downloader_factory`` should be a function taking no arguments and
+ returning a function for downloading a URL to a target.
"""
# making sure we use the absolute path
to_dir = os.path.abspath(to_dir)
@@ -267,7 +274,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
saveto = os.path.join(to_dir, tgz_name)
if not os.path.exists(saveto): # Avoid repeated downloads
log.warn("Downloading %s", url)
- downloader = get_best_downloader()
+ downloader = downloader_factory()
downloader(url, saveto)
return os.path.realpath(saveto)
@@ -343,6 +350,11 @@ def _parse_args():
'--download-base', dest='download_base', metavar="URL",
default=DEFAULT_URL,
help='alternative URL from where to download the setuptools package')
+ parser.add_option(
+ '--insecure', dest='downloader_factory', action='store_const',
+ const=lambda: download_file_insecure, default=get_best_downloader,
+ help='Use internal, non-validating downloader'
+ )
options, args = parser.parse_args()
# positional arguments are ignored
return options
@@ -350,7 +362,8 @@ def _parse_args():
def main(version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
options = _parse_args()
- tarball = download_setuptools(download_base=options.download_base)
+ tarball = download_setuptools(download_base=options.download_base,
+ downloader_factory=options.downloader_factory)
return _install(tarball, _build_install_args(options))
if __name__ == '__main__':