summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-08-23 13:34:52 +0000
committerPJ Eby <distutils-sig@python.org>2005-08-23 13:34:52 +0000
commit9b6dcdbf76e0c735b0d8cf00769cbd04fe4f8e18 (patch)
treea83743b026819a69fa1b8c346040e979272c60a9
parentb2382a4ed6703da09393343974c87ce0f4ce6670 (diff)
downloadpython-setuptools-git-9b6dcdbf76e0c735b0d8cf00769cbd04fe4f8e18.tar.gz
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. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041230
-rwxr-xr-xsetuptools/command/easy_install.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index db865e80..bf46b715 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -104,10 +104,8 @@ class easy_install(Command):
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 @@ class easy_install(Command):
+
+
def finalize_options(self):
# If a non-default installation directory was specified, default the
# script directory to match it.
@@ -547,9 +547,9 @@ class easy_install(Command):
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 @@ See the setuptools documentation for the "develop" command for more info.
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 @@ def extract_wininst_cfg(dist_filename):
f.close()
-def unlink_if_symlink(filename):
- if hasattr(os.path,'islink') and os.path.islink(filename):
- os.unlink(filename)
+
+
+
@@ -1100,11 +1100,11 @@ class PthDistributions(Environment):
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: