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:
		| @@ -870,7 +870,18 @@ def add_files_to_view(self, view, merge_map): | |||||||
|                         backup=False |                         backup=False | ||||||
|                     ) |                     ) | ||||||
|             else: |             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]) |                 new_link_target = os.path.abspath(merge_map[orig_link_target]) | ||||||
|                 view.link(new_link_target, dst) |                 view.link(new_link_target, dst) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Greg Becker
					Greg Becker