From 8a02463d7d14de275d5090fdf07a29af26d44e0e Mon Sep 17 00:00:00 2001 From: Sean Koyama Date: Thu, 15 Dec 2022 10:52:09 -0600 Subject: IntelOneApiPackage: add envmods variant to toggle environment modifications by oneapi packages (#34253) Co-authored-by: Sean Koyama Co-authored-by: Robert Cohn --- lib/spack/spack/build_systems/oneapi.py | 19 ++++++++++++++----- .../builtin/packages/intel-oneapi-mkl/package.py | 6 ++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/spack/spack/build_systems/oneapi.py b/lib/spack/spack/build_systems/oneapi.py index 9f009918fd..b7456a5775 100644 --- a/lib/spack/spack/build_systems/oneapi.py +++ b/lib/spack/spack/build_systems/oneapi.py @@ -10,7 +10,7 @@ from os.path import basename, dirname, isdir from llnl.util.filesystem import find_headers, find_libraries, join_path -from spack.directives import conflicts +from spack.directives import conflicts, variant from spack.util.environment import EnvironmentModifications from spack.util.executable import Executable @@ -36,6 +36,13 @@ class IntelOneApiPackage(Package): ]: conflicts(c, msg="This package in only available for x86_64 and Linux") + # Add variant to toggle environment modifications from vars.sh + variant( + "envmods", + default=True, + description="Toggles environment modifications", + ) + @staticmethod def update_description(cls): """Updates oneapi package descriptions with common text.""" @@ -114,11 +121,13 @@ class IntelOneApiPackage(Package): $ source {prefix}/{component}/{version}/env/vars.sh """ - env.extend( - EnvironmentModifications.from_sourcing_file( - join_path(self.component_prefix, "env", "vars.sh") + # Only if environment modifications are desired (default is +envmods) + if "+envmods" in self.spec: + env.extend( + EnvironmentModifications.from_sourcing_file( + join_path(self.component_prefix, "env", "vars.sh") + ) ) - ) class IntelOneApiLibraryPackage(IntelOneApiPackage): diff --git a/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py b/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py index 41b8f12b12..62befb387d 100644 --- a/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py +++ b/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py @@ -131,8 +131,10 @@ class IntelOneapiMkl(IntelOneApiLibraryPackage): env.append_path("__INTEL_POST_FFLAGS", flag, separator=" ") def setup_dependent_build_environment(self, env, dependent_spec): - env.set("MKLROOT", self.component_prefix) - env.append_path("PKG_CONFIG_PATH", self.component_prefix.lib.pkgconfig) + # Only if environment modifications are desired (default is +envmods) + if "+envmods" in self.spec: + env.set("MKLROOT", self.component_prefix) + env.append_path("PKG_CONFIG_PATH", self.component_prefix.lib.pkgconfig) def _find_mkl_libs(self, shared): libs = [] -- cgit v1.2.3-70-g09d2