From 2507eea6a528045ff5f59ffeb3be134929cf59e1 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 3 Sep 2014 17:18:27 +0200 Subject: [PATCH] misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used --- setup.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 22e3cc2d..df66557f 100644 --- a/setup.py +++ b/setup.py @@ -121,13 +121,20 @@ class CustomInstall(install): """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)