package : added environment_modifications

This commit is contained in:
alalazo 2016-03-15 13:36:41 +01:00
parent bcea1df01c
commit c85888eb57
8 changed files with 58 additions and 40 deletions

View File

@ -178,6 +178,7 @@ def set_build_environment_variables(pkg):
return env
def set_module_variables_for_package(pkg, m):
"""Populate the module scope of install() with some useful functions.
This makes things easier for package writers.
@ -272,7 +273,6 @@ def setup_package(pkg):
env = EnvironmentModifications()
env.extend(set_compiler_environment_variables(pkg))
env.extend(set_build_environment_variables(pkg))
apply_environment_modifications(env)
# If a user makes their own package repo, e.g.
# spack.repos.mystuff.libelf.Libelf, and they inherit from
# an existing class like spack.repos.original.libelf.Libelf,
@ -284,8 +284,9 @@ def setup_package(pkg):
# Allow dependencies to set up environment as well.
for dep_spec in pkg.spec.traverse(root=False):
dep_spec.package.setup_dependent_environment(
pkg.module, dep_spec, pkg.spec)
env.extend(dep_spec.package.environment_modifications(pkg.module, dep_spec, pkg.spec))
dep_spec.package.setup_dependent_environment(pkg.module, dep_spec, pkg.spec)
apply_environment_modifications(env)
def fork(pkg, function):

View File

@ -63,6 +63,7 @@
import spack.url
import spack.util.web
import spack.fetch_strategy as fs
from spack.environment import EnvironmentModifications
from spack.version import *
from spack.stage import Stage, ResourceStage, StageComposite
from spack.util.compression import allowed_archive, extension
@ -983,6 +984,9 @@ def module(self):
fromlist=[self.__class__.__name__])
def environment_modifications(self, module, spec, dependent_spec):
return EnvironmentModifications()
def setup_dependent_environment(self, module, spec, dependent_spec):
"""Called before the install() method of dependents.

View File

@ -46,14 +46,18 @@ class Mpich(Package):
provides('mpi@:3.0', when='@3:')
provides('mpi@:1.3', when='@1:')
def environment_modifications(self, module, spec, dependent_spec):
env = super(Mpich, self).environment_modifications(module, spec, dependent_spec)
env.set_env('MPICH_CC', os.environ['CC'])
env.set_env('MPICH_CXX', os.environ['CXX'])
env.set_env('MPICH_F77', os.environ['F77'])
env.set_env('MPICH_F90', os.environ['FC'])
env.set_env('MPICH_FC', os.environ['FC'])
return env
def setup_dependent_environment(self, module, spec, dep_spec):
"""For dependencies, make mpicc's use spack wrapper."""
os.environ['MPICH_CC'] = os.environ['CC']
os.environ['MPICH_CXX'] = os.environ['CXX']
os.environ['MPICH_F77'] = os.environ['F77']
os.environ['MPICH_F90'] = os.environ['FC']
os.environ['MPICH_FC'] = os.environ['FC']
# FIXME : is this necessary ? Shouldn't this be part of a contract with MPI providers?
module.mpicc = join_path(self.prefix.bin, 'mpicc')
def install(self, spec, prefix):

View File

@ -46,5 +46,4 @@ def setup_dependent_environment(self, module, spec, dependent_spec):
spec['scalapack'].fc_link = '-L%s -lscalapack' % spec['scalapack'].prefix.lib
spec['scalapack'].cc_link = spec['scalapack'].fc_link
spec['scalapack'].libraries = [join_path(spec['scalapack'].prefix.lib,
'libscalapack%s' % lib_suffix)]
spec['scalapack'].libraries = [join_path(spec['scalapack'].prefix.lib, 'libscalapack%s' % lib_suffix)]

View File

