From 37edc78d76ed31b52063fc5b8234d9d4ac0f337c Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 16 Dec 2013 11:42:04 -0800 Subject: [PATCH] If symlink already exists, clobber it with current one --- setupbase.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/setupbase.py b/setupbase.py index 6426d7bf1..5a6eac620 100644 --- a/setupbase.py +++ b/setupbase.py @@ -377,15 +377,11 @@ class install_lib_symlink(Command): raise Exception("This doesn't work on Windows.") pkg = os.path.join(os.getcwd(), 'IPython') dest = os.path.join(self.install_dir, 'IPython') + if os.path.islink(dest): + print('removing existing symlink at %s' % dest) + os.unlink(dest) print('symlinking %s -> %s' % (pkg, dest)) - try: - os.symlink(pkg, dest) - except OSError as e: - if e.errno == errno.EEXIST and os.path.islink(dest) \ - and os.path.realpath(dest) == pkg: - print('Symlink already exists') - else: - raise + os.symlink(pkg, dest) class install_symlinked(install): def run(self):