spack load/environments: allow customization of prefix inspections (#18260)

`spack load` and `spack env activate` now use the prefix inspections
defined in `modules.yaml`. This allows users to customize/override
environment variable modifications if desired.

If no `prefix_inspections` configuration is present, Spack uses the
values in the default configuration.
This commit is contained in:
Dr. Christian Tacke 2020-11-17 23:04:13 +01:00 committed by GitHub
parent 5f636fc317
commit d65f078f66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@
import sys import sys
import os import os
import spack.config
import spack.util.prefix as prefix import spack.util.prefix as prefix
import spack.util.environment as environment import spack.util.environment as environment
import spack.build_environment as build_env import spack.build_environment as build_env
@ -25,6 +26,10 @@ def prefix_inspections(platform):
A dictionary mapping subdirectory names to lists of environment A dictionary mapping subdirectory names to lists of environment
variables to modify with that directory if it exists. variables to modify with that directory if it exists.
""" """
inspections = spack.config.get('modules:prefix_inspections', None)
if inspections is not None:
return inspections
inspections = { inspections = {
'bin': ['PATH'], 'bin': ['PATH'],
'lib': ['LD_LIBRARY_PATH', 'LIBRARY_PATH'], 'lib': ['LD_LIBRARY_PATH', 'LIBRARY_PATH'],