aboutsummaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-06-01 13:46:52 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-06-09 13:07:52 +0000
commit6d8dee0c92dc914a501e2e0fe3a5e044f5d6d872 (patch)
tree5e7516c5b47983d9bc3fb1e792837b41d45dabdc /utils.py
parent5ff239ac4f1b34e2b3317f0968a61658d8c586d6 (diff)
utils: Handle Symlinks
Try to recreate the .so version symlinks correctly on Linux instead of copying the files. Task-number: PYSIDE-526 Change-Id: I3b015efe4f2f57abe418f171a8631d194ed08f65 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/utils.py b/utils.py
index f7be19d1b..a3f9a41d9 100644
--- a/utils.py
+++ b/utils.py
@@ -231,9 +231,28 @@ def copyfile(src, dst, force=True, vars=None):
log.info("**Skiping copy file %s to %s. Source does not exists." % (src, dst))
return
- log.info("Copying file %s to %s." % (src, dst))
-
- shutil.copy2(src, dst)
+ if not os.path.islink(src):
+ log.info("Copying file %s to %s." % (src, dst))
+ shutil.copy2(src, dst)
+ else:
+ linkTargetPath = os.path.realpath(src)
+ if os.path.dirname(linkTargetPath) == os.path.dirname(src):
+ linkTarget = os.path.basename(linkTargetPath)
+ linkName = os.path.basename(src)
+ currentDirectory = os.getcwd()
+ try:
+ targetDir = dst if os.path.isdir(dst) else os.path.dirname(dst)
+ os.chdir(targetDir)
+ if os.path.exists(linkName):
+ os.remove(linkName)
+ log.info("Symlinking %s -> %s in %s." % (linkName, linkTarget, targetDir))
+ os.symlink(linkTarget, linkName)
+ except OSError:
+ log.error("%s -> %s: Error creating symlink" % (linkName, linkTarget))
+ finally:
+ os.chdir(currentDirectory)
+ else:
+ log.error("%s -> %s: Can only create symlinks within the same directory" % (src, linkTargetPath))
return dst