summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-03-26 20:00:28 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-03-27 11:32:42 -0700
commitcde33205827edbed988ec4548c983ff93e9445c6 (patch)
tree31b672b445a6aabc58771e88ec800dce4759de9f
parentdce590fb21af844230727b283f6c8bf759ea805c (diff)
downloadspack-cde33205827edbed988ec4548c983ff93e9445c6.tar.gz
spack-cde33205827edbed988ec4548c983ff93e9445c6.tar.bz2
spack-cde33205827edbed988ec4548c983ff93e9445c6.tar.xz
spack-cde33205827edbed988ec4548c983ff93e9445c6.zip
Add a method to find the containing directory of a library.
-rw-r--r--lib/spack/llnl/util/filesystem.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index c4665c284c..92f9ca2983 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -27,7 +27,7 @@ __all__ = ['set_install_permissions', 'install', 'install_tree', 'traverse_tree'
'force_remove', 'join_path', 'ancestor', 'can_access', 'filter_file',
'FileFilter', 'change_sed_delimiter', 'is_exe', 'force_symlink',
'set_executable', 'copy_mode', 'unset_executable_mode',
- 'remove_dead_links', 'remove_linked_tree']
+ 'remove_dead_links', 'remove_linked_tree', 'find_library_path']
import os
import sys
@@ -392,3 +392,18 @@ def remove_linked_tree(path):
os.unlink(path)
else:
shutil.rmtree(path, True)
+
+
+def find_library_path(libname, *paths):
+ """Searches for a file called <libname> in each path.
+
+ Return:
+ directory where the library was found, if found. None otherwise.
+
+ """
+ for path in paths:
+ library = join_path(path, libname)
+ if os.path.exists(library):
+ return path
+ return None
+