diff options
Diffstat (limited to 'lib/spack/spack/detection/common.py')
-rw-r--r-- | lib/spack/spack/detection/common.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/spack/spack/detection/common.py b/lib/spack/spack/detection/common.py index 4f56a526aa..a8f0e82a87 100644 --- a/lib/spack/spack/detection/common.py +++ b/lib/spack/spack/detection/common.py @@ -150,6 +150,29 @@ def executable_prefix(executable_dir): return os.sep.join(components[:idx]) +def library_prefix(library_dir): + """Given a directory where an library is found, guess the prefix + (i.e. the "root" directory of that installation) and return it. + + Args: + library_dir: directory where an library is found + """ + # Given a prefix where an library is found, assuming that prefix + # contains /lib/ or /lib64/, strip off the 'lib' or 'lib64' directory + # to get a Spack-compatible prefix + assert os.path.isdir(library_dir) + + components = library_dir.split(os.sep) + if 'lib64' in components: + idx = components.index('lib64') + return os.sep.join(components[:idx]) + elif 'lib' in components: + idx = components.index('lib') + return os.sep.join(components[:idx]) + else: + return library_dir + + def update_configuration(detected_packages, scope=None, buildable=True): """Add the packages passed as arguments to packages.yaml |