summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2023-05-17 19:17:41 +0200
committerGitHub <noreply@github.com>2023-05-17 10:17:41 -0700
commitd45818ccff0e9766d0839efb7d6dc795e3fa2e1a (patch)
tree0040c3b87954d7ef323f98332b0846df307f94e3 /lib
parentbcb7af6eb371b8958824e2f0551c4baa88d754a3 (diff)
downloadspack-d45818ccff0e9766d0839efb7d6dc795e3fa2e1a.tar.gz
spack-d45818ccff0e9766d0839efb7d6dc795e3fa2e1a.tar.bz2
spack-d45818ccff0e9766d0839efb7d6dc795e3fa2e1a.tar.xz
spack-d45818ccff0e9766d0839efb7d6dc795e3fa2e1a.zip
Limit deepcopy to just the initial "all" section (#37718)
Modifications: - [x] Limit the scope of the deepcopy when initializing module file writers
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/modules/common.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py
index 930bce8a92..dfcd20b0ce 100644
--- a/lib/spack/spack/modules/common.py
+++ b/lib/spack/spack/modules/common.py
@@ -170,17 +170,12 @@ def merge_config_rules(configuration, spec):
Returns:
dict: actions to be taken on the spec passed as an argument
"""
-
- # Get the top-level configuration for the module type we are using
- module_specific_configuration = copy.deepcopy(configuration)
-
- # Construct a dictionary with the actions we need to perform on the spec
- # passed as a parameter
-
+ # Construct a dictionary with the actions we need to perform on the spec passed as a parameter
+ spec_configuration = {}
# The keyword 'all' is always evaluated first, all the others are
# evaluated in order of appearance in the module file
- spec_configuration = module_specific_configuration.pop("all", {})
- for constraint, action in module_specific_configuration.items():
+ spec_configuration.update(copy.deepcopy(configuration.get("all", {})))
+ for constraint, action in configuration.items():
if spec.satisfies(constraint):
if hasattr(constraint, "override") and constraint.override:
spec_configuration = {}
@@ -200,14 +195,14 @@ def merge_config_rules(configuration, spec):
# configuration
# Hash length in module files
- hash_length = module_specific_configuration.get("hash_length", 7)
+ hash_length = configuration.get("hash_length", 7)
spec_configuration["hash_length"] = hash_length
- verbose = module_specific_configuration.get("verbose", False)
+ verbose = configuration.get("verbose", False)
spec_configuration["verbose"] = verbose
# module defaults per-package
- defaults = module_specific_configuration.get("defaults", [])
+ defaults = configuration.get("defaults", [])
spec_configuration["defaults"] = defaults
return spec_configuration