Skip to content
Snippets Groups Projects
Unverified Commit ad1ad836 authored by Adam J. Stewart's avatar Adam J. Stewart Committed by GitHub
Browse files

IntelPackage: setup_env -> setup_build_env (#13888)

parent f6781d65
No related branches found
No related tags found
No related merge requests found
......@@ -89,7 +89,7 @@ class IntelPackage(PackageBase):
2. :py:meth:`~.IntelPackage.install`
They both have sensible defaults and for many packages the
only thing necessary will be to override setup_environment
only thing necessary will be to override setup_run_environment
to set the appropriate environment variables.
"""
#: Phases of an Intel package
......@@ -455,9 +455,7 @@ def normalize_suite_dir(self, suite_dir_name, version_globs=['*.*.*']):
break
if not matching_dirs:
# No match -- this *will* happen during pre-build call to
# setup_environment() when the destination dir is still empty.
# Return a sensible value anyway.
# No match -- return a sensible value anyway.
d = unversioned_dirname
debug_print(d)
......@@ -889,15 +887,15 @@ def mpi_compiler_wrappers(self):
# debug_print("wrapper_vars =", wrapper_vars)
return wrapper_vars
def mpi_setup_dependent_environment(
self, spack_env, run_env, dependent_spec, compilers_of_client={}):
'''Unified back-end for setup_dependent_environment() of Intel packages
that provide 'mpi'.
def mpi_setup_dependent_build_environment(
self, env, dependent_spec, compilers_of_client={}):
'''Unified back-end for setup_dependent_build_environment() of
Intel packages that provide 'mpi'.
Parameters:
spack_env, run_env, dependent_spec: same as in
setup_dependent_environment().
env, dependent_spec: same as in
setup_dependent_build_environment().
compilers_of_client (dict): Conveys spack_cc, spack_cxx, etc.,
from the scope of dependent packages; constructed in caller.
......@@ -939,10 +937,10 @@ def mpi_setup_dependent_environment(
# Ensure that the directory containing the compiler wrappers is in the
# PATH. Spack packages add `prefix.bin` to their dependents' paths,
# but because of the intel directory hierarchy that is insufficient.
spack_env.prepend_path('PATH', os.path.dirname(wrapper_vars['MPICC']))
env.prepend_path('PATH', os.path.dirname(wrapper_vars['MPICC']))
for key, value in wrapper_vars.items():
spack_env.set(key, value)
env.set(key, value)
debug_print("adding to spack_env:", wrapper_vars)
......@@ -995,7 +993,7 @@ def libs(self):
debug_print(result)
return result
def setup_environment(self, spack_env, run_env):
def setup_run_environment(self, env):
"""Adds environment variables to the generated module file.
These environment variables come from running:
......@@ -1005,24 +1003,7 @@ def setup_environment(self, spack_env, run_env):
$ source parallel_studio_xe_2017/bin/psxevars.sh intel64
[and likewise for MKL, MPI, and other components]
"""
# https://spack.readthedocs.io/en/latest/spack.html#spack.package.PackageBase.setup_environment
#
# spack_env -> Applied when dependent is built within Spack.
# Not used here.
# run_env -> Applied to the modulefile of dependent.
#
# NOTE: Spack runs setup_environment twice, once pre-build to set up
# the build environment, and once post-installation to determine
# the environment variables needed at run-time to add to the module
# file. The script we need to source is only present post-installation,
# so check for its existence before sourcing.
# TODO: At some point we should split setup_environment into
# setup_build_environment and setup_run_environment to get around
# this problem.
f = self.file_to_source
if not f or not os.path.isfile(f):
return
tty.debug("sourcing " + f)
# All Intel packages expect at least the architecture as argument.
......@@ -1034,15 +1015,9 @@ def setup_environment(self, spack_env, run_env):
# if sys.platform == 'darwin':
# args = ()
run_env.extend(EnvironmentModifications.from_sourcing_file(f, *args))
env.extend(EnvironmentModifications.from_sourcing_file(f, *args))
def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
# https://spack.readthedocs.io/en/latest/spack.html#spack.package.PackageBase.setup_dependent_environment
#
# spack_env -> Applied when dependent is built within Spack.
# run_env -> Applied to the modulefile of dependent.
# Not used here.
#
def setup_dependent_build_environment(self, env, dependent_spec):
# NB: This function is overwritten by 'mpi' provider packages:
#
# var/spack/repos/builtin/packages/intel-mpi/package.py
......@@ -1052,18 +1027,20 @@ def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
# dictionary kwarg compilers_of_client{} present and populated.
# Handle everything in a callback version.
self._setup_dependent_env_callback(spack_env, run_env, dependent_spec)
self._setup_dependent_env_callback(env, dependent_spec)
def _setup_dependent_env_callback(
self, spack_env, run_env, dependent_spec, compilers_of_client={}):
# Expected to be called from a client's setup_dependent_environment(),
self, env, dependent_spec, compilers_of_client={}):
# Expected to be called from a client's
# setup_dependent_build_environment(),
# with args extended to convey the client's compilers as needed.
if '+mkl' in self.spec or self.provides('mkl'):
# Spack's env philosophy demands that we replicate some of the
# settings normally handled by file_to_source ...
#
# TODO: Why is setup_environment() [which uses file_to_source()]
# TODO: Why is setup_run_environment()
# [which uses file_to_source()]
# not called as a matter of course upon entering the current
# function? (guarding against multiple calls notwithstanding)
#
......@@ -1073,16 +1050,16 @@ def _setup_dependent_env_callback(
'SPACK_COMPILER_EXTRA_RPATHS': self.component_lib_dir('mkl'),
}
spack_env.set('MKLROOT', env_mods['MKLROOT'])
spack_env.append_path('SPACK_COMPILER_EXTRA_RPATHS',
env_mods['SPACK_COMPILER_EXTRA_RPATHS'])
env.set('MKLROOT', env_mods['MKLROOT'])
env.append_path('SPACK_COMPILER_EXTRA_RPATHS',
env_mods['SPACK_COMPILER_EXTRA_RPATHS'])
debug_print("adding/modifying spack_env:", env_mods)
if '+mpi' in self.spec or self.provides('mpi'):
if compilers_of_client:
self.mpi_setup_dependent_environment(
spack_env, run_env, dependent_spec, compilers_of_client)
self.mpi_setup_dependent_build_environment(
env, dependent_spec, compilers_of_client)
# We could forego this nonce function and inline its code here,
# but (a) it sisters mpi_compiler_wrappers() [needed twice]
# which performs dizzyingly similar but necessarily different
......
......@@ -43,7 +43,7 @@ class IntelMpi(IntelPackage):
provides('mpi')
def setup_dependent_environment(self, *args):
def setup_dependent_build_environment(self, *args):
# Handle in callback, conveying client's compilers in additional arg.
# CAUTION - DUP code in:
# ../intel-mpi/package.py
......
......@@ -199,7 +199,7 @@ class IntelParallelStudio(IntelPackage):
conflicts('auto_dispatch=SSE3', 'platform=darwin target=x86_64:',
msg='SSE3 is not supported on MacOS x86_64')
def setup_dependent_environment(self, *args):
def setup_dependent_build_environment(self, *args):
# Handle in callback, conveying client's compilers in additional arg.
# CAUTION - DUP code in:
# ../intel-mpi/package.py
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment