summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralalazo <massimiliano.culpo@googlemail.com>2016-03-17 14:14:18 +0100
committeralalazo <massimiliano.culpo@googlemail.com>2016-03-17 14:14:18 +0100
commit9cdd79e33f8463699fcea0b668eafac1c9fae1d4 (patch)
tree93ba5ad8b1c687ae0dbd2a1eae07c6b27c816a7e
parentac762e95a6213e1514f29d3d6501e4a95dd3e1d4 (diff)
downloadspack-9cdd79e33f8463699fcea0b668eafac1c9fae1d4.tar.gz
spack-9cdd79e33f8463699fcea0b668eafac1c9fae1d4.tar.bz2
spack-9cdd79e33f8463699fcea0b668eafac1c9fae1d4.tar.xz
spack-9cdd79e33f8463699fcea0b668eafac1c9fae1d4.zip
modules : restored previous logic for path inspection
-rw-r--r--lib/spack/spack/modules.py54
1 files changed, 31 insertions, 23 deletions
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index b64a8b3226..7e395736e4 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -74,29 +74,37 @@ def print_help():
"")
-def inspect_path(path):
- class PathInspector(object):
- dirname2varname = {
- 'bin': ('PATH',),
- 'man': ('MANPATH',),
- 'lib': ('LIBRARY_PATH', 'LD_LIBRARY_PATH'),
- 'lib64': ('LIBRARY_PATH', 'LD_LIBRARY_PATH'),
- 'include': ('CPATH',),
- 'pkgconfig': ('PKG_CONFIG_PATH',)
- }
-
- def __call__(self, env, directory, names):
- for name in names:
- variables = PathInspector.dirname2varname.get(name, None)
- if variables is None:
- continue
- absolute_path = join_path(os.path.abspath(directory), name)
- for variable in variables:
- env.prepend_path(variable, absolute_path)
-
- env, inspector = EnvironmentModifications(), PathInspector()
- os.path.walk(path, inspector, env)
- env.prepend_path('CMAKE_PREFIX_PATH', path)
+def inspect_path(prefix):
+ """
+ Inspects the prefix of an installation to search for common layouts. Issues a request to modify the environment
+ accordingly when an item is found.
+
+ Args:
+ prefix: prefix of the installation
+
+ Returns:
+ instance of EnvironmentModifications containing the requested modifications
+ """
+ env = EnvironmentModifications()
+ # Inspect the prefix to check for the existence of common directories
+ prefix_inspections = {
+ 'bin': ('PATH',),
+ 'man': ('MANPATH',),
+ 'lib': ('LIBRARY_PATH', 'LD_LIBRARY_PATH'),
+ 'lib64': ('LIBRARY_PATH', 'LD_LIBRARY_PATH'),
+ 'include': ('CPATH',)
+ }
+ for attribute, variables in prefix_inspections.items():
+ expected = getattr(prefix, attribute)
+ if os.path.isdir(expected):
+ for variable in variables:
+ env.prepend_path(variable, expected)
+ # PKGCONFIG
+ for expected in (join_path(prefix.lib, 'pkgconfig'), join_path(prefix.lib64, 'pkgconfig')):
+ if os.path.isdir(expected):
+ env.prepend_path('PKG_CONFIG_PATH', expected)
+ # CMake related variables
+ env.prepend_path('CMAKE_PREFIX_PATH', prefix)
return env