summaryrefslogtreecommitdiff
path: root/setuptools/command
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-11-05 16:32:36 +0000
committerPJ Eby <distutils-sig@python.org>2005-11-05 16:32:36 +0000
commitc66760cc42a5584b4c4cc3fa9094a317e2584789 (patch)
tree143b0208f787ea05ad276a650b29f3f34322f6c4 /setuptools/command
parentf9aa7e9e50d68830954facf280a02b551357c524 (diff)
downloadpython-setuptools-git-c66760cc42a5584b4c4cc3fa9094a317e2584789.tar.gz
Fix rmtree() brokenness with Python 2.4 by breaking down and copying
shutil.rmtree from 2.4 directly into easy_install.py. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041402
Diffstat (limited to 'setuptools/command')
-rwxr-xr-xsetuptools/command/easy_install.py82
1 files changed, 41 insertions, 41 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index eb4952c0..1d0f1188 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -106,7 +106,7 @@ class easy_install(Command):
log.info("Deleting %s", filename)
if not self.dry_run:
if os.path.isdir(filename) and not os.path.islink(filename):
- shutil.rmtree(filename)
+ rmtree(filename)
else:
os.unlink(filename)
@@ -318,7 +318,7 @@ class easy_install(Command):
finally:
if os.path.exists(tmpdir):
- smart_rmtree(tmpdir)
+ rmtree(tmpdir)
@@ -856,7 +856,7 @@ See the setuptools documentation for the "develop" command for more info.
dist_dir)
return eggs
finally:
- shutil.rmtree(dist_dir)
+ rmtree(dist_dir)
log.set_verbosity(self.verbose) # restore our log verbosity
def update_pth(self,dist):
@@ -1173,7 +1173,6 @@ def get_script_header(script_text):
executable = os.path.normpath(sys.executable)
return "#!%(executable)s%(options)s\n" % locals()
-
def main(argv=None, **kw):
from setuptools import setup
if argv is None:
@@ -1181,46 +1180,47 @@ def main(argv=None, **kw):
setup(script_args = ['-q','easy_install', '-v']+argv, **kw)
+def auto_chmod(func, arg, exc):
+ if func is os.remove and os.name=='nt':
+ os.chmod(arg, stat.S_IWRITE)
+ return func(arg)
+ exc = sys.exc_info()
+ raise exc[0], (exc[1][0], exc[1][1] + (" %s %s" % (func,arg)))
+def rmtree(path, ignore_errors=False, onerror=auto_chmod):
+ """Recursively delete a directory tree.
-
-
-
-
-def smart_rmtree(path):
- """Recursively delete a directory tree."""
- cmdtuples = []
- shutil._build_cmdtuple(path, cmdtuples)
- for func, arg in cmdtuples:
+ This code is taken from the Python 2.4 version of 'shutil', because
+ the 2.3 version doesn't really work right.
+ """
+ if ignore_errors:
+ def onerror(*args):
+ pass
+ elif onerror is None:
+ def onerror(*args):
+ raise
+ names = []
+ try:
+ names = os.listdir(path)
+ except os.error, err:
+ onerror(os.listdir, path, sys.exc_info())
+ for name in names:
+ fullname = os.path.join(path, name)
try:
- func(arg)
- except OSError:
- if os.name=='nt' and func is not os.rmdir:
- os.chmod(arg, stat.S_IWRITE)
- try:
- func(arg)
- continue
- except OSError:
- pass
- exc = sys.exc_info()
- raise exc[0], (exc[1][0], exc[1][1] + ' removing '+arg)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ mode = os.lstat(fullname).st_mode
+ except os.error:
+ mode = 0
+ if stat.S_ISDIR(mode):
+ rmtree(fullname, ignore_errors, onerror)
+ else:
+ try:
+ os.remove(fullname)
+ except os.error, err:
+ onerror(os.remove, fullname, sys.exc_info())
+ try:
+ os.rmdir(path)
+ except os.error:
+ onerror(os.rmdir, path, sys.exc_info())