Change from PR #552: rename setup_dependent_python_module -> setup_dependent_package
- Fixed in package.py - Fixed wrong prototypes in packages that use it. - Fixed build_environment to set module variables properly - added hacky fix to ensure spec/package consistency in build processes. - Need to think about defensive spec copy done by `Repo.get`. May be time to think about an immutable spec implementation.
This commit is contained in:
parent
3f32dd767e
commit
a26992ef55
@ -225,7 +225,7 @@ def set_module_variables_for_package(pkg, module):
|
|||||||
m.spack_cc = join_path(link_dir, pkg.compiler.link_paths['cc'])
|
m.spack_cc = join_path(link_dir, pkg.compiler.link_paths['cc'])
|
||||||
m.spack_cxx = join_path(link_dir, pkg.compiler.link_paths['cxx'])
|
m.spack_cxx = join_path(link_dir, pkg.compiler.link_paths['cxx'])
|
||||||
m.spack_f77 = join_path(link_dir, pkg.compiler.link_paths['f77'])
|
m.spack_f77 = join_path(link_dir, pkg.compiler.link_paths['f77'])
|
||||||
m.spack_f90 = join_path(link_dir, pkg.compiler.link_paths['fc'])
|
m.spack_fc = join_path(link_dir, pkg.compiler.link_paths['fc'])
|
||||||
|
|
||||||
# Emulate some shell commands for convenience
|
# Emulate some shell commands for convenience
|
||||||
m.pwd = os.getcwd
|
m.pwd = os.getcwd
|
||||||
@ -270,32 +270,56 @@ def parent_class_modules(cls):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def setup_package(pkg):
|
def setup_module_variables_for_dag(pkg):
|
||||||
"""Execute all environment setup routines."""
|
"""Set module-scope variables for all packages in the DAG."""
|
||||||
spack_env = EnvironmentModifications()
|
for spec in pkg.spec.traverse(order='post'):
|
||||||
run_env = EnvironmentModifications()
|
|
||||||
|
|
||||||
set_compiler_environment_variables(pkg, spack_env)
|
|
||||||
set_build_environment_variables(pkg, spack_env)
|
|
||||||
|
|
||||||
# If a user makes their own package repo, e.g.
|
# If a user makes their own package repo, e.g.
|
||||||
# spack.repos.mystuff.libelf.Libelf, and they inherit from
|
# spack.repos.mystuff.libelf.Libelf, and they inherit from
|
||||||
# an existing class like spack.repos.original.libelf.Libelf,
|
# an existing class like spack.repos.original.libelf.Libelf,
|
||||||
# then set the module variables for both classes so the
|
# then set the module variables for both classes so the
|
||||||
# parent class can still use them if it gets called.
|
# parent class can still use them if it gets called.
|
||||||
modules = parent_class_modules(pkg.__class__)
|
spkg = spec.package
|
||||||
|
modules = parent_class_modules(spkg.__class__)
|
||||||
for mod in modules:
|
for mod in modules:
|
||||||
set_module_variables_for_package(pkg, mod)
|
set_module_variables_for_package(spkg, mod)
|
||||||
|
set_module_variables_for_package(spkg, spkg.module)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_package(pkg):
|
||||||
|
"""Execute all environment setup routines."""
|
||||||
|
spack_env = EnvironmentModifications()
|
||||||
|
run_env = EnvironmentModifications()
|
||||||
|
|
||||||
|
# Before proceeding, ensure that specs and packages are consistent
|
||||||
|
#
|
||||||
|
# This is a confusing behavior due to how packages are
|
||||||
|
# constructed. `setup_dependent_package` may set attributes on
|
||||||
|
# specs in the DAG for use by other packages' install
|
||||||
|
# method. However, spec.package will look up a package via
|
||||||
|
# spack.repo, which defensively copies specs into packages. This
|
||||||
|
# code ensures that all packages in the DAG have pieces of the
|
||||||
|
# same spec object at build time.
|
||||||
|
#
|
||||||
|
# This is safe for the build process, b/c the build process is a
|
||||||
|
# throwaway environment, but it is kind of dirty.
|
||||||
|
#
|
||||||
|
# TODO: Think about how to avoid this fix and do something cleaner.
|
||||||
|
for s in pkg.spec.traverse(): s.package.spec = s
|
||||||
|
|
||||||
|
set_compiler_environment_variables(pkg, spack_env)
|
||||||
|
set_build_environment_variables(pkg, spack_env)
|
||||||
|
setup_module_variables_for_dag(pkg)
|
||||||
|
|
||||||
# Allow dependencies to modify the module
|
# Allow dependencies to modify the module
|
||||||
for dependency_spec in pkg.spec.traverse(root=False):
|
spec = pkg.spec
|
||||||
|
for dependency_spec in spec.traverse(root=False):
|
||||||
dpkg = dependency_spec.package
|
dpkg = dependency_spec.package
|
||||||
dpkg.setup_dependent_python_module(pkg.module, pkg.spec)
|
dpkg.setup_dependent_package(pkg.module, spec)
|
||||||
|
|
||||||
# Allow dependencies to set up environment as well
|
# Allow dependencies to set up environment as well
|
||||||
for dependency_spec in pkg.spec.traverse(root=False):
|
for dependency_spec in spec.traverse(root=False):
|
||||||
dpkg = dependency_spec.package
|
dpkg = dependency_spec.package
|
||||||
dpkg.setup_dependent_environment(spack_env, run_env, pkg.spec)
|
dpkg.setup_dependent_environment(spack_env, run_env, spec)
|
||||||
|
|
||||||
# Allow the package to apply some settings.
|
# Allow the package to apply some settings.
|
||||||
pkg.setup_environment(spack_env, run_env)
|
pkg.setup_environment(spack_env, run_env)
|
||||||
|
@ -1075,7 +1075,7 @@ def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
|
|||||||
self.setup_environment(spack_env, run_env)
|
self.setup_environment(spack_env, run_env)
|
||||||
|
|
||||||
|
|
||||||
def setup_dependent_python_module(self, module, dependent_spec):
|
def setup_dependent_package(self, module, dependent_spec):
|
||||||
"""Set up Python module-scope variables for dependent packages.
|
"""Set up Python module-scope variables for dependent packages.
|
||||||
|
|
||||||
Called before the install() method of dependents.
|
Called before the install() method of dependents.
|
||||||
|
@ -54,7 +54,7 @@ def setup_dependent_environment(self, env, dependent_spec):
|
|||||||
env.set('MPICH_F90', spack_f90)
|
env.set('MPICH_F90', spack_f90)
|
||||||
env.set('MPICH_FC', spack_fc)
|
env.set('MPICH_FC', spack_fc)
|
||||||
|
|
||||||
def setup_dependent_python_module(self, module, spec, dep_spec):
|
def setup_dependent_package(self, module, dep_spec):
|
||||||
"""For dependencies, make mpicc's use spack wrapper."""
|
"""For dependencies, make mpicc's use spack wrapper."""
|
||||||
# FIXME : is this necessary ? Shouldn't this be part of a contract with MPI providers?
|
# FIXME : is this necessary ? Shouldn't this be part of a contract with MPI providers?
|
||||||
module.mpicc = join_path(self.prefix.bin, 'mpicc')
|
module.mpicc = join_path(self.prefix.bin, 'mpicc')
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from spack import *
|
from spack import *
|
||||||
|
import sys
|
||||||
|
|
||||||
class NetlibScalapack(Package):
|
class NetlibScalapack(Package):
|
||||||
"""ScaLAPACK is a library of high-performance linear algebra routines for parallel distributed memory machines"""
|
"""ScaLAPACK is a library of high-performance linear algebra routines for parallel distributed memory machines"""
|
||||||
@ -40,10 +41,11 @@ def install(self, spec, prefix):
|
|||||||
make()
|
make()
|
||||||
make("install")
|
make("install")
|
||||||
|
|
||||||
def setup_dependent_python_module(self, module, spec, dependent_spec):
|
def setup_dependent_package(self, module, dependent_spec):
|
||||||
|
spec = self.spec
|
||||||
lib_dsuffix = '.dylib' if sys.platform == 'darwin' else '.so'
|
lib_dsuffix = '.dylib' if sys.platform == 'darwin' else '.so'
|
||||||
lib_suffix = lib_dsuffix if '+shared' in spec['scalapack'] else '.a'
|
lib_suffix = lib_dsuffix if '+shared' in spec else '.a'
|
||||||
|
|
||||||
spec['scalapack'].fc_link = '-L%s -lscalapack' % spec['scalapack'].prefix.lib
|
spec.fc_link = '-L%s -lscalapack' % spec.prefix.lib
|
||||||
spec['scalapack'].cc_link = spec['scalapack'].fc_link
|
spec.cc_link = spec.fc_link
|
||||||
spec['scalapack'].libraries = [join_path(spec['scalapack'].prefix.lib, 'libscalapack%s' % lib_suffix)]
|
spec.libraries = [join_path(spec.prefix.lib, 'libscalapack%s' % lib_suffix)]
|
||||||
|
Loading…
Reference in New Issue
Block a user