diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 5ceb1ce2a2..c61f8262f7 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -40,6 +40,8 @@ import time import functools import inspect +import copy + from StringIO import StringIO from urlparse import urlparse @@ -135,7 +137,17 @@ def _append_checks(check_name): checks = getattr(meta, attr_name) if checks: for phase_name, funcs in checks.items(): - phase = attr_dict.get(PackageMeta.phase_fmt.format(phase_name)) + try: + # Search for the phase in the attribute dictionary + phase = attr_dict[PackageMeta.phase_fmt.format(phase_name)] + except KeyError: + # If it is not there it's in the bases + # and we added a check. We need to copy + # and extend + for base in bases: + phase = getattr(base, PackageMeta.phase_fmt.format(phase_name), None) + attr_dict[PackageMeta.phase_fmt.format(phase_name)] = copy.deepcopy(phase) + phase = attr_dict[PackageMeta.phase_fmt.format(phase_name)] getattr(phase, check_name).extend(funcs) # Clear the attribute for the next class setattr(meta, attr_name, {}) @@ -511,6 +523,8 @@ def __init__(self, spec): if self.is_extension: spack.repo.get(self.extendee_spec)._check_extendable() + self.extra_args = {} + @property def package_dir(self): """Return the directory where the package.py file lives.""" diff --git a/var/spack/repos/builtin/packages/hdf5/package.py b/var/spack/repos/builtin/packages/hdf5/package.py index 51a5823aa5..54c74901f0 100644 --- a/var/spack/repos/builtin/packages/hdf5/package.py +++ b/var/spack/repos/builtin/packages/hdf5/package.py @@ -27,7 +27,7 @@ import shutil -class Hdf5(Package): +class Hdf5(AutotoolsPackage): """HDF5 is a data model, library, and file format for storing and managing data. It supports an unlimited variety of datatypes, and is designed for flexible and efficient I/O and for high volume and complex data. @@ -58,13 +58,15 @@ class Hdf5(Package): depends_on("szip", when='+szip') depends_on("zlib") - def validate(self, spec): + @AutotoolsPackage.precondition('configure') + def validate(self): """ Checks if incompatible variants have been activated at the same time :param spec: spec of the package :raises RuntimeError: in case of inconsistencies """ + spec = self.spec if '+fortran' in spec and not self.compiler.fc: msg = 'cannot build a fortran variant without a fortran compiler' raise RuntimeError(msg) @@ -73,8 +75,8 @@ def validate(self, spec): msg = 'cannot use variant +threadsafe with either +cxx or +fortran' raise RuntimeError(msg) - def install(self, spec, prefix): - self.validate(spec) + def configure_args(self): + spec = self.spec # Handle compilation after spec validation extra_args = [] @@ -137,16 +139,19 @@ def install(self, spec, prefix): '--disable-hl', ]) - configure( - "--prefix=%s" % prefix, - "--with-zlib=%s" % spec['zlib'].prefix, - *extra_args) - make() - make("install") - self.check_install(spec) + return ["--with-zlib=%s" % spec['zlib'].prefix] + extra_args + #configure( + # "--prefix=%s" % prefix, + # "--with-zlib=%s" % spec['zlib'].prefix, + # *extra_args) + #make() + #make("install") + #self.check_install(spec) - def check_install(self, spec): + @AutotoolsPackage.sanity_check('install') + def check_install(self): "Build and run a small program to test the installed HDF5 library" + spec = self.spec print "Checking HDF5 installation..." checkdir = "spack-check" with working_dir(checkdir, create=True): diff --git a/var/spack/repos/builtin/packages/lzo/package.py b/var/spack/repos/builtin/packages/lzo/package.py index 0961bbb58c..edf6dc1d4c 100644 --- a/var/spack/repos/builtin/packages/lzo/package.py +++ b/var/spack/repos/builtin/packages/lzo/package.py @@ -25,7 +25,7 @@ from spack import * -class Lzo(Package): +class Lzo(AutotoolsPackage): """Real-time data compression library""" homepage = 'https://www.oberhumer.com/opensource/lzo/' @@ -37,13 +37,13 @@ class Lzo(Package): version('2.06', '95380bd4081f85ef08c5209f4107e9f8') version('2.05', 'c67cda5fa191bab761c7cb06fe091e36') - def install(self, spec, prefix): - configure_args = [ - '--prefix={0}'.format(prefix), + def configure_args(self): + return [ '--disable-dependency-tracking', '--enable-shared' ] - configure(*configure_args) - make() - make('check') - make('install') + + @AutotoolsPackage.sanity_check('build') + def check(self): + if self.extra_args.get('build-tests', False): + make('check')