package : split environment_modifications into setup_environment and setup_dependent_environment.

package : renamed `module_modifications` to `modify_module` for consistency
This commit is contained in:
alalazo 2016-03-17 15:11:39 +01:00
parent 9cdd79e33f
commit f0f0663d1b
9 changed files with 49 additions and 60 deletions

View File

@ -284,8 +284,8 @@ def setup_package(pkg):
# Allow dependencies to set up environment as well.
for dependency_spec in pkg.spec.traverse(root=False):
dependency_spec.package.module_modifications(pkg.module, dependency_spec, pkg.spec)
env.extend(dependency_spec.package.environment_modifications(pkg.spec))
dependency_spec.package.modify_module(pkg.module, dependency_spec, pkg.spec)
dependency_spec.package.setup_dependent_environment(env, pkg.spec)
# TODO : implement validation
#validate(env)
env.apply_modifications()

View File

@ -162,9 +162,8 @@ def write(self):
# Environment modifications guessed by inspecting the installation prefix
env = inspect_path(self.spec.prefix)
# Package-specific environment modifications
# FIXME : decide how to distinguish between calls done in the installation and elsewhere
env.extend(self.spec.package.environment_modifications(None))
# site_specific = ...`
self.spec.package.setup_environment(env)
# TODO : implement site-specific modifications and filters
if not env:
return

View File

@ -977,7 +977,7 @@ def module(self):
fromlist=[self.__class__.__name__])
def environment_modifications(self, dependent_spec):
def setup_environment(self, env):
"""
Called before the install() method of dependents.
@ -998,9 +998,12 @@ def environment_modifications(self, dependent_spec):
Returns:
instance of environment modifications
"""
return EnvironmentModifications()
pass
def module_modifications(self, module, spec, dependent_spec):
def setup_dependent_environment(self, env, dependent_spec):
self.setup_environment(env)
def modify_module(self, module, spec, dependent_spec):
"""
Called before the install() method of dependents.

View File

@ -47,30 +47,21 @@ class Mpich(Package):
provides('mpi@:3.0', when='@3:')
provides('mpi@:1.3', when='@1:')
def environment_modifications(self, dependent_spec):
env = super(Mpich, self).environment_modifications(dependent_spec)
def setup_environment(self, env):
env.set_env('MPICH_CC', self.compiler.cc)
env.set_env('MPICH_CXX', self.compiler.cxx)
env.set_env('MPICH_F77', self.compiler.f77)
env.set_env('MPICH_F90', self.compiler.fc)
env.set_env('MPICH_FC', self.compiler.fc)
if dependent_spec is None:
# We are not using compiler wrappers
cc = self.compiler.cc
cxx = self.compiler.cxx
f77 = self.compiler.f77
f90 = fc = self.compiler.fc
else:
# Spack compiler wrappers
cc = os.environ['CC']
cxx = os.environ['CXX']
f77 = os.environ['F77']
f90 = fc = os.environ['FC']
def setup_dependent_environment(self, env, dependent_spec):
env.set_env('MPICH_CC', spack_cc)
env.set_env('MPICH_CXX', spack_cxx)
env.set_env('MPICH_F77', spack_f77)
env.set_env('MPICH_F90', spack_f90)
env.set_env('MPICH_FC', spack_fc)
env.set_env('MPICH_CC', cc)
env.set_env('MPICH_CXX', cxx)
env.set_env('MPICH_F77', f77)
env.set_env('MPICH_F90', f90)
env.set_env('MPICH_FC', fc)
return env
def module_modifications(self, module, spec, dep_spec):
def modify_module(self, module, spec, dep_spec):
"""For dependencies, make mpicc's use spack wrapper."""
# FIXME : is this necessary ? Shouldn't this be part of a contract with MPI providers?
module.mpicc = join_path(self.prefix.bin, 'mpicc')

View File

@ -40,7 +40,7 @@ def install(self, spec, prefix):
make()
make("install")
def module_modifications(self, module, spec, dependent_spec):
def modify_module(self, module, spec, dependent_spec):
# TODO treat OS that are not Linux...
lib_suffix = '.so' if '+shared' in spec['scalapack'] else '.a'

View File

@ -41,14 +41,17 @@ 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 environment_modifications(self, dependent_spec):
env = super(Openmpi, self).environment_modifications(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 setup_environment(self, env):
env.set_env('OMPI_CC', self.compiler.cc)
env.set_env('OMPI_CXX', self.compiler.cxx)
env.set_env('OMPI_FC', self.compiler.fc)
env.set_env('OMPI_F77', self.compiler.f77)
def setup_dependent_environment(self, env, dependent_spec):
env.set_env('OMPI_CC', spack_cc)
env.set_env('OMPI_CXX', spack_cxx)
env.set_env('OMPI_FC', spack_fc)
env.set_env('OMPI_F77', spack_f77)
def install(self, spec, prefix):
config_args = ["--prefix=%s" % prefix,

View File

@ -89,24 +89,21 @@ def python_include_dir(self):
def site_packages_dir(self):
return os.path.join(self.python_lib_dir, 'site-packages')
def environment_modifications(self, extension_spec):
env = super(Python, self).environment_modifications(extension_spec)
if extension_spec is not None:
# Set PYTHONPATH to include site-packages dir for the
# extension and any other python extensions it depends on.
python_paths = []
for d in extension_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)
return env
def setup_dependent_environment(self, env, extension_spec):
# Set PYTHONPATH to include site-packages dir for the extension and any other python extensions it depends on.
python_paths = []
for d in extension_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 module_modifications(self, module, spec, ext_spec):
"""Called before python modules' install() methods.
def modify_module(self, module, spec, ext_spec):
"""
Called before python modules' install() methods.
In most cases, extensions will only need to have one line::
python('setup.py', 'install', '--prefix=%s' % prefix)
python('setup.py', 'install', '--prefix=%s' % prefix)
"""
# Python extension builds can have a global python executable function
if self.version >= Version("3.0.0") and self.version < Version("4.0.0"):

View File

@ -55,10 +55,8 @@ class Qt(Package):
depends_on("mesa", when='@4:+mesa')
depends_on("libxcb")
def environment_modifications(self, dependent_spec):
env = super(Qt, self).environment_modifications(dependent_spec)
def setup_environment(self, env):
env.set_env['QTDIR'] = self.prefix
return env
def patch(self):
if self.spec.satisfies('@4'):

View File

@ -17,8 +17,7 @@ def install(self, spec, prefix):
make()
make("install")
def environment_modifications(self, extension_spec):
env = super(Ruby, self).environment_modifications(extension_spec)
def setup_dependent_environment(self, env, extension_spec):
# Set GEM_PATH to include dependent gem directories
ruby_paths = []
for d in extension_spec.traverse():
@ -27,9 +26,8 @@ def environment_modifications(self, extension_spec):
env.set_env('GEM_PATH', concatenate_paths(ruby_paths))
# The actual installation path for this gem
env.set_env('GEM_HOME', extension_spec.prefix)
return env
def module_modifications(self, module, spec, ext_spec):
def modify_module(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.