package.py : extra arguments, fixed inheritance issue
- added attribute to hold extra arguments in PackageBase instances - fixed registration from within packages - examples : hdf5, lzo
This commit is contained in:
		| @@ -40,6 +40,8 @@ | |||||||
| import time | import time | ||||||
| import functools | import functools | ||||||
| import inspect | import inspect | ||||||
|  | import copy | ||||||
|  |  | ||||||
| from StringIO import StringIO | from StringIO import StringIO | ||||||
| from urlparse import urlparse | from urlparse import urlparse | ||||||
|  |  | ||||||
| @@ -135,7 +137,17 @@ def _append_checks(check_name): | |||||||
|             checks = getattr(meta, attr_name) |             checks = getattr(meta, attr_name) | ||||||
|             if checks: |             if checks: | ||||||
|                 for phase_name, funcs in checks.items(): |                 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) |                     getattr(phase, check_name).extend(funcs) | ||||||
|                 # Clear the attribute for the next class |                 # Clear the attribute for the next class | ||||||
|                 setattr(meta, attr_name, {}) |                 setattr(meta, attr_name, {}) | ||||||
| @@ -511,6 +523,8 @@ def __init__(self, spec): | |||||||
|         if self.is_extension: |         if self.is_extension: | ||||||
|             spack.repo.get(self.extendee_spec)._check_extendable() |             spack.repo.get(self.extendee_spec)._check_extendable() | ||||||
|  |  | ||||||
|  |         self.extra_args = {} | ||||||
|  |  | ||||||
|     @property |     @property | ||||||
|     def package_dir(self): |     def package_dir(self): | ||||||
|         """Return the directory where the package.py file lives.""" |         """Return the directory where the package.py file lives.""" | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ | |||||||
| import shutil | import shutil | ||||||
|  |  | ||||||
|  |  | ||||||
| class Hdf5(Package): | class Hdf5(AutotoolsPackage): | ||||||
|     """HDF5 is a data model, library, and file format for storing and managing |     """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 |        data. It supports an unlimited variety of datatypes, and is designed for | ||||||
|        flexible and efficient I/O and for high volume and complex data. |        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("szip", when='+szip') | ||||||
|     depends_on("zlib") |     depends_on("zlib") | ||||||
|  |  | ||||||
|     def validate(self, spec): |     @AutotoolsPackage.precondition('configure') | ||||||
|  |     def validate(self): | ||||||
|         """ |         """ | ||||||
|         Checks if incompatible variants have been activated at the same time |         Checks if incompatible variants have been activated at the same time | ||||||
|  |  | ||||||
|         :param spec: spec of the package |         :param spec: spec of the package | ||||||
|         :raises RuntimeError: in case of inconsistencies |         :raises RuntimeError: in case of inconsistencies | ||||||
|         """ |         """ | ||||||
|  |         spec = self.spec | ||||||
|         if '+fortran' in spec and not self.compiler.fc: |         if '+fortran' in spec and not self.compiler.fc: | ||||||
|             msg = 'cannot build a fortran variant without a fortran compiler' |             msg = 'cannot build a fortran variant without a fortran compiler' | ||||||
|             raise RuntimeError(msg) |             raise RuntimeError(msg) | ||||||
| @@ -73,8 +75,8 @@ def validate(self, spec): | |||||||
|             msg = 'cannot use variant +threadsafe with either +cxx or +fortran' |             msg = 'cannot use variant +threadsafe with either +cxx or +fortran' | ||||||
|             raise RuntimeError(msg) |             raise RuntimeError(msg) | ||||||
|  |  | ||||||
|     def install(self, spec, prefix): |     def configure_args(self): | ||||||
|         self.validate(spec) |         spec = self.spec | ||||||
|         # Handle compilation after spec validation |         # Handle compilation after spec validation | ||||||
|         extra_args = [] |         extra_args = [] | ||||||
|  |  | ||||||
| @@ -137,16 +139,19 @@ def install(self, spec, prefix): | |||||||
|                 '--disable-hl', |                 '--disable-hl', | ||||||
|             ]) |             ]) | ||||||
|  |  | ||||||
|         configure( |         return ["--with-zlib=%s" % spec['zlib'].prefix] + extra_args | ||||||
|             "--prefix=%s" % prefix, |         #configure( | ||||||
|             "--with-zlib=%s" % spec['zlib'].prefix, |         #    "--prefix=%s" % prefix, | ||||||
|             *extra_args) |         #    "--with-zlib=%s" % spec['zlib'].prefix, | ||||||
|         make() |         #    *extra_args) | ||||||
|         make("install") |         #make() | ||||||
|         self.check_install(spec) |         #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" |         "Build and run a small program to test the installed HDF5 library" | ||||||
|  |         spec = self.spec | ||||||
|         print "Checking HDF5 installation..." |         print "Checking HDF5 installation..." | ||||||
|         checkdir = "spack-check" |         checkdir = "spack-check" | ||||||
|         with working_dir(checkdir, create=True): |         with working_dir(checkdir, create=True): | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ | |||||||
| from spack import * | from spack import * | ||||||
|  |  | ||||||
|  |  | ||||||
| class Lzo(Package): | class Lzo(AutotoolsPackage): | ||||||
|     """Real-time data compression library""" |     """Real-time data compression library""" | ||||||
|  |  | ||||||
|     homepage = 'https://www.oberhumer.com/opensource/lzo/' |     homepage = 'https://www.oberhumer.com/opensource/lzo/' | ||||||
| @@ -37,13 +37,13 @@ class Lzo(Package): | |||||||
|     version('2.06', '95380bd4081f85ef08c5209f4107e9f8') |     version('2.06', '95380bd4081f85ef08c5209f4107e9f8') | ||||||
|     version('2.05', 'c67cda5fa191bab761c7cb06fe091e36') |     version('2.05', 'c67cda5fa191bab761c7cb06fe091e36') | ||||||
|  |  | ||||||
|     def install(self, spec, prefix): |     def configure_args(self): | ||||||
|         configure_args = [ |         return [ | ||||||
|             '--prefix={0}'.format(prefix), |  | ||||||
|             '--disable-dependency-tracking', |             '--disable-dependency-tracking', | ||||||
|             '--enable-shared' |             '--enable-shared' | ||||||
|         ] |         ] | ||||||
|         configure(*configure_args) |  | ||||||
|         make() |     @AutotoolsPackage.sanity_check('build') | ||||||
|  |     def check(self): | ||||||
|  |         if self.extra_args.get('build-tests', False): | ||||||
|             make('check') |             make('check') | ||||||
|         make('install') |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 alalazo
					alalazo