From d4a28b4e22727aa2e41f5064e1456a728ed39a93 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 3 Jan 2025 19:30:48 -0600 Subject: [PATCH] PythonPackage: run test_imports in run env context --- lib/spack/spack/build_systems/python.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/build_systems/python.py b/lib/spack/spack/build_systems/python.py index 4484620d1f5..d9563993a93 100644 --- a/lib/spack/spack/build_systems/python.py +++ b/lib/spack/spack/build_systems/python.py @@ -19,6 +19,7 @@ import spack.builder import spack.config +import spack.context import spack.deptypes as dt import spack.detection import spack.multimethod @@ -237,7 +238,12 @@ def test_imports(self) -> None: purpose=f"checking import of {module}", work_dir="spack-test", ): - python("-c", f"import {module}") + setup_context = spack.build_environment.SetupContext( + self.spec, context=spack.context.Context.RUN + ) + mods = setup_context.get_env_modifications() + with mods.set_env(): + python("-c", f"import {module}") def update_external_dependencies(self, extendee_spec=None): """