IntelPackage: setup_env -> setup_build_env (#13888)

This commit is contained in:
Adam J. Stewart 2019-11-26 16:48:32 -06:00 committed by GitHub
parent f6781d65f0
commit ad1ad83664
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 49 deletions

View File

@ -89,7 +89,7 @@ class IntelPackage(PackageBase):
2. :py:meth:`~.IntelPackage.install` 2. :py:meth:`~.IntelPackage.install`
They both have sensible defaults and for many packages the 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. to set the appropriate environment variables.
""" """
#: Phases of an Intel package #: Phases of an Intel package
@ -455,9 +455,7 @@ def normalize_suite_dir(self, suite_dir_name, version_globs=['*.*.*']):
break break
if not matching_dirs: if not matching_dirs:
# No match -- this *will* happen during pre-build call to # No match -- return a sensible value anyway.
# setup_environment() when the destination dir is still empty.
# Return a sensible value anyway.
d = unversioned_dirname d = unversioned_dirname
debug_print(d) debug_print(d)
@ -889,15 +887,15 @@ def mpi_compiler_wrappers(self):
# debug_print("wrapper_vars =", wrapper_vars) # debug_print("wrapper_vars =", wrapper_vars)
return wrapper_vars return wrapper_vars
def mpi_setup_dependent_environment( def mpi_setup_dependent_build_environment(
self, spack_env, run_env, dependent_spec, compilers_of_client={}): self, env, dependent_spec, compilers_of_client={}):
'''Unified back-end for setup_dependent_environment() of Intel packages '''Unified back-end for setup_dependent_build_environment() of
that provide 'mpi'. Intel packages that provide 'mpi'.
Parameters: Parameters:
spack_env, run_env, dependent_spec: same as in env, dependent_spec: same as in
setup_dependent_environment(). setup_dependent_build_environment().
compilers_of_client (dict): Conveys spack_cc, spack_cxx, etc., compilers_of_client (dict): Conveys spack_cc, spack_cxx, etc.,
from the scope of dependent packages; constructed in caller. 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 # Ensure that the directory containing the compiler wrappers is in the
# PATH. Spack packages add `prefix.bin` to their dependents' paths, # PATH. Spack packages add `prefix.bin` to their dependents' paths,
# but because of the intel directory hierarchy that is insufficient. # 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(): for key, value in wrapper_vars.items():
spack_env.set(key, value) env.set(key, value)
debug_print("adding to spack_env:", wrapper_vars) debug_print("adding to spack_env:", wrapper_vars)
@ -995,7 +993,7 @@ def libs(self):
debug_print(result) debug_print(result)
return 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. """Adds environment variables to the generated module file.
These environment variables come from running: 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 $ source parallel_studio_xe_2017/bin/psxevars.sh intel64
[and likewise for MKL, MPI, and other components] [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 f = self.file_to_source
if not f or not os.path.isfile(f):
return
tty.debug("sourcing " + f) tty.debug("sourcing " + f)
# All Intel packages expect at least the architecture as argument. # 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': # if sys.platform == 'darwin':
# args = () # 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): def setup_dependent_build_environment(self, 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.
#
# NB: This function is overwritten by 'mpi' provider packages: # NB: This function is overwritten by 'mpi' provider packages:
# #
# var/spack/repos/builtin/packages/intel-mpi/package.py # 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. # dictionary kwarg compilers_of_client{} present and populated.
# Handle everything in a callback version. # 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( def _setup_dependent_env_callback(
self, spack_env, run_env, dependent_spec, compilers_of_client={}): self, env, dependent_spec, compilers_of_client={}):
# Expected to be called from a client's setup_dependent_environment(), # Expected to be called from a client's
# setup_dependent_build_environment(),
# with args extended to convey the client's compilers as needed. # with args extended to convey the client's compilers as needed.
if '+mkl' in self.spec or self.provides('mkl'): if '+mkl' in self.spec or self.provides('mkl'):
# Spack's env philosophy demands that we replicate some of the # Spack's env philosophy demands that we replicate some of the
# settings normally handled by file_to_source ... # 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 # not called as a matter of course upon entering the current
# function? (guarding against multiple calls notwithstanding) # 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_COMPILER_EXTRA_RPATHS': self.component_lib_dir('mkl'),
} }
spack_env.set('MKLROOT', env_mods['MKLROOT']) env.set('MKLROOT', env_mods['MKLROOT'])
spack_env.append_path('SPACK_COMPILER_EXTRA_RPATHS', env.append_path('SPACK_COMPILER_EXTRA_RPATHS',
env_mods['SPACK_COMPILER_EXTRA_RPATHS']) env_mods['SPACK_COMPILER_EXTRA_RPATHS'])
debug_print("adding/modifying spack_env:", env_mods) debug_print("adding/modifying spack_env:", env_mods)
if '+mpi' in self.spec or self.provides('mpi'): if '+mpi' in self.spec or self.provides('mpi'):
if compilers_of_client: if compilers_of_client:
self.mpi_setup_dependent_environment( self.mpi_setup_dependent_build_environment(
spack_env, run_env, dependent_spec, compilers_of_client) env, dependent_spec, compilers_of_client)
# We could forego this nonce function and inline its code here, # We could forego this nonce function and inline its code here,
# but (a) it sisters mpi_compiler_wrappers() [needed twice] # but (a) it sisters mpi_compiler_wrappers() [needed twice]
# which performs dizzyingly similar but necessarily different # which performs dizzyingly similar but necessarily different

View File

@ -43,7 +43,7 @@ class IntelMpi(IntelPackage):
provides('mpi') 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. # Handle in callback, conveying client's compilers in additional arg.
# CAUTION - DUP code in: # CAUTION - DUP code in:
# ../intel-mpi/package.py # ../intel-mpi/package.py

View File

@ -199,7 +199,7 @@ class IntelParallelStudio(IntelPackage):
conflicts('auto_dispatch=SSE3', 'platform=darwin target=x86_64:', conflicts('auto_dispatch=SSE3', 'platform=darwin target=x86_64:',
msg='SSE3 is not supported on MacOS 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. # Handle in callback, conveying client's compilers in additional arg.
# CAUTION - DUP code in: # CAUTION - DUP code in:
# ../intel-mpi/package.py # ../intel-mpi/package.py