diff options
author | Mattias Andrée <maandree@operamail.com> | 2012-09-11 11:35:55 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2012-09-11 11:35:55 +0200 |
commit | 21fb804c39b428f17f584bffa41a20ac54a545f9 (patch) | |
tree | c5b05eb8ea034c1883465d37048f9f60402774ca | |
parent | 61d5ad76ea47ed248e1a2043f0caa742a987900a (diff) | |
download | ponysay-21fb804c39b428f17f584bffa41a20ac54a545f9.tar.gz ponysay-21fb804c39b428f17f584bffa41a20ac54a545f9.tar.bz2 ponysay-21fb804c39b428f17f584bffa41a20ac54a545f9.zip |
setup linking fix
-rwxr-xr-x | setup.py | 35 |
1 files changed, 30 insertions, 5 deletions
@@ -705,7 +705,7 @@ class Setup(): print('Creating symbolic link %s with target directory %s' % (dest, target)) if os.path.exists(dest): self.removeLists([], [dest]) - os.symlink(target, dest) + self.symlink(target, dest) if os.path.islink(source) and (self.linking != COPY) and os.path.isfile(os.path.realpath(source)): target = os.readlink(source) if self.linking == HARD: @@ -718,13 +718,13 @@ class Setup(): os.link(mytarget, dest) else: print('\033[31mTarget did not exists, using symlink instead\033[39m') - os.symlink(target, dest) + self.symlink(target, dest) else: for dest in destinations: print('Creating symbolic link %s with target file %s' % (dest, target)) if os.path.exists(dest): self.removeLists([], [dest]) - os.symlink(target, dest) + self.symlink(target, dest) for dest in destinations: dir = dest[:dest.rfind('/') + 1] if not os.path.exists(dir): @@ -750,7 +750,7 @@ class Setup(): print('Creating symbolic link %s with target directory %s' % (dest, target)) if os.path.exists(dest): self.removeLists([], [dest]) - os.symlink(target, dest) + self.symlink(target, dest) else: target = destinations[0] for dest in destinations if self.linking == COPY else [target]: @@ -767,7 +767,32 @@ class Setup(): print('Creating symbolic link %s with target file %s' % (dest, target)) if os.path.exists(dest): os.unlink(dest) - os.symlink(target, dest) + self.symlink(target, dest) + + + ''' + Create a symlink with a relative path + ''' + def symlink(self, target, dest): + if target.startswith('./') or target.startswith('../'): + os.symlink(target, dest) + elif '/' not in target: + os.symlink('./' + target, dest) + else: + targets = target.split('/') + dests = dest.split('/') + + while (len(targets) > 1) and (len(target) > 1) and (targets[0] == dests[0]): + targets = targets[1:] + dests = dests[1:] + + if (len(dests) == 1): + targets = ['.'] + targets + else: + targets = (['..'] * (len(dests) - 1)) + targets + + print('>>> ' + str(targets) + ' -> ' + dest) + os.symlink('/'.join(targets), dest) ''' |