diff options
author | Adam J. Stewart <ajstewart426@gmail.com> | 2017-08-04 16:52:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-04 16:52:10 -0500 |
commit | 7eb263effe3ac6f2f79e4f6c060b7ae96b7a9cc8 (patch) | |
tree | b4a96b5d44a7bcc7ce4cd2bb7ae676a5c0efdc6a /var/spack/repos/builtin/packages/cantera/package.py | |
parent | b8ed61cfea58c8cab5c86d6c0189512605890444 (diff) | |
download | spack-7eb263effe3ac6f2f79e4f6c060b7ae96b7a9cc8.tar.gz spack-7eb263effe3ac6f2f79e4f6c060b7ae96b7a9cc8.tar.bz2 spack-7eb263effe3ac6f2f79e4f6c060b7ae96b7a9cc8.tar.xz spack-7eb263effe3ac6f2f79e4f6c060b7ae96b7a9cc8.zip |
Add a SConsPackage base class (#4936)
* Add a SConsPackage base class
* Make Matlab extendable
* Most dependencies are actually required
* Cantera requires older version of fmt
Diffstat (limited to 'var/spack/repos/builtin/packages/cantera/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/cantera/package.py | 137 |
1 files changed, 76 insertions, 61 deletions
diff --git a/var/spack/repos/builtin/packages/cantera/package.py b/var/spack/repos/builtin/packages/cantera/package.py index 5987f0865a..36c796e45d 100644 --- a/var/spack/repos/builtin/packages/cantera/package.py +++ b/var/spack/repos/builtin/packages/cantera/package.py @@ -26,132 +26,147 @@ from spack import * import os -class Cantera(Package): +class Cantera(SConsPackage): """Cantera is a suite of object-oriented software tools for problems involving chemical kinetics, thermodynamics, and/or transport processes.""" homepage = "http://www.cantera.org/docs/sphinx/html/index.html" - url = "https://github.com/Cantera/cantera/archive/v2.2.1.tar.gz" + url = "https://github.com/Cantera/cantera/archive/v2.3.0.tar.gz" + version('2.3.0', 'aebbd8d891cb1623604245398502b72e') version('2.2.1', '9d1919bdef39ddec54485fc8a741a3aa') - variant('lapack', default=True, - description='Build with external BLAS/LAPACK libraries') - variant('threadsafe', default=True, - description='Build threadsafe, requires Boost') - variant('sundials', default=True, - description='Build with external Sundials') variant('python', default=False, description='Build the Cantera Python module') variant('matlab', default=False, description='Build the Cantera Matlab toolbox') # Required dependencies - depends_on('scons', type='build') - - # Recommended dependencies - depends_on('blas', when='+lapack') - depends_on('lapack', when='+lapack') - depends_on('boost', when='+threadsafe') - depends_on('sundials', when='+sundials') # must be compiled with -fPIC + depends_on('fmt@3.0.0:3.0.2', when='@2.3.0:') + depends_on('googletest', when='@2.3.0:') + depends_on('eigen', when='@2.3.0:') + depends_on('boost') + depends_on('sundials') # must be compiled with -fPIC + depends_on('blas') + depends_on('lapack') # Python module dependencies extends('python', when='+python') + depends_on('py-cython', when='+python', type='build') depends_on('py-numpy', when='+python', type=('build', 'run')) depends_on('py-scipy', when='+python', type=('build', 'run')) - depends_on('py-cython', when='+python', type=('build', 'run')) depends_on('py-3to2', when='+python', type=('build', 'run')) # TODO: these "when" specs don't actually work # depends_on('py-unittest2', when='+python^python@2.6', type=('build', 'run')) # noqa # depends_on('py-unittest2py3k', when='+python^python@3.1', type=('build', 'run')) # noqa # Matlab toolbox dependencies - # TODO: add Matlab package - # TODO: allow packages to extend multiple other packages - # extends('matlab', when='+matlab') + extends('matlab', when='+matlab') + + def build_args(self, spec, prefix): + # Valid args can be found by running `scons help` - def install(self, spec, prefix): - # Required options - options = [ + # Required args + args = [ + 'build', 'prefix={0}'.format(prefix), - 'CC={0}'.format(os.environ['CC']), - 'CXX={0}'.format(os.environ['CXX']), - 'F77={0}'.format(os.environ['F77']), - 'FORTRAN={0}'.format(os.environ['FC']), + 'VERBOSE=yes', + 'CC={0}'.format(spack_cc), + 'CXX={0}'.format(spack_cxx), + 'FORTRAN={0}'.format(spack_fc), 'cc_flags={0}'.format(self.compiler.pic_flag), # Allow Spack environment variables to propagate through to SCons 'env_vars=all' ] - # BLAS/LAPACK support - if '+lapack' in spec: - lapack_blas = spec['lapack'].libs + spec['blas'].libs - options.extend([ - 'blas_lapack_libs={0}'.format(','.join(lapack_blas.names)), - 'blas_lapack_dir={0}'.format(spec['lapack'].prefix.lib) + if spec.satisfies('@:2.2.1'): + args.append('F77={0}'.format(spack_f77)) + + # fmt support + if spec.satisfies('@2.3.0:'): + args.append('system_fmt=y') + + # Googletest support + if spec.satisfies('@2.3.0:'): + args.append('system_googletest=y') + + # Eigen support + if spec.satisfies('@2.3.0:'): + args.extend([ + 'system_eigen=y', + 'extra_inc_dirs={0}'.format( + join_path(spec['eigen'].prefix.include, 'eigen{0}'.format( + spec['eigen'].version.up_to(1)))), ]) - # Threadsafe build, requires Boost - if '+threadsafe' in spec: - options.extend([ + # BLAS/LAPACK support + lapack_blas = spec['lapack'].libs + spec['blas'].libs + args.extend([ + 'blas_lapack_libs={0}'.format(','.join(lapack_blas.names)), + 'blas_lapack_dir={0}'.format(spec['lapack'].prefix.lib) + ]) + + # Boost support + if spec.satisfies('@2.3.0:'): + args.append('boost_inc_dir={0}'.format( + spec['boost'].prefix.include)) + else: + args.extend([ 'build_thread_safe=yes', 'boost_inc_dir={0}'.format(spec['boost'].prefix.include), - 'boost_lib_dir={0}'.format(spec['boost'].prefix.lib) + 'boost_lib_dir={0}'.format(spec['boost'].prefix.lib), ]) - else: - options.append('build_thread_safe=no') # Sundials support - if '+sundials' in spec: - options.extend([ + if spec.satisfies('@2.3.0:'): + args.append('system_sundials=y') + else: + args.extend([ 'use_sundials=y', - 'sundials_include={0}'.format(spec['sundials'].prefix.include), - 'sundials_libdir={0}'.format(spec['sundials'].prefix.lib), 'sundials_license={0}'.format( - join_path(spec['sundials'].prefix, 'LICENSE')) + spec['sundials'].prefix.LICENSE) ]) - else: - options.append('use_sundials=n') + + args.extend([ + 'sundials_include={0}'.format(spec['sundials'].prefix.include), + 'sundials_libdir={0}'.format(spec['sundials'].prefix.lib), + ]) # Python module if '+python' in spec: - options.extend([ + args.extend([ 'python_package=full', 'python_cmd={0}'.format(spec['python'].command.path), - 'python_array_home={0}'.format(spec['py-numpy'].prefix) ]) - if spec['python'].satisfies('@3'): - options.extend([ + if spec['python'].satisfies('@3:'): + args.extend([ 'python3_package=y', 'python3_cmd={0}'.format(spec['python'].command.path), - 'python3_array_home={0}'.format(spec['py-numpy'].prefix) ]) else: - options.append('python3_package=n') + args.append('python3_package=n') else: - options.append('python_package=none') - options.append('python3_package=n') + args.append('python_package=none') + args.append('python3_package=n') # Matlab toolbox if '+matlab' in spec: - options.extend([ + args.extend([ 'matlab_toolbox=y', 'matlab_path={0}'.format(spec['matlab'].prefix) ]) else: - options.append('matlab_toolbox=n') + args.append('matlab_toolbox=n') - scons('build', *options) + return args - if '+python' in spec: + def test(self): + if '+python' in self.spec: # Tests will always fail if Python dependencies aren't built # In addition, 3 of the tests fail when run in parallel scons('test', parallel=False) - scons('install') - - self.filter_compilers() - + @run_after('install') def filter_compilers(self): """Run after install to tell the Makefile and SConstruct files to use the compilers that Spack built the package with. |