Views: fix python in views when python prefix is under a symlink (#12575)

* Fix python in views when python prefix is under a symlink

* Add todo for future generalization
This commit is contained in:
Greg Becker 2019-10-24 16:27:21 -05:00 committed by GitHub
parent 0f22e528f3
commit a6ea0bbbae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -870,7 +870,18 @@ def add_files_to_view(self, view, merge_map):
backup=False
)
else:
orig_link_target = os.path.realpath(src)
# orig_link_target = os.path.realpath(src) is insufficient when
# the spack install tree is located at a symlink or a
# descendent of a symlink. What we need here is the real
# relative path from the python prefix to src
# TODO: generalize this logic in the link_tree object
# add a method to resolve a link relative to the link_tree
# object root.
realpath_src = os.path.realpath(src)
realpath_prefix = os.path.realpath(self.spec.prefix)
realpath_rel = os.path.relpath(realpath_src, realpath_prefix)
orig_link_target = os.path.join(self.spec.prefix, realpath_rel)
new_link_target = os.path.abspath(merge_map[orig_link_target])
view.link(new_link_target, dst)