From 0558fd640eadc979f8f44e0ffaf8b212dbd1b9e0 Mon Sep 17 00:00:00 2001 From: "Kelly (KT) Thompson" Date: Sat, 16 Sep 2017 14:26:29 -0600 Subject: Improve external package location detection algorithm. (#5145) Also inspect `PATH` to help locate an external package and provide a test for getting path from module's PATH. Fixes #5141 --- lib/spack/spack/test/module_parsing.py | 3 ++- lib/spack/spack/util/module_cmd.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/test/module_parsing.py b/lib/spack/spack/test/module_parsing.py index 63eafcca26..7483b66ebb 100644 --- a/lib/spack/spack/test/module_parsing.py +++ b/lib/spack/spack/test/module_parsing.py @@ -53,7 +53,8 @@ def test_get_path_from_module(save_env): lines = ['prepend-path LD_LIBRARY_PATH /path/to/lib', 'setenv MOD_DIR /path/to', 'setenv LDFLAGS -Wl,-rpath/path/to/lib', - 'setenv LDFLAGS -L/path/to/lib'] + 'setenv LDFLAGS -L/path/to/lib', + 'prepend-path PATH /path/to/bin'] for line in lines: module_func = '() { eval `echo ' + line + ' bash filler`\n}' diff --git a/lib/spack/spack/util/module_cmd.py b/lib/spack/spack/util/module_cmd.py index c2448aa278..a726023d95 100644 --- a/lib/spack/spack/util/module_cmd.py +++ b/lib/spack/spack/util/module_cmd.py @@ -187,6 +187,12 @@ def get_path_from_module(mod): if L >= 0: return line[L + 2:line.find('/lib')] + # If it sets the PATH, use it + for line in text: + if line.find('PATH') >= 0: + path = get_argument_from_module_line(line) + return path[:path.find('/bin')] + # Unable to find module path return None -- cgit v1.2.3-70-g09d2