@ -41,12 +41,14 @@ class Openmpi(Package):
def url_for_version(self, version):
return "http://www.open-mpi.org/software/ompi/v%s/downloads/openmpi-%s.tar.bz2" % (version.up_to(2), version)
def setup_dependent_environment(self, module, spec, dep_spec):
"""For dependencies, make mpicc's use spack wrapper."""
os.environ['OMPI_CC'] = 'cc'
os.environ['OMPI_CXX'] = 'c++'
os.environ['OMPI_FC'] = 'f90'
os.environ['OMPI_F77'] = 'f77'
def environment_modifications(self, module, spec, dependent_spec):
env = super(Openmpi, self).environment_modifications(module, spec, dependent_spec)
# FIXME : the compilers should point to the current wrappers, not to generic cc etc.
env.set_env('OMPI_CC', 'cc')
env.set_env('OMPI_CXX', 'c++')
env.set_env('OMPI_FC', 'f90')
env.set_env('OMPI_F77', 'f77')
return env
def install(self, spec, prefix):
config_args = ["--prefix=%s" % prefix,

View File

@ -90,6 +90,17 @@ def site_packages_dir(self):
return os.path.join(self.python_lib_dir, 'site-packages')
def environment_modifications(self, module, spec, dependent_spec):
env = super(Python, self).environment_modifications(module, spec, dependent_spec)
# Set PYTHONPATH to include site-packages dir for the
# extension and any other python extensions it depends on.
python_paths = []
for d in ext_spec.traverse():
if d.package.extends(self.spec):
python_paths.append(os.path.join(d.prefix, self.site_packages_dir))
env.set_env['PYTHONPATH'] = ':'.join(python_paths)
def setup_dependent_environment(self, module, spec, ext_spec):
"""Called before python modules' install() methods.
@ -111,15 +122,6 @@ def setup_dependent_environment(self, module, spec, ext_spec):
# Make the site packages directory if it does not exist already.
mkdirp(module.site_packages_dir)
# Set PYTHONPATH to include site-packages dir for the
# extension and any other python extensions it depends on.
python_paths = []
for d in ext_spec.traverse():
if d.package.extends(self.spec):
python_paths.append(os.path.join(d.prefix, self.site_packages_dir))
os.environ['PYTHONPATH'] = ':'.join(python_paths)
# ========================================================================
# Handle specifics of activating and deactivating python modules.
# ========================================================================

View File

@ -52,11 +52,13 @@ class Qt(Package):
depends_on("mesa", when='@4:+mesa')
depends_on("libxcb")
def setup_dependent_environment(self, module, spec, dep_spec):
"""Dependencies of Qt find it using the QTDIR environment variable."""
os.environ['QTDIR'] = self.prefix
def environment_modifications(self, module, spec, dep_spec):
"""
Dependencies of Qt find it using the QTDIR environment variable
"""
env = super(Qt, self).environment_modifications(module, spec, dep_spec)
env.set_env['QTDIR'] = self.prefix
return env
def patch(self):
if self.spec.satisfies('@4'):

View File

@ -15,10 +15,21 @@ class Ruby(Package):
def install(self, spec, prefix):
configure("--prefix=%s" % prefix)
make()
make("install")
def environment_modifications(self, module, spec, ext_spec):
env = super(Ruby, self).environment_modifications(module, spec, ext_spec)
# Set GEM_PATH to include dependent gem directories
ruby_paths = []
for d in ext_spec.traverse():
if d.package.extends(self.spec):
ruby_paths.append(d.prefix)
env.set_env('GEM_PATH', concatenate_paths(ruby_paths))
# The actual installation path for this gem
env.set_env('GEM_HOME', ext_spec.prefix)
return env
def setup_dependent_environment(self, module, spec, ext_spec):
"""Called before ruby modules' install() methods. Sets GEM_HOME
and GEM_PATH to values appropriate for the package being built.
@ -31,11 +42,4 @@ def setup_dependent_environment(self, module, spec, ext_spec):
module.ruby = Executable(join_path(spec.prefix.bin, 'ruby'))
module.gem = Executable(join_path(spec.prefix.bin, 'gem'))
# Set GEM_PATH to include dependent gem directories
ruby_paths = []
for d in ext_spec.traverse():
if d.package.extends(self.spec):
ruby_paths.append(d.prefix)
os.environ['GEM_PATH'] = ':'.join(ruby_paths)
# The actual installation path for this gem
os.environ['GEM_HOME'] = ext_spec.prefix