[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command easy_install.py, 1.24, 1.25
pje@users.sourceforge.net
pje at users.sourceforge.net
Tue Aug 23 15:35:04 CEST 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31447/setuptools/command
Modified Files:
easy_install.py
Log Message:
D'oh! os.path.islink is available on all platforms. Also, ensure that we
do directory tree removals only if isdir() and not islink(), and use
unlink() in all other cases.
Index: easy_install.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/easy_install.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- easy_install.py 23 Aug 2005 13:24:42 -0000 1.24
+++ easy_install.py 23 Aug 2005 13:34:52 -0000 1.25
@@ -104,10 +104,8 @@
for filename in blockers:
log.info("Deleting %s", filename)
if not self.dry_run:
- if hasattr(os.path,'islink') and os.path.islink(filename):
- os.unlink(filename)
- elif os.path.isdir(filename):
- shutil.rmtree(filename)
+ if os.path.isdir(filename) and not os.path.islink(filename):
+ shutil.rmtree(filename)
else:
os.unlink(filename)
@@ -121,6 +119,8 @@
+
+
def finalize_options(self):
# If a non-default installation directory was specified, default the
# script directory to match it.
@@ -547,9 +547,9 @@
dist = self.egg_distribution(egg_path)
self.check_conflicts(dist)
if not samefile(egg_path, destination):
- if os.path.isdir(destination):
+ if os.path.isdir(destination) and not os.path.islink(destination):
dir_util.remove_tree(destination, dry_run=self.dry_run)
- elif os.path.isfile(destination):
+ elif os.path.exists(destination):
self.execute(os.unlink,(destination,),"Removing "+destination)
if os.path.isdir(egg_path):
@@ -841,24 +841,24 @@
if dist.location not in self.shadow_path:
self.shadow_path.append(dist.location)
- self.pth_file.save()
+ if not self.dry_run:
- if dist.key=='setuptools':
- # Ensure that setuptools itself never becomes unavailable!
- # XXX should this check for latest version?
- filename = os.path.join(self.install_dir,'setuptools.pth')
- unlink_if_symlink(filename)
- f = open(filename, 'wt')
- f.write(dist.location+'\n')
- f.close()
+ self.pth_file.save()
+ if dist.key=='setuptools':
+ # Ensure that setuptools itself never becomes unavailable!
+ # XXX should this check for latest version?
+ filename = os.path.join(self.install_dir,'setuptools.pth')
+ if os.path.islink(filename): unlink(filename)
+ f = open(filename, 'wt')
+ f.write(dist.location+'\n')
+ f.close()
def unpack_progress(self, src, dst):
# Progress filter for unpacking
log.debug("Unpacking %s to %s", src, dst)
return dst # only unpack-and-compile skips files for dry run
-
def unpack_and_compile(self, egg_path, destination):
to_compile = []
@@ -1017,9 +1017,9 @@
f.close()
-def unlink_if_symlink(filename):
- if hasattr(os.path,'islink') and os.path.islink(filename):
- os.unlink(filename)
+
+
+
@@ -1100,11 +1100,11 @@
if self.dirty:
log.debug("Saving %s", self.filename)
data = '\n'.join(self.paths+[''])
- unlink_if_symlink(self.filename)
+ if os.path.islink(self.filename):
+ os.unlink(self.filename)
f = open(self.filename,'wt'); f.write(data); f.close()
self.dirty = False
-
def add(self,dist):
"""Add `dist` to the distribution map"""
if dist.location not in self.paths:
More information about the Python-checkins
mailing list