summaryrefslogtreecommitdiff
path: root/lib/spack/llnl/util
diff options
context:
space:
mode:
authorJohn W. Parent <45471568+johnwparent@users.noreply.github.com>2022-12-07 19:58:44 -0500
committerGitHub <noreply@github.com>2022-12-07 16:58:44 -0800
commitaed77efb9a098fb7269a9c0fedc189d1415f9c54 (patch)
treef5e0a6c64a4e8c3032b50c5d53310bbc94437c2a /lib/spack/llnl/util
parentab6499ce1e4c8c6f043c52226b9eb50dc96ddfc9 (diff)
downloadspack-aed77efb9a098fb7269a9c0fedc189d1415f9c54.tar.gz
spack-aed77efb9a098fb7269a9c0fedc189d1415f9c54.tar.bz2
spack-aed77efb9a098fb7269a9c0fedc189d1415f9c54.tar.xz
spack-aed77efb9a098fb7269a9c0fedc189d1415f9c54.zip
Windows: Prevent SameFileError when rpathing (#34332)
Diffstat (limited to 'lib/spack/llnl/util')
-rw-r--r--lib/spack/llnl/util/filesystem.py15
1 files changed, 11 insertions, 4 deletions
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: