summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/build_environment.py19
-rw-r--r--lib/spack/spack/test/build_environment.py8
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index 93ff1512a7..63b1309a22 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -64,6 +64,7 @@ import spack.store
import spack.subprocess_context
import spack.user_environment
import spack.util.path
+import spack.util.pattern
from spack.error import NoHeadersError, NoLibrariesError
from spack.installer import InstallError
from spack.util.cpus import cpus_available
@@ -993,8 +994,24 @@ def modifications_from_dependencies(
dpkg = dep.package
if set_package_py_globals:
set_module_variables_for_package(dpkg)
+
# Allow dependencies to modify the module
- dpkg.setup_dependent_package(spec.package.module, spec)
+ # Get list of modules that may need updating
+ modules = []
+ for cls in inspect.getmro(type(spec.package)):
+ module = cls.module
+ if module == spack.package_base:
+ break
+ modules.append(module)
+
+ # Execute changes as if on a single module
+ # copy dict to ensure prior changes are available
+ changes = spack.util.pattern.Bunch()
+ dpkg.setup_dependent_package(changes, spec)
+
+ for module in modules:
+ module.__dict__.update(changes.__dict__)
+
if context == "build":
dpkg.setup_dependent_build_environment(env, spec)
else:
diff --git a/lib/spack/spack/test/build_environment.py b/lib/spack/spack/test/build_environment.py
index 41a5475c89..6ba8fc056f 100644
--- a/lib/spack/spack/test/build_environment.py
+++ b/lib/spack/spack/test/build_environment.py
@@ -177,6 +177,14 @@ def test_cc_not_changed_by_modules(monkeypatch, working_env):
assert os.environ["ANOTHER_VAR"] == "THIS_IS_SET"
+def test_setup_dependent_package_inherited_modules(
+ config, working_env, mock_packages, install_mockery, mock_fetch
+):
+ # This will raise on regression
+ s = spack.spec.Spec("cmake-client-inheritor").concretized()
+ s.package.do_install()
+
+
@pytest.mark.parametrize(
"initial,modifications,expected",
[