From 9d99042fed2abad1ccb22669bc1dfa298d495768 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 3 Jun 2016 15:12:10 -0500 Subject: Add Psi4 package --- var/spack/repos/builtin/packages/boost/package.py | 2 +- var/spack/repos/builtin/packages/psi4/package.py | 84 +++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 var/spack/repos/builtin/packages/psi4/package.py diff --git a/var/spack/repos/builtin/packages/boost/package.py b/var/spack/repos/builtin/packages/boost/package.py index 8a49672824..d833054e33 100644 --- a/var/spack/repos/builtin/packages/boost/package.py +++ b/var/spack/repos/builtin/packages/boost/package.py @@ -25,7 +25,6 @@ from spack import * import spack import sys - import os @@ -91,6 +90,7 @@ class Boost(Package): 'system', 'test', 'thread', + 'timer', 'wave']) # mpi/python are not installed by default because they pull in many diff --git a/var/spack/repos/builtin/packages/psi4/package.py b/var/spack/repos/builtin/packages/psi4/package.py new file mode 100644 index 0000000000..5c2ce369c9 --- /dev/null +++ b/var/spack/repos/builtin/packages/psi4/package.py @@ -0,0 +1,84 @@ +############################################################################## +# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/llnl/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## +from spack import * + + +class Psi4(Package): + """Psi4 is an open-source suite of ab initio quantum chemistry + programs designed for efficient, high-accuracy simulations of + a variety of molecular properties.""" + + homepage = "http://www.psicode.org/" + url = "https://github.com/psi4/psi4/archive/0.5.tar.gz" + + version('0.5', '53041b8a9be3958384171d0d22f9fdd0') + + variant('mpi', default=True, description='Enable MPI parallelization') + + # Required dependencies + depends_on('python@2.7:') + depends_on('py-numpy') + depends_on('blas') + depends_on('lapack') + depends_on('cmake@3.0:') + depends_on('boost@1.55.0:+chrono+filesystem~mpi+python+regex+serialization+system+timer+thread', when='~mpi') + depends_on('boost@1.55.0:+chrono+filesystem+mpi+python+regex+serialization+system+timer+thread', when='+mpi') + + # Optional dependencies + depends_on('mpi', when='+mpi') + # TODO: add packages for these + # depends_on('perl') + # depends_on('erd') + # depends_on('pcm-solver') + # depends_on('chemps2') + + def install(self, spec, prefix): + cmake_args = [ + '-DBLAS_TYPE={0}'.format(spec['blas'].name.upper()), + '-DBLAS_LIBRARIES={0}'.format(spec['blas'].blas_shared_lib), + '-DLAPACK_TYPE={0}'.format(spec['lapack'].name.upper()), + '-DLAPACK_LIBRARIES={0}'.format(spec['lapack'].lapack_shared_lib), + '-DBOOST_INCLUDEDIR={0}'.format(spec['boost'].prefix.include), + '-DBOOST_LIBRARYDIR={0}'.format(spec['boost'].prefix.lib), + '-DENABLE_CHEMPS2=OFF' + ] + + if '+mpi' in spec: + cmake_args.extend([ + '-DENABLE_MPI=ON' + #'-DMPI_C_COMPILER={0}'.format(spec['mpi'].mpicc) + #'-DMPI_C_INCLUDE_PATH={0}'.format(spec['mpi'].prefix.include), + ]) + else: + cmake_args.append('-DENABLE_MPI=OFF') + + cmake_args.extend(std_cmake_args) + + with working_dir('spack-build', create=True): + cmake('..', *cmake_args) + + make() + #ctest() + make('install') -- cgit v1.2.3-70-g09d2 From deb4f919cf64717036ee0c8c1b6cb00d46b579aa Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Mon, 13 Jun 2016 16:14:16 -0500 Subject: Psi4 tweaks --- var/spack/repos/builtin/packages/psi4/package.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/var/spack/repos/builtin/packages/psi4/package.py b/var/spack/repos/builtin/packages/psi4/package.py index 5c2ce369c9..e02dc65fd4 100644 --- a/var/spack/repos/builtin/packages/psi4/package.py +++ b/var/spack/repos/builtin/packages/psi4/package.py @@ -38,13 +38,13 @@ class Psi4(Package): variant('mpi', default=True, description='Enable MPI parallelization') # Required dependencies - depends_on('python@2.7:') - depends_on('py-numpy') depends_on('blas') depends_on('lapack') - depends_on('cmake@3.0:') - depends_on('boost@1.55.0:+chrono+filesystem~mpi+python+regex+serialization+system+timer+thread', when='~mpi') - depends_on('boost@1.55.0:+chrono+filesystem+mpi+python+regex+serialization+system+timer+thread', when='+mpi') + depends_on('boost+chrono+filesystem~mpi+python+regex+serialization+system+timer+thread', when='~mpi') + depends_on('boost+chrono+filesystem+mpi+python+regex+serialization+system+timer+thread', when='+mpi') + depends_on('python') + depends_on('cmake') + depends_on('py-numpy') # Optional dependencies depends_on('mpi', when='+mpi') @@ -62,23 +62,15 @@ class Psi4(Package): '-DLAPACK_LIBRARIES={0}'.format(spec['lapack'].lapack_shared_lib), '-DBOOST_INCLUDEDIR={0}'.format(spec['boost'].prefix.include), '-DBOOST_LIBRARYDIR={0}'.format(spec['boost'].prefix.lib), + '-DENABLE_MPI={0}'.format('ON' if '+mpi' in spec else 'OFF'), '-DENABLE_CHEMPS2=OFF' ] - if '+mpi' in spec: - cmake_args.extend([ - '-DENABLE_MPI=ON' - #'-DMPI_C_COMPILER={0}'.format(spec['mpi'].mpicc) - #'-DMPI_C_INCLUDE_PATH={0}'.format(spec['mpi'].prefix.include), - ]) - else: - cmake_args.append('-DENABLE_MPI=OFF') - cmake_args.extend(std_cmake_args) with working_dir('spack-build', create=True): cmake('..', *cmake_args) make() - #ctest() + # ctest() make('install') -- cgit v1.2.3-70-g09d2 From 9cf1257be4b6203f5a90ee5b410902daafa53d7b Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 14 Jun 2016 11:19:05 -0500 Subject: Filter compilers --- var/spack/repos/builtin/packages/psi4/package.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/var/spack/repos/builtin/packages/psi4/package.py b/var/spack/repos/builtin/packages/psi4/package.py index e02dc65fd4..4bd47302ab 100644 --- a/var/spack/repos/builtin/packages/psi4/package.py +++ b/var/spack/repos/builtin/packages/psi4/package.py @@ -23,6 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * +import os class Psi4(Package): @@ -74,3 +75,26 @@ class Psi4(Package): make() # ctest() make('install') + + self.filter_compilers() + + def filter_compilers(self): + """Run after install to tell the configuration files to + use the compilers that Spack built the package with. + + If this isn't done, they'll have PLUGIN_CXX set to + Spack's generic cxx. We want it to be bound to + whatever compiler it was built with.""" + + kwargs = {'ignore_absent': True, 'backup': False, 'string': True} + + cc_files = ['bin/psi4-config'] + cxx_files = ['bin/psi4-config', 'include/psi4/psiconfig.h'] + + for filename in cc_files: + filter_file(os.environ['CC'], self.compiler.cc, + os.path.join(self.prefix, filename), **kwargs) + + for filename in cxx_files: + filter_file(os.environ['CXX'], self.compiler.cxx, + os.path.join(self.prefix, filename), **kwargs) -- cgit v1.2.3-70-g09d2 From 7b97ea248a355d0dd763facd808722dfb1632f14 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Wed, 15 Jun 2016 09:33:13 -0500 Subject: More template filtering --- var/spack/repos/builtin/packages/psi4/package.py | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/var/spack/repos/builtin/packages/psi4/package.py b/var/spack/repos/builtin/packages/psi4/package.py index 4bd47302ab..74f1554336 100644 --- a/var/spack/repos/builtin/packages/psi4/package.py +++ b/var/spack/repos/builtin/packages/psi4/package.py @@ -73,12 +73,12 @@ class Psi4(Package): cmake('..', *cmake_args) make() - # ctest() + ctest() make('install') - self.filter_compilers() + self.filter_compilers(spec) - def filter_compilers(self): + def filter_compilers(self, spec): """Run after install to tell the configuration files to use the compilers that Spack built the package with. @@ -90,6 +90,7 @@ class Psi4(Package): cc_files = ['bin/psi4-config'] cxx_files = ['bin/psi4-config', 'include/psi4/psiconfig.h'] + template = 'share/psi4/plugin/Makefile.template' for filename in cc_files: filter_file(os.environ['CC'], self.compiler.cc, @@ -98,3 +99,22 @@ class Psi4(Package): for filename in cxx_files: filter_file(os.environ['CXX'], self.compiler.cxx, os.path.join(self.prefix, filename), **kwargs) + + # The binary still keeps track of the compiler used to install Psi4 + # and uses it when creating a plugin template + filter_file('@PLUGIN_CXX@', self.compiler.cxx, + os.path.join(self.prefix, template), **kwargs) + + # The binary links to the build include directory instead of the + # installation include directory: + # https://github.com/psi4/psi4/issues/410 + filter_file('@PLUGIN_INCLUDES@', '-I{0}'.format( + ' -I'.join( + spec['psi4'].prefix.include, + spec['boost'].prefix.include, + spec['lapack'].prefix.include, + spec['blas'].prefix.include, + spec['python'].prefix.include, + '/usr/include' + ) + ), os.path.join(self.prefix, template), **kwargs) -- cgit v1.2.3-70-g09d2 From 44e188f1111ce4251a756d92cae7c5a7e0ed41fe Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Wed, 15 Jun 2016 13:55:51 -0500 Subject: Remove MPI support, fix INCLUDE filters --- var/spack/repos/builtin/packages/psi4/package.py | 37 ++++++++++-------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/var/spack/repos/builtin/packages/psi4/package.py b/var/spack/repos/builtin/packages/psi4/package.py index 74f1554336..fc77ba7412 100644 --- a/var/spack/repos/builtin/packages/psi4/package.py +++ b/var/spack/repos/builtin/packages/psi4/package.py @@ -36,19 +36,15 @@ class Psi4(Package): version('0.5', '53041b8a9be3958384171d0d22f9fdd0') - variant('mpi', default=True, description='Enable MPI parallelization') - # Required dependencies depends_on('blas') depends_on('lapack') - depends_on('boost+chrono+filesystem~mpi+python+regex+serialization+system+timer+thread', when='~mpi') - depends_on('boost+chrono+filesystem+mpi+python+regex+serialization+system+timer+thread', when='+mpi') + depends_on('boost+chrono+filesystem+python+regex+serialization+system+timer+thread') depends_on('python') depends_on('cmake') depends_on('py-numpy') # Optional dependencies - depends_on('mpi', when='+mpi') # TODO: add packages for these # depends_on('perl') # depends_on('erd') @@ -63,7 +59,6 @@ class Psi4(Package): '-DLAPACK_LIBRARIES={0}'.format(spec['lapack'].lapack_shared_lib), '-DBOOST_INCLUDEDIR={0}'.format(spec['boost'].prefix.include), '-DBOOST_LIBRARYDIR={0}'.format(spec['boost'].prefix.lib), - '-DENABLE_MPI={0}'.format('ON' if '+mpi' in spec else 'OFF'), '-DENABLE_CHEMPS2=OFF' ] @@ -73,12 +68,11 @@ class Psi4(Package): cmake('..', *cmake_args) make() - ctest() make('install') - self.filter_compilers(spec) + self.filter_compilers(spec, prefix) - def filter_compilers(self, spec): + def filter_compilers(self, spec, prefix): """Run after install to tell the configuration files to use the compilers that Spack built the package with. @@ -94,27 +88,28 @@ class Psi4(Package): for filename in cc_files: filter_file(os.environ['CC'], self.compiler.cc, - os.path.join(self.prefix, filename), **kwargs) + os.path.join(prefix, filename), **kwargs) for filename in cxx_files: filter_file(os.environ['CXX'], self.compiler.cxx, - os.path.join(self.prefix, filename), **kwargs) + os.path.join(prefix, filename), **kwargs) # The binary still keeps track of the compiler used to install Psi4 # and uses it when creating a plugin template filter_file('@PLUGIN_CXX@', self.compiler.cxx, - os.path.join(self.prefix, template), **kwargs) + os.path.join(prefix, template), **kwargs) # The binary links to the build include directory instead of the # installation include directory: # https://github.com/psi4/psi4/issues/410 filter_file('@PLUGIN_INCLUDES@', '-I{0}'.format( - ' -I'.join( - spec['psi4'].prefix.include, - spec['boost'].prefix.include, - spec['lapack'].prefix.include, - spec['blas'].prefix.include, - spec['python'].prefix.include, - '/usr/include' - ) - ), os.path.join(self.prefix, template), **kwargs) + ' -I'.join([ + os.path.join(spec['psi4'].prefix.include, 'psi4'), + os.path.join(spec['boost'].prefix.include, 'boost'), + os.path.join(spec['python'].prefix.include, 'python{0}'.format( + spec['python'].version.up_to(2))), + spec['lapack'].prefix.include, + spec['blas'].prefix.include, + '/usr/include' + ]) + ), os.path.join(prefix, template), **kwargs) -- cgit v1.2.3-70-g09d2 From ea80c8d3c3a0690dcb357840cfb0db824f44fdc9 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Wed, 15 Jun 2016 14:38:53 -0500 Subject: Ignore E501 for depends_on and extends --- share/spack/qa/run-flake8 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/spack/qa/run-flake8 b/share/spack/qa/run-flake8 index 44eb0167fb..57534eb6e2 100755 --- a/share/spack/qa/run-flake8 +++ b/share/spack/qa/run-flake8 @@ -29,6 +29,8 @@ for file in $changed; do perl -i -pe 's/^(\s*url\s*=.*)$/\1 # NOQA: ignore=E501/' $file perl -i -pe 's/^(\s*version\(.*\).*)$/\1 # NOQA: ignore=E501/' $file perl -i -pe 's/^(\s*variant\(.*\).*)$/\1 # NOQA: ignore=E501/' $file + perl -i -pe 's/^(\s*depends_on\(.*\).*)$/\1 # NOQA: ignore=E501/' $file + perl -i -pe 's/^(\s*extends\(.*\).*)$/\1 # NOQA: ignore=E501/' $file # Exempt '@when' decorated functions from redefinition errors. perl -i -pe 's/^(\s*\@when\(.*\).*)$/\1 # NOQA: ignore=F811/' $file -- cgit v1.2.3-70-g09d2