From aed77efb9a098fb7269a9c0fedc189d1415f9c54 Mon Sep 17 00:00:00 2001 From: "John W. Parent" <45471568+johnwparent@users.noreply.github.com> Date: Wed, 7 Dec 2022 19:58:44 -0500 Subject: Windows: Prevent SameFileError when rpathing (#34332) --- lib/spack/llnl/util/filesystem.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lib/spack/llnl') diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index db83cea6fc..388c6fd173 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -2278,10 +2278,17 @@ class WindowsSimulatedRPath(object): """ self._addl_rpaths = self._addl_rpaths | set(paths) - def _link(self, path, dest): + def _link(self, path, dest_dir): + """Perform link step of simulated rpathing, installing + simlinks of file in path to the dest_dir + location. This method deliberately prevents + the case where a path points to a file inside the dest_dir. + This is because it is both meaningless from an rpath + perspective, and will cause an error when Developer + mode is not enabled""" file_name = os.path.basename(path) - dest_file = os.path.join(dest, file_name) - if os.path.exists(dest): + dest_file = os.path.join(dest_dir, file_name) + if os.path.exists(dest_dir) and not dest_file == path: try: symlink(path, dest_file) # For py2 compatibility, we have to catch the specific Windows error code @@ -2295,7 +2302,7 @@ class WindowsSimulatedRPath(object): "Linking library %s to %s failed, " % (path, dest_file) + "already linked." if already_linked else "library with name %s already exists at location %s." - % (file_name, dest) + % (file_name, dest_dir) ) pass else: -- cgit v1.2.3-60-g2f50