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. # Allow dependencies to set up environment as well.
for dependency_spec in pkg.spec.traverse(root=False): for dependency_spec in pkg.spec.traverse(root=False):
dependency_spec.package.module_modifications(pkg.module, dependency_spec, pkg.spec) dependency_spec.package.modify_module(pkg.module, dependency_spec, pkg.spec)
env.extend(dependency_spec.package.environment_modifications(pkg.spec)) dependency_spec.package.setup_dependent_environment(env, pkg.spec)
# TODO : implement validation # TODO : implement validation
#validate(env) #validate(env)
env.apply_modifications() env.apply_modifications()

View File

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

View File

@ -977,7 +977,7 @@ def module(self):
fromlist=[self.__class__.__name__]) fromlist=[self.__class__.__name__])
def environment_modifications(self, dependent_spec): def setup_environment(self, env):
""" """
Called before the install() method of dependents. Called before the install() method of dependents.
@ -998,9 +998,12 @@ def environment_modifications(self, dependent_spec):
Returns: Returns:
instance of environment modifications 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. Called before the install() method of dependents.

View File

@ -47,30 +47,21 @@ class Mpich(Package):
provides('mpi@:3.0', when='@3:') provides('mpi@:3.0', when='@3:')
provides('mpi@:1.3', when='@1:') provides('mpi@:1.3', when='@1:')
def environment_modifications(self, dependent_spec): def setup_environment(self, env):
env = super(Mpich, self).environment_modifications(dependent_spec) 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: def setup_dependent_environment(self, env, dependent_spec):
# We are not using compiler wrappers env.set_env('MPICH_CC', spack_cc)
cc = self.compiler.cc env.set_env('MPICH_CXX', spack_cxx)
cxx = self.compiler.cxx env.set_env('MPICH_F77', spack_f77)
f77 = self.compiler.f77 env.set_env('MPICH_F90', spack_f90)
f90 = fc = self.compiler.fc env.set_env('MPICH_FC', spack_fc)
else:
# Spack compiler wrappers
cc = os.environ['CC']
cxx = os.environ['CXX']
f77 = os.environ['F77']
f90 = fc = os.environ['FC']
env.set_env('MPICH_CC', cc) def modify_module(self, module, spec, dep_spec):
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):
"""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')

View File

@ -40,7 +40,7 @@ def install(self, spec, prefix):
make() make()
make("install") 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... # TODO treat OS that are not Linux...
lib_suffix = '.so' if '+shared' in spec['scalapack'] else '.a' 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): 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) 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): def setup_environment(self, env):
env = super(Openmpi, self).environment_modifications(dependent_spec) env.set_env('OMPI_CC', self.compiler.cc)
# FIXME : the compilers should point to the current wrappers, not to generic cc etc. env.set_env('OMPI_CXX', self.compiler.cxx)
env.set_env('OMPI_CC', 'cc') env.set_env('OMPI_FC', self.compiler.fc)
env.set_env('OMPI_CXX', 'c++') env.set_env('OMPI_F77', self.compiler.f77)
env.set_env('OMPI_FC', 'f90')
env.set_env('OMPI_F77', 'f77') def setup_dependent_environment(self, env, dependent_spec):
return env 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): def install(self, spec, prefix):
config_args = ["--prefix=%s" % prefix, config_args = ["--prefix=%s" % prefix,

View File

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

View File

@ -17,8 +17,7 @@ def install(self, spec, prefix):
make() make()
make("install") make("install")
def environment_modifications(self, extension_spec): def setup_dependent_environment(self, env, extension_spec):
env = super(Ruby, self).environment_modifications(extension_spec)
# Set GEM_PATH to include dependent gem directories # Set GEM_PATH to include dependent gem directories
ruby_paths = [] ruby_paths = []
for d in extension_spec.traverse(): 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)) env.set_env('GEM_PATH', concatenate_paths(ruby_paths))
# The actual installation path for this gem # The actual installation path for this gem
env.set_env('GEM_HOME', extension_spec.prefix) 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 """Called before ruby modules' install() methods. Sets GEM_HOME
and GEM_PATH to values appropriate for the package being built. and GEM_PATH to values appropriate for the package being built.