From a6ea0bbbaea533bc024fcc326fece709fe5b24a6 Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Thu, 24 Oct 2019 16:27:21 -0500 Subject: 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 --- var/spack/repos/builtin/packages/python/package.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py index 6087ff5be8..15901872e9 100644 --- a/var/spack/repos/builtin/packages/python/package.py +++ b/var/spack/repos/builtin/packages/python/package.py @@ -870,7 +870,18 @@ class Python(AutotoolsPackage): 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) -- cgit v1.2.3-70-g09d2