summaryrefslogtreecommitdiff
path: root/distribute_setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'distribute_setup.py')
-rw-r--r--distribute_setup.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/distribute_setup.py b/distribute_setup.py
index 95ba23c5..f3e85a1e 100644
--- a/distribute_setup.py
+++ b/distribute_setup.py
@@ -14,6 +14,7 @@ the appropriate options to ``use_setuptools()``.
This file can also be run as a script to install or upgrade setuptools.
"""
import os
+import shutil
import sys
import time
import fnmatch
@@ -48,7 +49,7 @@ except ImportError:
args = [quote(arg) for arg in args]
return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
-DEFAULT_VERSION = "0.6.29"
+DEFAULT_VERSION = "0.6.31"
DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
SETUPTOOLS_FAKED_VERSION = "0.6c11"
@@ -86,8 +87,11 @@ def _install(tarball, install_args=()):
if not _python_cmd('setup.py', 'install', *install_args):
log.warn('Something went wrong during the installation.')
log.warn('See the error message above.')
+ # exitcode will be 2
+ return 2
finally:
os.chdir(old_wd)
+ shutil.rmtree(tmpdir)
def _build_egg(egg, tarball, to_dir):
@@ -112,6 +116,7 @@ def _build_egg(egg, tarball, to_dir):
finally:
os.chdir(old_wd)
+ shutil.rmtree(tmpdir)
# returning the result
log.warn(egg)
if not os.path.exists(egg):
@@ -257,7 +262,7 @@ def _same_content(path, content):
def _rename_path(path):
new_name = path + '.OLD.%s' % time.time()
- log.warn('Renaming %s into %s', path, new_name)
+ log.warn('Renaming %s to %s', path, new_name)
os.rename(path, new_name)
return new_name
@@ -275,7 +280,7 @@ def _remove_flat_installation(placeholder):
log.warn('Could not locate setuptools*.egg-info')
return
- log.warn('Removing elements out of the way...')
+ log.warn('Moving elements out of the way...')
pkg_info = os.path.join(placeholder, file)
if os.path.isdir(pkg_info):
patched = _patch_egg_dir(pkg_info)
@@ -316,12 +321,12 @@ def _create_fake_setuptools_pkg_info(placeholder):
log.warn('%s already exists', pkg_info)
return
- if not os.access(pkg_info, os.W_OK):
+ log.warn('Creating %s', pkg_info)
+ try:
+ f = open(pkg_info, 'w')
+ except EnvironmentError:
log.warn("Don't have permissions to write %s, skipping", pkg_info)
return
-
- log.warn('Creating %s', pkg_info)
- f = open(pkg_info, 'w')
try:
f.write(SETUPTOOLS_PKG_INFO)
finally:
@@ -435,7 +440,7 @@ def _fake_setuptools():
res = _patch_egg_dir(setuptools_location)
if not res:
return
- log.warn('Patched done.')
+ log.warn('Patching complete.')
_relaunch()
@@ -443,8 +448,9 @@ def _relaunch():
log.warn('Relaunching...')
# we have to relaunch the process
# pip marker to avoid a relaunch bug
- _cmd = ['-c', 'install', '--single-version-externally-managed']
- if sys.argv[:3] == _cmd:
+ _cmd1 = ['-c', 'install', '--single-version-externally-managed']
+ _cmd2 = ['-c', 'install', '--record']
+ if sys.argv[:3] == _cmd1 or sys.argv[:3] == _cmd2:
sys.argv[0] = 'setup.py'
args = [sys.executable] + sys.argv
sys.exit(subprocess.call(args))
@@ -529,7 +535,7 @@ def main(version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
options = _parse_args()
tarball = download_setuptools(download_base=options.download_base)
- _install(tarball, _build_install_args(options))
+ return _install(tarball, _build_install_args(options))
if __name__ == '__main__':
- main()
+ sys.exit(main())