diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-02-16 10:05:59 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-02-16 10:05:59 -0500 |
commit | 1ba919120ead7b064e1b0b80e4174d7c4435e700 (patch) | |
tree | 0a3f8ae0da03c06fca565be3f75865a34982b939 /ez_setup.py | |
parent | 947b300262d3415f4a1a073887973f2772792ae0 (diff) | |
download | external_python_setuptools-1ba919120ead7b064e1b0b80e4174d7c4435e700.tar.gz external_python_setuptools-1ba919120ead7b064e1b0b80e4174d7c4435e700.tar.bz2 external_python_setuptools-1ba919120ead7b064e1b0b80e4174d7c4435e700.zip |
Extract _conflict_bail function
Diffstat (limited to 'ez_setup.py')
-rw-r--r-- | ez_setup.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/ez_setup.py b/ez_setup.py index d8d2ad8b..19af8969 100644 --- a/ez_setup.py +++ b/ez_setup.py @@ -146,14 +146,6 @@ def use_setuptools( to_dir = os.path.abspath(to_dir) rep_modules = 'pkg_resources', 'setuptools' imported = set(sys.modules).intersection(rep_modules) - conflict_tmpl = textwrap.dedent(""" - The required version of setuptools (>={version}) is not available, - and can't be installed while this script is running. Please - install a more recent version first, using - 'easy_install -U setuptools'. - - (Currently using {VC_err.args[0]!r}) - """) try: import pkg_resources pkg_resources.require("setuptools>=" + version) @@ -167,11 +159,7 @@ def use_setuptools( pass except pkg_resources.VersionConflict as VC_err: if imported: - # setuptools was imported prior to invocation of this function, - # so it's not safe to unload it. - msg = conflict_tmpl.format(VC_err=VC_err, version=version) - sys.stderr.write(msg) - sys.exit(2) + _conflict_bail(VC_err, version) # otherwise, unload pkg_resources to allow the downloaded version to # take precedence. @@ -181,6 +169,24 @@ def use_setuptools( return _do_download(version, download_base, to_dir, download_delay) +def _conflict_bail(VC_err, version): + """ + Setuptools was imported prior to invocation, so it is + unsafe to unload it. Bail out. + """ + conflict_tmpl = textwrap.dedent(""" + The required version of setuptools (>={version}) is not available, + and can't be installed while this script is running. Please + install a more recent version first, using + 'easy_install -U setuptools'. + + (Currently using {VC_err.args[0]!r}) + """) + msg = conflict_tmpl.format(**locals()) + sys.stderr.write(msg) + sys.exit(2) + + def _unload_pkg_resources(): del_modules = [ name for name in sys.modules |