changeset 1154:6365e6826831

misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
author Goffi <goffi@goffi.org>
date Wed, 03 Sep 2014 17:18:27 +0200
parents 25a16df15ae2
children a1d47760df3f
files setup.py
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Wed Sep 03 16:40:52 2014 +0200
+++ b/setup.py	Wed Sep 03 17:18:27 2014 +0200
@@ -121,13 +121,20 @@
         """Create symbolic links to executables"""
         # the script which launch the daemon
         for source, dest in self.sh_script_links:
-            if os.path.islink(dest) and os.readlink(dest) != source:
-                os.remove(dest)  # copy_file doesn't force the link update
-            dest_name, copied = copy_file(source, dest, link='sym')
-            assert copied
-            # we change the perm in the same way as in the original install_scripts
-            mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777
-            os.chmod(dest_name, mode)
+            if self.root is None:
+                if os.path.islink(dest) and os.readlink(dest) != source:
+                    os.remove(dest)  # copy_file doesn't force the link update
+                dest_name, copied = copy_file(source, dest, link='sym')
+                assert copied
+                # we change the perm in the same way as in the original install_scripts
+                mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777
+                os.chmod(dest_name, mode)
+            else:
+                # if root is not None, source probably doesn't exist yet
+                # this is not managed by copy_file, so we must use os.symlink directly
+                if os.path.islink(dest):
+                    os.remove(dest)  # symlink doesn't force the link update
+                os.symlink(source, dest)
 
     def run(self):
         ignore_idx = 0 if self.root is None else len(self.root)