From 4c87ef915f917c2262349832966a12127b7700b3 Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Sun, 22 May 2016 18:55:29 +0200 Subject: First try at OpenFOAM-extend --- .../builtin/packages/openfoam-extend/package.py | 262 +++++++++++++++++++++ .../repos/builtin/packages/parmgridgen/package.py | 75 ++++++ var/spack/repos/builtin/packages/scotch/package.py | 12 +- 3 files changed, 342 insertions(+), 7 deletions(-) create mode 100644 var/spack/repos/builtin/packages/openfoam-extend/package.py create mode 100644 var/spack/repos/builtin/packages/parmgridgen/package.py (limited to 'var') diff --git a/var/spack/repos/builtin/packages/openfoam-extend/package.py b/var/spack/repos/builtin/packages/openfoam-extend/package.py new file mode 100644 index 0000000000..6af824df7e --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam-extend/package.py @@ -0,0 +1,262 @@ +from spack import * +from spack.environment import * + +import multiprocessing +import subprocess +import re +import os + + +class OpenfoamExtend(Package): + """OpenFOAM-extend or foam-extend""" + + version('3.2', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.2') + version('3.1', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.1') + version('3.0', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.0') + + variant('paraview', default=False, description='Enable ParaFOAM') + variant('scotch', default=True, description='Activate Scotch as a possible decomposition library') + variant('ptscotch', default=True, description='Activate PT-Scotch as a possible decomposition library') + variant('metis', default=True, description='Activate Metis as a possible decomposition library') + variant('parmetis', default=True, description='Activate Parmetis as a possible decomposition library') + variant('parmgridgen', default=True, description='Activate Parmgridgen support') + + supported_compilers = {'clang': 'Clang', 'gcc': 'Gcc', 'intel': 'Icc'} + + depends_on('mpi') + depends_on('cmake') + depends_on('python') + depends_on('flex@:2.5.99') + depends_on('bison') + depends_on('m4') + depends_on('hwloc') + depends_on('zlib') + + depends_on('scotch ~ metis', when='~ptscotch+scotch') + depends_on('scotch ~ metis + mpi', when='+ptscotch') + depends_on('metis@5:', when='+metis') + depends_on('parmetis', when='+parmetis') + depends_on('parmgridgen', when='+parmgridgen') + + depends_on('paraview', when='+paraview') + depends_on('qt@:4', when='+paraview') + + def _get_env(self, command): + variable_set = re.compile(r'(.+?)=(.*)') + proc = subprocess.Popen(['bash', '-c', command], + stdout=subprocess.PIPE) + env = {} + for line in proc.stdout: + match_grp = variable_set.match(line) + if match_grp: + env[match_grp.group(1)] = match_grp.group(2) + return env + + def set_arch(self): + (sysname, nodename, release, version, machine) = os.uname() + + if self.compiler.name not in self.supported_compilers: + raise RuntimeError('{0} is not a supported compiler \ + to compile OpenFOAM'.format(self.compiler.name)) + + foam_compiler = self.supported_compilers[self.compiler.name] + if sysname == 'Linux': + arch = 'linux' + if foam_compiler == 'Clang': + raise RuntimeError('OS, compiler combinaison not\ + supported ({0} {1})'.format(sysname, foam_compiler)) + elif sysname == 'Darwin': + if machine == 'x86_64': + arch = 'darwinIntel' + if foam_compiler == 'Icc': + raise RuntimeError('OS, compiler combinaison not\ + supported ({0} {1})'.format(sysname, foam_compiler)) + else: + raise RuntimeError('{0} {1} is not a \ + supported architecture'.format(sysname, machine)) + + return (arch, foam_compiler) + + def get_openfoam_environment(self, env_openfoam): + env_before = self._get_env('env') + + with working_dir(self.stage.source_path): + env_after = self._get_env('source etc/bashrc && env') + + if 'PATH' in env_after: + del env_after['PATH'] + + if 'LD_LIBRARY_PATH' in env_after: + del env_after['LD_LIBRARY_PATH'] + + for key, value in env_after.iteritems(): + if key not in env_before or not value == env_before[key]: + env_openfoam.set(key, value) + + def patch(self): + if '+parmgridgen' in self.spec: + filter_file(r'-lIMlib -lMGridGen', + r'-limlib -lmgrid', + 'src/dbns/Make/options') + filter_file(r'-lMGridGen', + r'-lmgrid', + 'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options') + + (arch, foam_compiler) = self.set_arch() + + prefs_dict = { + 'compilerInstall': 'System', + 'WM_COMPILER': foam_compiler, + 'WM_ARCH_OPTION': '64', + 'WM_PRECISION_OPTION': 'DP', + 'WM_COMPILE_OPTION': 'SPACKOpt', + 'WM_MPLIB': 'SPACK', + + 'CMAKE_DIR': self.spec['cmake'].prefix, + 'CMAKE_BIN_DIR': self.spec['cmake'].prefix.bin, + 'PYTHON_DIR': self.spec['python'].prefix, + 'PYTHON_BIN_DIR': self.spec['python'].prefix.bin, + + 'FLEX_SYSTEM': 1, + 'FLEX_DIR': self.spec['flex'].prefix, + + 'BISON_SYSTEM': 1, + 'BISON_DIR': self.spec['flex'].prefix, + + 'M4_SYSTEM': 1, + 'M4_DIR': self.spec['m4'].prefix, + + 'ZLIB_SYSTEM': 1, + 'ZLIB_DIR': self.spec['zlib'].prefix, + + 'HWLOC_SYSTEM': 1, + 'HWLOC_DIR': self.spec['hwloc'].prefix, + 'HWLOC_BIN_DIR': self.spec['hwloc'].prefix.bin, + } + + if '+scotch' in self.spec or '+ptscotch' in self.spec: + prefs_dict['SCOTCH_SYSTEM'] = 1 + prefs_dict['SCOTCH_DIR'] = self.spec['scotch'].prefix + prefs_dict['SCOTCH_BIN_DIR'] = self.spec['scotch'].prefix.bin + prefs_dict['SCOTCH_LIB_DIR'] = self.spec['scotch'].prefix.lib + prefs_dict['SCOTCH_INCLUDE_DIR'] = \ + self.spec['scotch'].prefix.include + + if '+metis' in self.spec: + prefs_dict['METIS_SYSTEM'] = 1 + prefs_dict['METIS_DIR'] = self.spec['metis'].prefix + prefs_dict['METIS_BIN_DIR'] = self.spec['metis'].prefix.bin + prefs_dict['METIS_LIB_DIR'] = self.spec['metis'].prefix.lib + prefs_dict['METIS_INCLUDE_DIR'] = self.spec['metis'].prefix.include + + if '+parmetis' in self.spec: + prefs_dict['PARMETIS_SYSTEM'] = 1 + prefs_dict['PARMETIS_DIR'] = self.spec['parmetis'].prefix + prefs_dict['PARMETIS_BIN_DIR'] = self.spec['parmetis'].prefix.bin + prefs_dict['PARMETIS_LIB_DIR'] = self.spec['parmetis'].prefix.lib + prefs_dict['PARMETIS_INCLUDE_DIR'] = \ + self.spec['parmetis'].prefix.include + + if '+parmgridgen' in self.spec: + prefs_dict['PARMGRIDGEN_SYSTEM'] = 1 + prefs_dict['PARMGRIDGEN_DIR'] = self.spec['parmgridgen'].prefix + prefs_dict['PARMGRIDGEN_BIN_DIR'] = \ + self.spec['parmgridgen'].prefix.bin + prefs_dict['PARMGRIDGEN_LIB_DIR'] = \ + self.spec['parmgridgen'].prefix.lib + prefs_dict['PARMGRIDGEN_INCLUDE_DIR'] = \ + self.spec['parmgridgen'].prefix.include + + if '+paraview' in self.spec: + prefs_dict['PARAVIEW_SYSTEM'] = 1 + prefs_dict['PARAVIEW_DIR'] = self.spec['paraview'].prefix, + prefs_dict['PARAVIEW_BIN_DIR'] = self.spec['paraview'].prefix.bin, + prefs_dict['QT_SYSTEM'] = 1 + prefs_dict['QT_DIR'] = self.spec['qt'].prefix, + prefs_dict['QT_BIN_DIR'] = self.spec['qt'].prefix.bin, + + with working_dir('.'): + with open("etc/prefs.sh", "w") as fh: + for key in sorted(prefs_dict): + fh.write('export {0}={1}\n'.format(key, prefs_dict[key])) + + with open("etc/prefs.csh", "w") as fh: + for key in sorted(prefs_dict): + fh.write('setenv {0}={1}\n'.format(key, prefs_dict[key])) + + mpi_info = [ + 'PFLAGS = -DOMPI_SKIP_MPICXX -DMPICH_IGNORE_CXX_SEEK', + 'PINC = -I{0}'.format(self.spec['mpi'].prefix.include), + 'PLIBS = -L{0} -lmpi'.format(self.spec['mpi'].prefix.lib) + ] + + arch_path = ''.join([arch, prefs_dict['WM_ARCH_OPTION'], + foam_compiler]) + option_path = ''.join([arch_path, + prefs_dict['WM_PRECISION_OPTION'], + prefs_dict['WM_COMPILE_OPTION']]) + rule_path = join_path("wmake", "rules", arch_path) + build_path = join_path(self.stage.source_path, 'lib', option_path) + install_path = \ + join_path(self.prefix, + 'foam-extend-{0}'.format(self.version.up_to(2)), + option_path) + + rpaths_foam = ' '.join([ + '{0}{1}'.format(self.compiler.cxx_rpath_arg, + install_path), + '{0}{1}'.format(self.compiler.cxx_rpath_arg, + build_path) + ]) + + compiler_flags = { + 'DBUG': rpaths_foam, + 'OPT': '-O3', + } + + with working_dir(rule_path): + with open('mplibSPACK', "w") as fh: + fh.write('\n'.join(mpi_info)) + + for comp in ['c', 'c++']: + with open('{0}SPACKOpt'.format(comp), "w") as fh: + for key, val in compiler_flags.iteritems(): + fh.write('{0}{1} = {2}\n'.format(comp, key, val)) + + def setup_environment(self, spack_env, run_env): + with working_dir(self.stage.path): + spack_env.set('FOAM_INST_DIR', os.path.abspath('.')) + + (arch, foam_compiler) = self.set_arch() + + run_env.set('FOAM_INST_DIR', self.prefix) + + def install(self, spec, prefix): + self.patch() + + env_openfoam = EnvironmentModifications() + self.get_openfoam_environment(env_openfoam) + env_openfoam.apply_modifications() + + if self.parallel: + os.environ['WM_NCOMPPROCS'] = str(self.make_jobs) \ + if self.make_jobs else str(multiprocessing.cpu_count()) + + # for key in sorted(os.environ): + # print("{0} = {1}".format(key, os.environ[key])) + + allwmake = Executable('./Allwmake') + allwmake() + + install_path = \ + join_path(self.prefix, + 'foam-extend-{0}'.format(self.version.up_to(2))) + + if '+source' in spec: + install_tree('src', join_path(install_path, 'src')) + + install_tree('lib', join_path(install_path, 'lib')) + install_tree('bin', join_path(install_path, 'bin')) + install_tree('applications', join_path(install_path, 'applications')) + install_tree('etc', join_path(install_path, 'etc')) + install_tree('wmake', join_path(install_path, 'wmake')) diff --git a/var/spack/repos/builtin/packages/parmgridgen/package.py b/var/spack/repos/builtin/packages/parmgridgen/package.py new file mode 100644 index 0000000000..11b19f2ec2 --- /dev/null +++ b/var/spack/repos/builtin/packages/parmgridgen/package.py @@ -0,0 +1,75 @@ +############################################################################## +# 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 Parmgridgen(Package): + """MGRIDGEN is a serial library written entirely in ANSI C that implements + (serial) algorithms for obtaining a sequence of successive coarse grids + that are well-suited for geometric multigrid methods. + ParMGridGen is the parallel version of MGridGen + """ + + homepage = "http://www-users.cs.umn.edu/~moulitsa/software.html" + url = "http://www-users.cs.umn.edu/~moulitsa/download/ParMGridGen-1.0.tar.gz" + + version('1.0', '2872fa95b7fb91d6bd525490eed62038') + + depends_on('mpi') + + def install(self, spec, prefix): + make_opts = [ + 'make=make', + 'COPTIONS=-fPIC', + 'LDOPTIONS=-fPIC', + 'CC={0}'.format(self.compiler.cc), + 'PARCC={0}'.format(self.spec['mpi'].mpicc), + 'LD={0}'.format(self.compiler.cc), + 'PARLD={0}'.format(self.spec['mpi'].mpicc), + 'LIBDIR=-L../..', + 'PARLIBS=-L../../ -lparmgrid -lmgrid -lm', + 'LIBS=-L../../ -lmgrid -lm', + 'parallel' + ] + + make(*make_opts, parallel=False) + + include_path = join_path(self.prefix, 'include') + lib_path = join_path(self.prefix, 'lib') + bin_path = join_path(self.prefix, 'bin') + + mkdirp(include_path, lib_path, bin_path) + + install("mgridgen.h", include_path) + install("parmgridgen.h", include_path) + + install("MGridGen/IMlib/libIMlib.a", + join_path(lib_path, 'libimlib.a')) + install("libmgrid.a", lib_path) + install("libparmgrid.a", lib_path) + + install("mgridgen", bin_path) + install("parmgridgen", bin_path) diff --git a/var/spack/repos/builtin/packages/scotch/package.py b/var/spack/repos/builtin/packages/scotch/package.py index 3c2b4993ac..2f6e42c439 100644 --- a/var/spack/repos/builtin/packages/scotch/package.py +++ b/var/spack/repos/builtin/packages/scotch/package.py @@ -171,15 +171,13 @@ class Scotch(Package): target == 'ptscotch')) make(target, parallel=can_make_parallel) - # todo change this to take into account darwin systems - lib_ext = '.so' if '+shared' in self.spec else '.a' + lib_ext = dso_suffix if '+shared' in self.spec else 'a' # It seams easier to remove metis wrappers from the folder that will be # installed than to tweak the Makefiles if '+metis' not in self.spec: with working_dir('lib'): - lib_ext = '.so' if '+shared' in self.spec else '.a' - force_remove('libscotchmetis{0}'.format(lib_ext)) - force_remove('libptscotchparmetis{0}'.format(lib_ext)) + force_remove('libscotchmetis.{0}'.format(lib_ext)) + force_remove('libptscotchparmetis.{0}'.format(lib_ext)) with working_dir('include'): force_remove('metis.h') @@ -187,8 +185,8 @@ class Scotch(Package): if '~esmumps' in self.spec and self.spec.version < Version('6.0.0'): with working_dir('lib'): - force_remove('libesmumps{0}'.format(lib_ext)) - force_remove('libptesmumps{0}'.format(lib_ext)) + force_remove('libesmumps.{0}'.format(lib_ext)) + force_remove('libptesmumps.{0}'.format(lib_ext)) with working_dir('include'): force_remove('esmumps.h') -- cgit v1.2.3-70-g09d2 From fe79e434592ee87fe69b65d30200794e10bf30f9 Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Mon, 30 May 2016 15:46:39 +0200 Subject: limiting package to foam-extend to start --- .../repos/builtin/packages/foam-extend/package.py | 263 +++++++++++++++++++++ .../builtin/packages/openfoam-extend/package.py | 262 -------------------- 2 files changed, 263 insertions(+), 262 deletions(-) create mode 100644 var/spack/repos/builtin/packages/foam-extend/package.py delete mode 100644 var/spack/repos/builtin/packages/openfoam-extend/package.py (limited to 'var') diff --git a/var/spack/repos/builtin/packages/foam-extend/package.py b/var/spack/repos/builtin/packages/foam-extend/package.py new file mode 100644 index 0000000000..4bbb065d8b --- /dev/null +++ b/var/spack/repos/builtin/packages/foam-extend/package.py @@ -0,0 +1,263 @@ +from spack import * +from spack.environment import * + +import multiprocessing +import subprocess +import re +import os + + +class FoamExtend(Package): + """The foam-extend project is a fork of the OpenFOAM open source library + for Computational Fluid Dynamics (CFD).""" + + version('3.2', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.2') + version('3.1', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.1') + version('3.0', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.0') + + variant('paraview', default=False, description='Enable ParaFOAM') + variant('scotch', default=True, description='Activate Scotch as a possible decomposition library') + variant('ptscotch', default=True, description='Activate PT-Scotch as a possible decomposition library') + variant('metis', default=True, description='Activate Metis as a possible decomposition library') + variant('parmetis', default=True, description='Activate Parmetis as a possible decomposition library') + variant('parmgridgen', default=True, description='Activate Parmgridgen support') + + supported_compilers = {'clang': 'Clang', 'gcc': 'Gcc', 'intel': 'Icc'} + + depends_on('mpi') + depends_on('cmake') + depends_on('python') + depends_on('flex@:2.5.99') + depends_on('bison') + depends_on('m4') + depends_on('hwloc') + depends_on('zlib') + + depends_on('scotch ~ metis', when='~ptscotch+scotch') + depends_on('scotch ~ metis + mpi', when='+ptscotch') + depends_on('metis@5:', when='+metis') + depends_on('parmetis', when='+parmetis') + depends_on('parmgridgen', when='+parmgridgen') + + depends_on('paraview', when='+paraview') + depends_on('qt@:4', when='+paraview') + + def _get_env(self, command): + variable_set = re.compile(r'(.+?)=(.*)') + proc = subprocess.Popen(['bash', '-c', command], + stdout=subprocess.PIPE) + env = {} + for line in proc.stdout: + match_grp = variable_set.match(line) + if match_grp: + env[match_grp.group(1)] = match_grp.group(2) + return env + + def set_arch(self): + (sysname, nodename, release, version, machine) = os.uname() + + if self.compiler.name not in self.supported_compilers: + raise RuntimeError('{0} is not a supported compiler \ + to compile OpenFOAM'.format(self.compiler.name)) + + foam_compiler = self.supported_compilers[self.compiler.name] + if sysname == 'Linux': + arch = 'linux' + if foam_compiler == 'Clang': + raise RuntimeError('OS, compiler combinaison not\ + supported ({0} {1})'.format(sysname, foam_compiler)) + elif sysname == 'Darwin': + if machine == 'x86_64': + arch = 'darwinIntel' + if foam_compiler == 'Icc': + raise RuntimeError('OS, compiler combinaison not\ + supported ({0} {1})'.format(sysname, foam_compiler)) + else: + raise RuntimeError('{0} {1} is not a \ + supported architecture'.format(sysname, machine)) + + return (arch, foam_compiler) + + def get_openfoam_environment(self, env_openfoam): + env_before = self._get_env('env') + + with working_dir(self.stage.source_path): + env_after = self._get_env('source etc/bashrc && env') + + if 'PATH' in env_after: + del env_after['PATH'] + + if 'LD_LIBRARY_PATH' in env_after: + del env_after['LD_LIBRARY_PATH'] + + for key, value in env_after.iteritems(): + if key not in env_before or not value == env_before[key]: + env_openfoam.set(key, value) + + def patch(self): + if '+parmgridgen' in self.spec: + filter_file(r'-lIMlib -lMGridGen', + r'-limlib -lmgrid', + 'src/dbns/Make/options') + filter_file(r'-lMGridGen', + r'-lmgrid', + 'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options') + + (arch, foam_compiler) = self.set_arch() + + prefs_dict = { + 'compilerInstall': 'System', + 'WM_COMPILER': foam_compiler, + 'WM_ARCH_OPTION': '64', + 'WM_PRECISION_OPTION': 'DP', + 'WM_COMPILE_OPTION': 'SPACKOpt', + 'WM_MPLIB': 'SPACK', + + 'CMAKE_DIR': self.spec['cmake'].prefix, + 'CMAKE_BIN_DIR': self.spec['cmake'].prefix.bin, + 'PYTHON_DIR': self.spec['python'].prefix, + 'PYTHON_BIN_DIR': self.spec['python'].prefix.bin, + + 'FLEX_SYSTEM': 1, + 'FLEX_DIR': self.spec['flex'].prefix, + + 'BISON_SYSTEM': 1, + 'BISON_DIR': self.spec['flex'].prefix, + + 'M4_SYSTEM': 1, + 'M4_DIR': self.spec['m4'].prefix, + + 'ZLIB_SYSTEM': 1, + 'ZLIB_DIR': self.spec['zlib'].prefix, + + 'HWLOC_SYSTEM': 1, + 'HWLOC_DIR': self.spec['hwloc'].prefix, + 'HWLOC_BIN_DIR': self.spec['hwloc'].prefix.bin, + } + + if '+scotch' in self.spec or '+ptscotch' in self.spec: + prefs_dict['SCOTCH_SYSTEM'] = 1 + prefs_dict['SCOTCH_DIR'] = self.spec['scotch'].prefix + prefs_dict['SCOTCH_BIN_DIR'] = self.spec['scotch'].prefix.bin + prefs_dict['SCOTCH_LIB_DIR'] = self.spec['scotch'].prefix.lib + prefs_dict['SCOTCH_INCLUDE_DIR'] = \ + self.spec['scotch'].prefix.include + + if '+metis' in self.spec: + prefs_dict['METIS_SYSTEM'] = 1 + prefs_dict['METIS_DIR'] = self.spec['metis'].prefix + prefs_dict['METIS_BIN_DIR'] = self.spec['metis'].prefix.bin + prefs_dict['METIS_LIB_DIR'] = self.spec['metis'].prefix.lib + prefs_dict['METIS_INCLUDE_DIR'] = self.spec['metis'].prefix.include + + if '+parmetis' in self.spec: + prefs_dict['PARMETIS_SYSTEM'] = 1 + prefs_dict['PARMETIS_DIR'] = self.spec['parmetis'].prefix + prefs_dict['PARMETIS_BIN_DIR'] = self.spec['parmetis'].prefix.bin + prefs_dict['PARMETIS_LIB_DIR'] = self.spec['parmetis'].prefix.lib + prefs_dict['PARMETIS_INCLUDE_DIR'] = \ + self.spec['parmetis'].prefix.include + + if '+parmgridgen' in self.spec: + prefs_dict['PARMGRIDGEN_SYSTEM'] = 1 + prefs_dict['PARMGRIDGEN_DIR'] = self.spec['parmgridgen'].prefix + prefs_dict['PARMGRIDGEN_BIN_DIR'] = \ + self.spec['parmgridgen'].prefix.bin + prefs_dict['PARMGRIDGEN_LIB_DIR'] = \ + self.spec['parmgridgen'].prefix.lib + prefs_dict['PARMGRIDGEN_INCLUDE_DIR'] = \ + self.spec['parmgridgen'].prefix.include + + if '+paraview' in self.spec: + prefs_dict['PARAVIEW_SYSTEM'] = 1 + prefs_dict['PARAVIEW_DIR'] = self.spec['paraview'].prefix, + prefs_dict['PARAVIEW_BIN_DIR'] = self.spec['paraview'].prefix.bin, + prefs_dict['QT_SYSTEM'] = 1 + prefs_dict['QT_DIR'] = self.spec['qt'].prefix, + prefs_dict['QT_BIN_DIR'] = self.spec['qt'].prefix.bin, + + with working_dir('.'): + with open("etc/prefs.sh", "w") as fh: + for key in sorted(prefs_dict): + fh.write('export {0}={1}\n'.format(key, prefs_dict[key])) + + with open("etc/prefs.csh", "w") as fh: + for key in sorted(prefs_dict): + fh.write('setenv {0}={1}\n'.format(key, prefs_dict[key])) + + mpi_info = [ + 'PFLAGS = -DOMPI_SKIP_MPICXX -DMPICH_IGNORE_CXX_SEEK', + 'PINC = -I{0}'.format(self.spec['mpi'].prefix.include), + 'PLIBS = -L{0} -lmpi'.format(self.spec['mpi'].prefix.lib) + ] + + arch_path = ''.join([arch, prefs_dict['WM_ARCH_OPTION'], + foam_compiler]) + option_path = ''.join([arch_path, + prefs_dict['WM_PRECISION_OPTION'], + prefs_dict['WM_COMPILE_OPTION']]) + rule_path = join_path("wmake", "rules", arch_path) + build_path = join_path(self.stage.source_path, 'lib', option_path) + install_path = \ + join_path(self.prefix, + 'foam-extend-{0}'.format(self.version.up_to(2)), + option_path) + + rpaths_foam = ' '.join([ + '{0}{1}'.format(self.compiler.cxx_rpath_arg, + install_path), + '{0}{1}'.format(self.compiler.cxx_rpath_arg, + build_path) + ]) + + compiler_flags = { + 'DBUG': rpaths_foam, + 'OPT': '-O3', + } + + with working_dir(rule_path): + with open('mplibSPACK', "w") as fh: + fh.write('\n'.join(mpi_info)) + + for comp in ['c', 'c++']: + with open('{0}SPACKOpt'.format(comp), "w") as fh: + for key, val in compiler_flags.iteritems(): + fh.write('{0}{1} = {2}\n'.format(comp, key, val)) + + def setup_environment(self, spack_env, run_env): + with working_dir(self.stage.path): + spack_env.set('FOAM_INST_DIR', os.path.abspath('.')) + + (arch, foam_compiler) = self.set_arch() + + run_env.set('FOAM_INST_DIR', self.prefix) + + def install(self, spec, prefix): + self.patch() + + env_openfoam = EnvironmentModifications() + self.get_openfoam_environment(env_openfoam) + env_openfoam.apply_modifications() + + if self.parallel: + os.environ['WM_NCOMPPROCS'] = str(self.make_jobs) \ + if self.make_jobs else str(multiprocessing.cpu_count()) + + # for key in sorted(os.environ): + # print("{0} = {1}".format(key, os.environ[key])) + + allwmake = Executable('./Allwmake') + allwmake() + + install_path = \ + join_path(self.prefix, + 'foam-extend-{0}'.format(self.version.up_to(2))) + + if '+source' in spec: + install_tree('src', join_path(install_path, 'src')) + + install_tree('lib', join_path(install_path, 'lib')) + install_tree('bin', join_path(install_path, 'bin')) + install_tree('applications', join_path(install_path, 'applications')) + install_tree('etc', join_path(install_path, 'etc')) + install_tree('wmake', join_path(install_path, 'wmake')) diff --git a/var/spack/repos/builtin/packages/openfoam-extend/package.py b/var/spack/repos/builtin/packages/openfoam-extend/package.py deleted file mode 100644 index 6af824df7e..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-extend/package.py +++ /dev/null @@ -1,262 +0,0 @@ -from spack import * -from spack.environment import * - -import multiprocessing -import subprocess -import re -import os - - -class OpenfoamExtend(Package): - """OpenFOAM-extend or foam-extend""" - - version('3.2', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.2') - version('3.1', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.1') - version('3.0', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.0') - - variant('paraview', default=False, description='Enable ParaFOAM') - variant('scotch', default=True, description='Activate Scotch as a possible decomposition library') - variant('ptscotch', default=True, description='Activate PT-Scotch as a possible decomposition library') - variant('metis', default=True, description='Activate Metis as a possible decomposition library') - variant('parmetis', default=True, description='Activate Parmetis as a possible decomposition library') - variant('parmgridgen', default=True, description='Activate Parmgridgen support') - - supported_compilers = {'clang': 'Clang', 'gcc': 'Gcc', 'intel': 'Icc'} - - depends_on('mpi') - depends_on('cmake') - depends_on('python') - depends_on('flex@:2.5.99') - depends_on('bison') - depends_on('m4') - depends_on('hwloc') - depends_on('zlib') - - depends_on('scotch ~ metis', when='~ptscotch+scotch') - depends_on('scotch ~ metis + mpi', when='+ptscotch') - depends_on('metis@5:', when='+metis') - depends_on('parmetis', when='+parmetis') - depends_on('parmgridgen', when='+parmgridgen') - - depends_on('paraview', when='+paraview') - depends_on('qt@:4', when='+paraview') - - def _get_env(self, command): - variable_set = re.compile(r'(.+?)=(.*)') - proc = subprocess.Popen(['bash', '-c', command], - stdout=subprocess.PIPE) - env = {} - for line in proc.stdout: - match_grp = variable_set.match(line) - if match_grp: - env[match_grp.group(1)] = match_grp.group(2) - return env - - def set_arch(self): - (sysname, nodename, release, version, machine) = os.uname() - - if self.compiler.name not in self.supported_compilers: - raise RuntimeError('{0} is not a supported compiler \ - to compile OpenFOAM'.format(self.compiler.name)) - - foam_compiler = self.supported_compilers[self.compiler.name] - if sysname == 'Linux': - arch = 'linux' - if foam_compiler == 'Clang': - raise RuntimeError('OS, compiler combinaison not\ - supported ({0} {1})'.format(sysname, foam_compiler)) - elif sysname == 'Darwin': - if machine == 'x86_64': - arch = 'darwinIntel' - if foam_compiler == 'Icc': - raise RuntimeError('OS, compiler combinaison not\ - supported ({0} {1})'.format(sysname, foam_compiler)) - else: - raise RuntimeError('{0} {1} is not a \ - supported architecture'.format(sysname, machine)) - - return (arch, foam_compiler) - - def get_openfoam_environment(self, env_openfoam): - env_before = self._get_env('env') - - with working_dir(self.stage.source_path): - env_after = self._get_env('source etc/bashrc && env') - - if 'PATH' in env_after: - del env_after['PATH'] - - if 'LD_LIBRARY_PATH' in env_after: - del env_after['LD_LIBRARY_PATH'] - - for key, value in env_after.iteritems(): - if key not in env_before or not value == env_before[key]: - env_openfoam.set(key, value) - - def patch(self): - if '+parmgridgen' in self.spec: - filter_file(r'-lIMlib -lMGridGen', - r'-limlib -lmgrid', - 'src/dbns/Make/options') - filter_file(r'-lMGridGen', - r'-lmgrid', - 'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options') - - (arch, foam_compiler) = self.set_arch() - - prefs_dict = { - 'compilerInstall': 'System', - 'WM_COMPILER': foam_compiler, - 'WM_ARCH_OPTION': '64', - 'WM_PRECISION_OPTION': 'DP', - 'WM_COMPILE_OPTION': 'SPACKOpt', - 'WM_MPLIB': 'SPACK', - - 'CMAKE_DIR': self.spec['cmake'].prefix, - 'CMAKE_BIN_DIR': self.spec['cmake'].prefix.bin, - 'PYTHON_DIR': self.spec['python'].prefix, - 'PYTHON_BIN_DIR': self.spec['python'].prefix.bin, - - 'FLEX_SYSTEM': 1, - 'FLEX_DIR': self.spec['flex'].prefix, - - 'BISON_SYSTEM': 1, - 'BISON_DIR': self.spec['flex'].prefix, - - 'M4_SYSTEM': 1, - 'M4_DIR': self.spec['m4'].prefix, - - 'ZLIB_SYSTEM': 1, - 'ZLIB_DIR': self.spec['zlib'].prefix, - - 'HWLOC_SYSTEM': 1, - 'HWLOC_DIR': self.spec['hwloc'].prefix, - 'HWLOC_BIN_DIR': self.spec['hwloc'].prefix.bin, - } - - if '+scotch' in self.spec or '+ptscotch' in self.spec: - prefs_dict['SCOTCH_SYSTEM'] = 1 - prefs_dict['SCOTCH_DIR'] = self.spec['scotch'].prefix - prefs_dict['SCOTCH_BIN_DIR'] = self.spec['scotch'].prefix.bin - prefs_dict['SCOTCH_LIB_DIR'] = self.spec['scotch'].prefix.lib - prefs_dict['SCOTCH_INCLUDE_DIR'] = \ - self.spec['scotch'].prefix.include - - if '+metis' in self.spec: - prefs_dict['METIS_SYSTEM'] = 1 - prefs_dict['METIS_DIR'] = self.spec['metis'].prefix - prefs_dict['METIS_BIN_DIR'] = self.spec['metis'].prefix.bin - prefs_dict['METIS_LIB_DIR'] = self.spec['metis'].prefix.lib - prefs_dict['METIS_INCLUDE_DIR'] = self.spec['metis'].prefix.include - - if '+parmetis' in self.spec: - prefs_dict['PARMETIS_SYSTEM'] = 1 - prefs_dict['PARMETIS_DIR'] = self.spec['parmetis'].prefix - prefs_dict['PARMETIS_BIN_DIR'] = self.spec['parmetis'].prefix.bin - prefs_dict['PARMETIS_LIB_DIR'] = self.spec['parmetis'].prefix.lib - prefs_dict['PARMETIS_INCLUDE_DIR'] = \ - self.spec['parmetis'].prefix.include - - if '+parmgridgen' in self.spec: - prefs_dict['PARMGRIDGEN_SYSTEM'] = 1 - prefs_dict['PARMGRIDGEN_DIR'] = self.spec['parmgridgen'].prefix - prefs_dict['PARMGRIDGEN_BIN_DIR'] = \ - self.spec['parmgridgen'].prefix.bin - prefs_dict['PARMGRIDGEN_LIB_DIR'] = \ - self.spec['parmgridgen'].prefix.lib - prefs_dict['PARMGRIDGEN_INCLUDE_DIR'] = \ - self.spec['parmgridgen'].prefix.include - - if '+paraview' in self.spec: - prefs_dict['PARAVIEW_SYSTEM'] = 1 - prefs_dict['PARAVIEW_DIR'] = self.spec['paraview'].prefix, - prefs_dict['PARAVIEW_BIN_DIR'] = self.spec['paraview'].prefix.bin, - prefs_dict['QT_SYSTEM'] = 1 - prefs_dict['QT_DIR'] = self.spec['qt'].prefix, - prefs_dict['QT_BIN_DIR'] = self.spec['qt'].prefix.bin, - - with working_dir('.'): - with open("etc/prefs.sh", "w") as fh: - for key in sorted(prefs_dict): - fh.write('export {0}={1}\n'.format(key, prefs_dict[key])) - - with open("etc/prefs.csh", "w") as fh: - for key in sorted(prefs_dict): - fh.write('setenv {0}={1}\n'.format(key, prefs_dict[key])) - - mpi_info = [ - 'PFLAGS = -DOMPI_SKIP_MPICXX -DMPICH_IGNORE_CXX_SEEK', - 'PINC = -I{0}'.format(self.spec['mpi'].prefix.include), - 'PLIBS = -L{0} -lmpi'.format(self.spec['mpi'].prefix.lib) - ] - - arch_path = ''.join([arch, prefs_dict['WM_ARCH_OPTION'], - foam_compiler]) - option_path = ''.join([arch_path, - prefs_dict['WM_PRECISION_OPTION'], - prefs_dict['WM_COMPILE_OPTION']]) - rule_path = join_path("wmake", "rules", arch_path) - build_path = join_path(self.stage.source_path, 'lib', option_path) - install_path = \ - join_path(self.prefix, - 'foam-extend-{0}'.format(self.version.up_to(2)), - option_path) - - rpaths_foam = ' '.join([ - '{0}{1}'.format(self.compiler.cxx_rpath_arg, - install_path), - '{0}{1}'.format(self.compiler.cxx_rpath_arg, - build_path) - ]) - - compiler_flags = { - 'DBUG': rpaths_foam, - 'OPT': '-O3', - } - - with working_dir(rule_path): - with open('mplibSPACK', "w") as fh: - fh.write('\n'.join(mpi_info)) - - for comp in ['c', 'c++']: - with open('{0}SPACKOpt'.format(comp), "w") as fh: - for key, val in compiler_flags.iteritems(): - fh.write('{0}{1} = {2}\n'.format(comp, key, val)) - - def setup_environment(self, spack_env, run_env): - with working_dir(self.stage.path): - spack_env.set('FOAM_INST_DIR', os.path.abspath('.')) - - (arch, foam_compiler) = self.set_arch() - - run_env.set('FOAM_INST_DIR', self.prefix) - - def install(self, spec, prefix): - self.patch() - - env_openfoam = EnvironmentModifications() - self.get_openfoam_environment(env_openfoam) - env_openfoam.apply_modifications() - - if self.parallel: - os.environ['WM_NCOMPPROCS'] = str(self.make_jobs) \ - if self.make_jobs else str(multiprocessing.cpu_count()) - - # for key in sorted(os.environ): - # print("{0} = {1}".format(key, os.environ[key])) - - allwmake = Executable('./Allwmake') - allwmake() - - install_path = \ - join_path(self.prefix, - 'foam-extend-{0}'.format(self.version.up_to(2))) - - if '+source' in spec: - install_tree('src', join_path(install_path, 'src')) - - install_tree('lib', join_path(install_path, 'lib')) - install_tree('bin', join_path(install_path, 'bin')) - install_tree('applications', join_path(install_path, 'applications')) - install_tree('etc', join_path(install_path, 'etc')) - install_tree('wmake', join_path(install_path, 'wmake')) -- cgit v1.2.3-70-g09d2 From 4122ecbc804706b93c226f77720a0334fc020a02 Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Sun, 22 May 2016 18:55:29 +0200 Subject: First try at OpenFOAM-extend --- .../builtin/packages/openfoam-extend/package.py | 262 +++++++++++++++++++++ .../repos/builtin/packages/parmgridgen/package.py | 75 ++++++ var/spack/repos/builtin/packages/scotch/package.py | 12 +- 3 files changed, 342 insertions(+), 7 deletions(-) create mode 100644 var/spack/repos/builtin/packages/openfoam-extend/package.py create mode 100644 var/spack/repos/builtin/packages/parmgridgen/package.py (limited to 'var') diff --git a/var/spack/repos/builtin/packages/openfoam-extend/package.py b/var/spack/repos/builtin/packages/openfoam-extend/package.py new file mode 100644 index 0000000000..6af824df7e --- /dev/null +++ b/var/spack/repos/builtin/packages/openfoam-extend/package.py @@ -0,0 +1,262 @@ +from spack import * +from spack.environment import * + +import multiprocessing +import subprocess +import re +import os + + +class OpenfoamExtend(Package): + """OpenFOAM-extend or foam-extend""" + + version('3.2', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.2') + version('3.1', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.1') + version('3.0', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.0') + + variant('paraview', default=False, description='Enable ParaFOAM') + variant('scotch', default=True, description='Activate Scotch as a possible decomposition library') + variant('ptscotch', default=True, description='Activate PT-Scotch as a possible decomposition library') + variant('metis', default=True, description='Activate Metis as a possible decomposition library') + variant('parmetis', default=True, description='Activate Parmetis as a possible decomposition library') + variant('parmgridgen', default=True, description='Activate Parmgridgen support') + + supported_compilers = {'clang': 'Clang', 'gcc': 'Gcc', 'intel': 'Icc'} + + depends_on('mpi') + depends_on('cmake') + depends_on('python') + depends_on('flex@:2.5.99') + depends_on('bison') + depends_on('m4') + depends_on('hwloc') + depends_on('zlib') + + depends_on('scotch ~ metis', when='~ptscotch+scotch') + depends_on('scotch ~ metis + mpi', when='+ptscotch') + depends_on('metis@5:', when='+metis') + depends_on('parmetis', when='+parmetis') + depends_on('parmgridgen', when='+parmgridgen') + + depends_on('paraview', when='+paraview') + depends_on('qt@:4', when='+paraview') + + def _get_env(self, command): + variable_set = re.compile(r'(.+?)=(.*)') + proc = subprocess.Popen(['bash', '-c', command], + stdout=subprocess.PIPE) + env = {} + for line in proc.stdout: + match_grp = variable_set.match(line) + if match_grp: + env[match_grp.group(1)] = match_grp.group(2) + return env + + def set_arch(self): + (sysname, nodename, release, version, machine) = os.uname() + + if self.compiler.name not in self.supported_compilers: + raise RuntimeError('{0} is not a supported compiler \ + to compile OpenFOAM'.format(self.compiler.name)) + + foam_compiler = self.supported_compilers[self.compiler.name] + if sysname == 'Linux': + arch = 'linux' + if foam_compiler == 'Clang': + raise RuntimeError('OS, compiler combinaison not\ + supported ({0} {1})'.format(sysname, foam_compiler)) + elif sysname == 'Darwin': + if machine == 'x86_64': + arch = 'darwinIntel' + if foam_compiler == 'Icc': + raise RuntimeError('OS, compiler combinaison not\ + supported ({0} {1})'.format(sysname, foam_compiler)) + else: + raise RuntimeError('{0} {1} is not a \ + supported architecture'.format(sysname, machine)) + + return (arch, foam_compiler) + + def get_openfoam_environment(self, env_openfoam): + env_before = self._get_env('env') + + with working_dir(self.stage.source_path): + env_after = self._get_env('source etc/bashrc && env') + + if 'PATH' in env_after: + del env_after['PATH'] + + if 'LD_LIBRARY_PATH' in env_after: + del env_after['LD_LIBRARY_PATH'] + + for key, value in env_after.iteritems(): + if key not in env_before or not value == env_before[key]: + env_openfoam.set(key, value) + + def patch(self): + if '+parmgridgen' in self.spec: + filter_file(r'-lIMlib -lMGridGen', + r'-limlib -lmgrid', + 'src/dbns/Make/options') + filter_file(r'-lMGridGen', + r'-lmgrid', + 'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options') + + (arch, foam_compiler) = self.set_arch() + + prefs_dict = { + 'compilerInstall': 'System', + 'WM_COMPILER': foam_compiler, + 'WM_ARCH_OPTION': '64', + 'WM_PRECISION_OPTION': 'DP', + 'WM_COMPILE_OPTION': 'SPACKOpt', + 'WM_MPLIB': 'SPACK', + + 'CMAKE_DIR': self.spec['cmake'].prefix, + 'CMAKE_BIN_DIR': self.spec['cmake'].prefix.bin, + 'PYTHON_DIR': self.spec['python'].prefix, + 'PYTHON_BIN_DIR': self.spec['python'].prefix.bin, + + 'FLEX_SYSTEM': 1, + 'FLEX_DIR': self.spec['flex'].prefix, + + 'BISON_SYSTEM': 1, + 'BISON_DIR': self.spec['flex'].prefix, + + 'M4_SYSTEM': 1, + 'M4_DIR': self.spec['m4'].prefix, + + 'ZLIB_SYSTEM': 1, + 'ZLIB_DIR': self.spec['zlib'].prefix, + + 'HWLOC_SYSTEM': 1, + 'HWLOC_DIR': self.spec['hwloc'].prefix, + 'HWLOC_BIN_DIR': self.spec['hwloc'].prefix.bin, + } + + if '+scotch' in self.spec or '+ptscotch' in self.spec: + prefs_dict['SCOTCH_SYSTEM'] = 1 + prefs_dict['SCOTCH_DIR'] = self.spec['scotch'].prefix + prefs_dict['SCOTCH_BIN_DIR'] = self.spec['scotch'].prefix.bin + prefs_dict['SCOTCH_LIB_DIR'] = self.spec['scotch'].prefix.lib + prefs_dict['SCOTCH_INCLUDE_DIR'] = \ + self.spec['scotch'].prefix.include + + if '+metis' in self.spec: + prefs_dict['METIS_SYSTEM'] = 1 + prefs_dict['METIS_DIR'] = self.spec['metis'].prefix + prefs_dict['METIS_BIN_DIR'] = self.spec['metis'].prefix.bin + prefs_dict['METIS_LIB_DIR'] = self.spec['metis'].prefix.lib + prefs_dict['METIS_INCLUDE_DIR'] = self.spec['metis'].prefix.include + + if '+parmetis' in self.spec: + prefs_dict['PARMETIS_SYSTEM'] = 1 + prefs_dict['PARMETIS_DIR'] = self.spec['parmetis'].prefix + prefs_dict['PARMETIS_BIN_DIR'] = self.spec['parmetis'].prefix.bin + prefs_dict['PARMETIS_LIB_DIR'] = self.spec['parmetis'].prefix.lib + prefs_dict['PARMETIS_INCLUDE_DIR'] = \ + self.spec['parmetis'].prefix.include + + if '+parmgridgen' in self.spec: + prefs_dict['PARMGRIDGEN_SYSTEM'] = 1 + prefs_dict['PARMGRIDGEN_DIR'] = self.spec['parmgridgen'].prefix + prefs_dict['PARMGRIDGEN_BIN_DIR'] = \ + self.spec['parmgridgen'].prefix.bin + prefs_dict['PARMGRIDGEN_LIB_DIR'] = \ + self.spec['parmgridgen'].prefix.lib + prefs_dict['PARMGRIDGEN_INCLUDE_DIR'] = \ + self.spec['parmgridgen'].prefix.include + + if '+paraview' in self.spec: + prefs_dict['PARAVIEW_SYSTEM'] = 1 + prefs_dict['PARAVIEW_DIR'] = self.spec['paraview'].prefix, + prefs_dict['PARAVIEW_BIN_DIR'] = self.spec['paraview'].prefix.bin, + prefs_dict['QT_SYSTEM'] = 1 + prefs_dict['QT_DIR'] = self.spec['qt'].prefix, + prefs_dict['QT_BIN_DIR'] = self.spec['qt'].prefix.bin, + + with working_dir('.'): + with open("etc/prefs.sh", "w") as fh: + for key in sorted(prefs_dict): + fh.write('export {0}={1}\n'.format(key, prefs_dict[key])) + + with open("etc/prefs.csh", "w") as fh: + for key in sorted(prefs_dict): + fh.write('setenv {0}={1}\n'.format(key, prefs_dict[key])) + + mpi_info = [ + 'PFLAGS = -DOMPI_SKIP_MPICXX -DMPICH_IGNORE_CXX_SEEK', + 'PINC = -I{0}'.format(self.spec['mpi'].prefix.include), + 'PLIBS = -L{0} -lmpi'.format(self.spec['mpi'].prefix.lib) + ] + + arch_path = ''.join([arch, prefs_dict['WM_ARCH_OPTION'], + foam_compiler]) + option_path = ''.join([arch_path, + prefs_dict['WM_PRECISION_OPTION'], + prefs_dict['WM_COMPILE_OPTION']]) + rule_path = join_path("wmake", "rules", arch_path) + build_path = join_path(self.stage.source_path, 'lib', option_path) + install_path = \ + join_path(self.prefix, + 'foam-extend-{0}'.format(self.version.up_to(2)), + option_path) + + rpaths_foam = ' '.join([ + '{0}{1}'.format(self.compiler.cxx_rpath_arg, + install_path), + '{0}{1}'.format(self.compiler.cxx_rpath_arg, + build_path) + ]) + + compiler_flags = { + 'DBUG': rpaths_foam, + 'OPT': '-O3', + } + + with working_dir(rule_path): + with open('mplibSPACK', "w") as fh: + fh.write('\n'.join(mpi_info)) + + for comp in ['c', 'c++']: + with open('{0}SPACKOpt'.format(comp), "w") as fh: + for key, val in compiler_flags.iteritems(): + fh.write('{0}{1} = {2}\n'.format(comp, key, val)) + + def setup_environment(self, spack_env, run_env): + with working_dir(self.stage.path): + spack_env.set('FOAM_INST_DIR', os.path.abspath('.')) + + (arch, foam_compiler) = self.set_arch() + + run_env.set('FOAM_INST_DIR', self.prefix) + + def install(self, spec, prefix): + self.patch() + + env_openfoam = EnvironmentModifications() + self.get_openfoam_environment(env_openfoam) + env_openfoam.apply_modifications() + + if self.parallel: + os.environ['WM_NCOMPPROCS'] = str(self.make_jobs) \ + if self.make_jobs else str(multiprocessing.cpu_count()) + + # for key in sorted(os.environ): + # print("{0} = {1}".format(key, os.environ[key])) + + allwmake = Executable('./Allwmake') + allwmake() + + install_path = \ + join_path(self.prefix, + 'foam-extend-{0}'.format(self.version.up_to(2))) + + if '+source' in spec: + install_tree('src', join_path(install_path, 'src')) + + install_tree('lib', join_path(install_path, 'lib')) + install_tree('bin', join_path(install_path, 'bin')) + install_tree('applications', join_path(install_path, 'applications')) + install_tree('etc', join_path(install_path, 'etc')) + install_tree('wmake', join_path(install_path, 'wmake')) diff --git a/var/spack/repos/builtin/packages/parmgridgen/package.py b/var/spack/repos/builtin/packages/parmgridgen/package.py new file mode 100644 index 0000000000..11b19f2ec2 --- /dev/null +++ b/var/spack/repos/builtin/packages/parmgridgen/package.py @@ -0,0 +1,75 @@ +############################################################################## +# 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 Parmgridgen(Package): + """MGRIDGEN is a serial library written entirely in ANSI C that implements + (serial) algorithms for obtaining a sequence of successive coarse grids + that are well-suited for geometric multigrid methods. + ParMGridGen is the parallel version of MGridGen + """ + + homepage = "http://www-users.cs.umn.edu/~moulitsa/software.html" + url = "http://www-users.cs.umn.edu/~moulitsa/download/ParMGridGen-1.0.tar.gz" + + version('1.0', '2872fa95b7fb91d6bd525490eed62038') + + depends_on('mpi') + + def install(self, spec, prefix): + make_opts = [ + 'make=make', + 'COPTIONS=-fPIC', + 'LDOPTIONS=-fPIC', + 'CC={0}'.format(self.compiler.cc), + 'PARCC={0}'.format(self.spec['mpi'].mpicc), + 'LD={0}'.format(self.compiler.cc), + 'PARLD={0}'.format(self.spec['mpi'].mpicc), + 'LIBDIR=-L../..', + 'PARLIBS=-L../../ -lparmgrid -lmgrid -lm', + 'LIBS=-L../../ -lmgrid -lm', + 'parallel' + ] + + make(*make_opts, parallel=False) + + include_path = join_path(self.prefix, 'include') + lib_path = join_path(self.prefix, 'lib') + bin_path = join_path(self.prefix, 'bin') + + mkdirp(include_path, lib_path, bin_path) + + install("mgridgen.h", include_path) + install("parmgridgen.h", include_path) + + install("MGridGen/IMlib/libIMlib.a", + join_path(lib_path, 'libimlib.a')) + install("libmgrid.a", lib_path) + install("libparmgrid.a", lib_path) + + install("mgridgen", bin_path) + install("parmgridgen", bin_path) diff --git a/var/spack/repos/builtin/packages/scotch/package.py b/var/spack/repos/builtin/packages/scotch/package.py index 3c2b4993ac..2f6e42c439 100644 --- a/var/spack/repos/builtin/packages/scotch/package.py +++ b/var/spack/repos/builtin/packages/scotch/package.py @@ -171,15 +171,13 @@ class Scotch(Package): target == 'ptscotch')) make(target, parallel=can_make_parallel) - # todo change this to take into account darwin systems - lib_ext = '.so' if '+shared' in self.spec else '.a' + lib_ext = dso_suffix if '+shared' in self.spec else 'a' # It seams easier to remove metis wrappers from the folder that will be # installed than to tweak the Makefiles if '+metis' not in self.spec: with working_dir('lib'): - lib_ext = '.so' if '+shared' in self.spec else '.a' - force_remove('libscotchmetis{0}'.format(lib_ext)) - force_remove('libptscotchparmetis{0}'.format(lib_ext)) + force_remove('libscotchmetis.{0}'.format(lib_ext)) + force_remove('libptscotchparmetis.{0}'.format(lib_ext)) with working_dir('include'): force_remove('metis.h') @@ -187,8 +185,8 @@ class Scotch(Package): if '~esmumps' in self.spec and self.spec.version < Version('6.0.0'): with working_dir('lib'): - force_remove('libesmumps{0}'.format(lib_ext)) - force_remove('libptesmumps{0}'.format(lib_ext)) + force_remove('libesmumps.{0}'.format(lib_ext)) + force_remove('libptesmumps.{0}'.format(lib_ext)) with working_dir('include'): force_remove('esmumps.h') -- cgit v1.2.3-70-g09d2 From 08c8d1d1f7cbae2449dc56b0aafc390247b2be83 Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Mon, 30 May 2016 15:46:39 +0200 Subject: limiting package to foam-extend to start --- .../repos/builtin/packages/foam-extend/package.py | 263 +++++++++++++++++++++ .../builtin/packages/openfoam-extend/package.py | 262 -------------------- 2 files changed, 263 insertions(+), 262 deletions(-) create mode 100644 var/spack/repos/builtin/packages/foam-extend/package.py delete mode 100644 var/spack/repos/builtin/packages/openfoam-extend/package.py (limited to 'var') diff --git a/var/spack/repos/builtin/packages/foam-extend/package.py b/var/spack/repos/builtin/packages/foam-extend/package.py new file mode 100644 index 0000000000..4bbb065d8b --- /dev/null +++ b/var/spack/repos/builtin/packages/foam-extend/package.py @@ -0,0 +1,263 @@ +from spack import * +from spack.environment import * + +import multiprocessing +import subprocess +import re +import os + + +class FoamExtend(Package): + """The foam-extend project is a fork of the OpenFOAM open source library + for Computational Fluid Dynamics (CFD).""" + + version('3.2', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.2') + version('3.1', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.1') + version('3.0', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.0') + + variant('paraview', default=False, description='Enable ParaFOAM') + variant('scotch', default=True, description='Activate Scotch as a possible decomposition library') + variant('ptscotch', default=True, description='Activate PT-Scotch as a possible decomposition library') + variant('metis', default=True, description='Activate Metis as a possible decomposition library') + variant('parmetis', default=True, description='Activate Parmetis as a possible decomposition library') + variant('parmgridgen', default=True, description='Activate Parmgridgen support') + + supported_compilers = {'clang': 'Clang', 'gcc': 'Gcc', 'intel': 'Icc'} + + depends_on('mpi') + depends_on('cmake') + depends_on('python') + depends_on('flex@:2.5.99') + depends_on('bison') + depends_on('m4') + depends_on('hwloc') + depends_on('zlib') + + depends_on('scotch ~ metis', when='~ptscotch+scotch') + depends_on('scotch ~ metis + mpi', when='+ptscotch') + depends_on('metis@5:', when='+metis') + depends_on('parmetis', when='+parmetis') + depends_on('parmgridgen', when='+parmgridgen') + + depends_on('paraview', when='+paraview') + depends_on('qt@:4', when='+paraview') + + def _get_env(self, command): + variable_set = re.compile(r'(.+?)=(.*)') + proc = subprocess.Popen(['bash', '-c', command], + stdout=subprocess.PIPE) + env = {} + for line in proc.stdout: + match_grp = variable_set.match(line) + if match_grp: + env[match_grp.group(1)] = match_grp.group(2) + return env + + def set_arch(self): + (sysname, nodename, release, version, machine) = os.uname() + + if self.compiler.name not in self.supported_compilers: + raise RuntimeError('{0} is not a supported compiler \ + to compile OpenFOAM'.format(self.compiler.name)) + + foam_compiler = self.supported_compilers[self.compiler.name] + if sysname == 'Linux': + arch = 'linux' + if foam_compiler == 'Clang': + raise RuntimeError('OS, compiler combinaison not\ + supported ({0} {1})'.format(sysname, foam_compiler)) + elif sysname == 'Darwin': + if machine == 'x86_64': + arch = 'darwinIntel' + if foam_compiler == 'Icc': + raise RuntimeError('OS, compiler combinaison not\ + supported ({0} {1})'.format(sysname, foam_compiler)) + else: + raise RuntimeError('{0} {1} is not a \ + supported architecture'.format(sysname, machine)) + + return (arch, foam_compiler) + + def get_openfoam_environment(self, env_openfoam): + env_before = self._get_env('env') + + with working_dir(self.stage.source_path): + env_after = self._get_env('source etc/bashrc && env') + + if 'PATH' in env_after: + del env_after['PATH'] + + if 'LD_LIBRARY_PATH' in env_after: + del env_after['LD_LIBRARY_PATH'] + + for key, value in env_after.iteritems(): + if key not in env_before or not value == env_before[key]: + env_openfoam.set(key, value) + + def patch(self): + if '+parmgridgen' in self.spec: + filter_file(r'-lIMlib -lMGridGen', + r'-limlib -lmgrid', + 'src/dbns/Make/options') + filter_file(r'-lMGridGen', + r'-lmgrid', + 'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options') + + (arch, foam_compiler) = self.set_arch() + + prefs_dict = { + 'compilerInstall': 'System', + 'WM_COMPILER': foam_compiler, + 'WM_ARCH_OPTION': '64', + 'WM_PRECISION_OPTION': 'DP', + 'WM_COMPILE_OPTION': 'SPACKOpt', + 'WM_MPLIB': 'SPACK', + + 'CMAKE_DIR': self.spec['cmake'].prefix, + 'CMAKE_BIN_DIR': self.spec['cmake'].prefix.bin, + 'PYTHON_DIR': self.spec['python'].prefix, + 'PYTHON_BIN_DIR': self.spec['python'].prefix.bin, + + 'FLEX_SYSTEM': 1, + 'FLEX_DIR': self.spec['flex'].prefix, + + 'BISON_SYSTEM': 1, + 'BISON_DIR': self.spec['flex'].prefix, + + 'M4_SYSTEM': 1, + 'M4_DIR': self.spec['m4'].prefix, + + 'ZLIB_SYSTEM': 1, + 'ZLIB_DIR': self.spec['zlib'].prefix, + + 'HWLOC_SYSTEM': 1, + 'HWLOC_DIR': self.spec['hwloc'].prefix, + 'HWLOC_BIN_DIR': self.spec['hwloc'].prefix.bin, + } + + if '+scotch' in self.spec or '+ptscotch' in self.spec: + prefs_dict['SCOTCH_SYSTEM'] = 1 + prefs_dict['SCOTCH_DIR'] = self.spec['scotch'].prefix + prefs_dict['SCOTCH_BIN_DIR'] = self.spec['scotch'].prefix.bin + prefs_dict['SCOTCH_LIB_DIR'] = self.spec['scotch'].prefix.lib + prefs_dict['SCOTCH_INCLUDE_DIR'] = \ + self.spec['scotch'].prefix.include + + if '+metis' in self.spec: + prefs_dict['METIS_SYSTEM'] = 1 + prefs_dict['METIS_DIR'] = self.spec['metis'].prefix + prefs_dict['METIS_BIN_DIR'] = self.spec['metis'].prefix.bin + prefs_dict['METIS_LIB_DIR'] = self.spec['metis'].prefix.lib + prefs_dict['METIS_INCLUDE_DIR'] = self.spec['metis'].prefix.include + + if '+parmetis' in self.spec: + prefs_dict['PARMETIS_SYSTEM'] = 1 + prefs_dict['PARMETIS_DIR'] = self.spec['parmetis'].prefix + prefs_dict['PARMETIS_BIN_DIR'] = self.spec['parmetis'].prefix.bin + prefs_dict['PARMETIS_LIB_DIR'] = self.spec['parmetis'].prefix.lib + prefs_dict['PARMETIS_INCLUDE_DIR'] = \ + self.spec['parmetis'].prefix.include + + if '+parmgridgen' in self.spec: + prefs_dict['PARMGRIDGEN_SYSTEM'] = 1 + prefs_dict['PARMGRIDGEN_DIR'] = self.spec['parmgridgen'].prefix + prefs_dict['PARMGRIDGEN_BIN_DIR'] = \ + self.spec['parmgridgen'].prefix.bin + prefs_dict['PARMGRIDGEN_LIB_DIR'] = \ + self.spec['parmgridgen'].prefix.lib + prefs_dict['PARMGRIDGEN_INCLUDE_DIR'] = \ + self.spec['parmgridgen'].prefix.include + + if '+paraview' in self.spec: + prefs_dict['PARAVIEW_SYSTEM'] = 1 + prefs_dict['PARAVIEW_DIR'] = self.spec['paraview'].prefix, + prefs_dict['PARAVIEW_BIN_DIR'] = self.spec['paraview'].prefix.bin, + prefs_dict['QT_SYSTEM'] = 1 + prefs_dict['QT_DIR'] = self.spec['qt'].prefix, + prefs_dict['QT_BIN_DIR'] = self.spec['qt'].prefix.bin, + + with working_dir('.'): + with open("etc/prefs.sh", "w") as fh: + for key in sorted(prefs_dict): + fh.write('export {0}={1}\n'.format(key, prefs_dict[key])) + + with open("etc/prefs.csh", "w") as fh: + for key in sorted(prefs_dict): + fh.write('setenv {0}={1}\n'.format(key, prefs_dict[key])) + + mpi_info = [ + 'PFLAGS = -DOMPI_SKIP_MPICXX -DMPICH_IGNORE_CXX_SEEK', + 'PINC = -I{0}'.format(self.spec['mpi'].prefix.include), + 'PLIBS = -L{0} -lmpi'.format(self.spec['mpi'].prefix.lib) + ] + + arch_path = ''.join([arch, prefs_dict['WM_ARCH_OPTION'], + foam_compiler]) + option_path = ''.join([arch_path, + prefs_dict['WM_PRECISION_OPTION'], + prefs_dict['WM_COMPILE_OPTION']]) + rule_path = join_path("wmake", "rules", arch_path) + build_path = join_path(self.stage.source_path, 'lib', option_path) + install_path = \ + join_path(self.prefix, + 'foam-extend-{0}'.format(self.version.up_to(2)), + option_path) + + rpaths_foam = ' '.join([ + '{0}{1}'.format(self.compiler.cxx_rpath_arg, + install_path), + '{0}{1}'.format(self.compiler.cxx_rpath_arg, + build_path) + ]) + + compiler_flags = { + 'DBUG': rpaths_foam, + 'OPT': '-O3', + } + + with working_dir(rule_path): + with open('mplibSPACK', "w") as fh: + fh.write('\n'.join(mpi_info)) + + for comp in ['c', 'c++']: + with open('{0}SPACKOpt'.format(comp), "w") as fh: + for key, val in compiler_flags.iteritems(): + fh.write('{0}{1} = {2}\n'.format(comp, key, val)) + + def setup_environment(self, spack_env, run_env): + with working_dir(self.stage.path): + spack_env.set('FOAM_INST_DIR', os.path.abspath('.')) + + (arch, foam_compiler) = self.set_arch() + + run_env.set('FOAM_INST_DIR', self.prefix) + + def install(self, spec, prefix): + self.patch() + + env_openfoam = EnvironmentModifications() + self.get_openfoam_environment(env_openfoam) + env_openfoam.apply_modifications() + + if self.parallel: + os.environ['WM_NCOMPPROCS'] = str(self.make_jobs) \ + if self.make_jobs else str(multiprocessing.cpu_count()) + + # for key in sorted(os.environ): + # print("{0} = {1}".format(key, os.environ[key])) + + allwmake = Executable('./Allwmake') + allwmake() + + install_path = \ + join_path(self.prefix, + 'foam-extend-{0}'.format(self.version.up_to(2))) + + if '+source' in spec: + install_tree('src', join_path(install_path, 'src')) + + install_tree('lib', join_path(install_path, 'lib')) + install_tree('bin', join_path(install_path, 'bin')) + install_tree('applications', join_path(install_path, 'applications')) + install_tree('etc', join_path(install_path, 'etc')) + install_tree('wmake', join_path(install_path, 'wmake')) diff --git a/var/spack/repos/builtin/packages/openfoam-extend/package.py b/var/spack/repos/builtin/packages/openfoam-extend/package.py deleted file mode 100644 index 6af824df7e..0000000000 --- a/var/spack/repos/builtin/packages/openfoam-extend/package.py +++ /dev/null @@ -1,262 +0,0 @@ -from spack import * -from spack.environment import * - -import multiprocessing -import subprocess -import re -import os - - -class OpenfoamExtend(Package): - """OpenFOAM-extend or foam-extend""" - - version('3.2', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.2') - version('3.1', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.1') - version('3.0', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.0') - - variant('paraview', default=False, description='Enable ParaFOAM') - variant('scotch', default=True, description='Activate Scotch as a possible decomposition library') - variant('ptscotch', default=True, description='Activate PT-Scotch as a possible decomposition library') - variant('metis', default=True, description='Activate Metis as a possible decomposition library') - variant('parmetis', default=True, description='Activate Parmetis as a possible decomposition library') - variant('parmgridgen', default=True, description='Activate Parmgridgen support') - - supported_compilers = {'clang': 'Clang', 'gcc': 'Gcc', 'intel': 'Icc'} - - depends_on('mpi') - depends_on('cmake') - depends_on('python') - depends_on('flex@:2.5.99') - depends_on('bison') - depends_on('m4') - depends_on('hwloc') - depends_on('zlib') - - depends_on('scotch ~ metis', when='~ptscotch+scotch') - depends_on('scotch ~ metis + mpi', when='+ptscotch') - depends_on('metis@5:', when='+metis') - depends_on('parmetis', when='+parmetis') - depends_on('parmgridgen', when='+parmgridgen') - - depends_on('paraview', when='+paraview') - depends_on('qt@:4', when='+paraview') - - def _get_env(self, command): - variable_set = re.compile(r'(.+?)=(.*)') - proc = subprocess.Popen(['bash', '-c', command], - stdout=subprocess.PIPE) - env = {} - for line in proc.stdout: - match_grp = variable_set.match(line) - if match_grp: - env[match_grp.group(1)] = match_grp.group(2) - return env - - def set_arch(self): - (sysname, nodename, release, version, machine) = os.uname() - - if self.compiler.name not in self.supported_compilers: - raise RuntimeError('{0} is not a supported compiler \ - to compile OpenFOAM'.format(self.compiler.name)) - - foam_compiler = self.supported_compilers[self.compiler.name] - if sysname == 'Linux': - arch = 'linux' - if foam_compiler == 'Clang': - raise RuntimeError('OS, compiler combinaison not\ - supported ({0} {1})'.format(sysname, foam_compiler)) - elif sysname == 'Darwin': - if machine == 'x86_64': - arch = 'darwinIntel' - if foam_compiler == 'Icc': - raise RuntimeError('OS, compiler combinaison not\ - supported ({0} {1})'.format(sysname, foam_compiler)) - else: - raise RuntimeError('{0} {1} is not a \ - supported architecture'.format(sysname, machine)) - - return (arch, foam_compiler) - - def get_openfoam_environment(self, env_openfoam): - env_before = self._get_env('env') - - with working_dir(self.stage.source_path): - env_after = self._get_env('source etc/bashrc && env') - - if 'PATH' in env_after: - del env_after['PATH'] - - if 'LD_LIBRARY_PATH' in env_after: - del env_after['LD_LIBRARY_PATH'] - - for key, value in env_after.iteritems(): - if key not in env_before or not value == env_before[key]: - env_openfoam.set(key, value) - - def patch(self): - if '+parmgridgen' in self.spec: - filter_file(r'-lIMlib -lMGridGen', - r'-limlib -lmgrid', - 'src/dbns/Make/options') - filter_file(r'-lMGridGen', - r'-lmgrid', - 'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options') - - (arch, foam_compiler) = self.set_arch() - - prefs_dict = { - 'compilerInstall': 'System', - 'WM_COMPILER': foam_compiler, - 'WM_ARCH_OPTION': '64', - 'WM_PRECISION_OPTION': 'DP', - 'WM_COMPILE_OPTION': 'SPACKOpt', - 'WM_MPLIB': 'SPACK', - - 'CMAKE_DIR': self.spec['cmake'].prefix, - 'CMAKE_BIN_DIR': self.spec['cmake'].prefix.bin, - 'PYTHON_DIR': self.spec['python'].prefix, - 'PYTHON_BIN_DIR': self.spec['python'].prefix.bin, - - 'FLEX_SYSTEM': 1, - 'FLEX_DIR': self.spec['flex'].prefix, - - 'BISON_SYSTEM': 1, - 'BISON_DIR': self.spec['flex'].prefix, - - 'M4_SYSTEM': 1, - 'M4_DIR': self.spec['m4'].prefix, - - 'ZLIB_SYSTEM': 1, - 'ZLIB_DIR': self.spec['zlib'].prefix, - - 'HWLOC_SYSTEM': 1, - 'HWLOC_DIR': self.spec['hwloc'].prefix, - 'HWLOC_BIN_DIR': self.spec['hwloc'].prefix.bin, - } - - if '+scotch' in self.spec or '+ptscotch' in self.spec: - prefs_dict['SCOTCH_SYSTEM'] = 1 - prefs_dict['SCOTCH_DIR'] = self.spec['scotch'].prefix - prefs_dict['SCOTCH_BIN_DIR'] = self.spec['scotch'].prefix.bin - prefs_dict['SCOTCH_LIB_DIR'] = self.spec['scotch'].prefix.lib - prefs_dict['SCOTCH_INCLUDE_DIR'] = \ - self.spec['scotch'].prefix.include - - if '+metis' in self.spec: - prefs_dict['METIS_SYSTEM'] = 1 - prefs_dict['METIS_DIR'] = self.spec['metis'].prefix - prefs_dict['METIS_BIN_DIR'] = self.spec['metis'].prefix.bin - prefs_dict['METIS_LIB_DIR'] = self.spec['metis'].prefix.lib - prefs_dict['METIS_INCLUDE_DIR'] = self.spec['metis'].prefix.include - - if '+parmetis' in self.spec: - prefs_dict['PARMETIS_SYSTEM'] = 1 - prefs_dict['PARMETIS_DIR'] = self.spec['parmetis'].prefix - prefs_dict['PARMETIS_BIN_DIR'] = self.spec['parmetis'].prefix.bin - prefs_dict['PARMETIS_LIB_DIR'] = self.spec['parmetis'].prefix.lib - prefs_dict['PARMETIS_INCLUDE_DIR'] = \ - self.spec['parmetis'].prefix.include - - if '+parmgridgen' in self.spec: - prefs_dict['PARMGRIDGEN_SYSTEM'] = 1 - prefs_dict['PARMGRIDGEN_DIR'] = self.spec['parmgridgen'].prefix - prefs_dict['PARMGRIDGEN_BIN_DIR'] = \ - self.spec['parmgridgen'].prefix.bin - prefs_dict['PARMGRIDGEN_LIB_DIR'] = \ - self.spec['parmgridgen'].prefix.lib - prefs_dict['PARMGRIDGEN_INCLUDE_DIR'] = \ - self.spec['parmgridgen'].prefix.include - - if '+paraview' in self.spec: - prefs_dict['PARAVIEW_SYSTEM'] = 1 - prefs_dict['PARAVIEW_DIR'] = self.spec['paraview'].prefix, - prefs_dict['PARAVIEW_BIN_DIR'] = self.spec['paraview'].prefix.bin, - prefs_dict['QT_SYSTEM'] = 1 - prefs_dict['QT_DIR'] = self.spec['qt'].prefix, - prefs_dict['QT_BIN_DIR'] = self.spec['qt'].prefix.bin, - - with working_dir('.'): - with open("etc/prefs.sh", "w") as fh: - for key in sorted(prefs_dict): - fh.write('export {0}={1}\n'.format(key, prefs_dict[key])) - - with open("etc/prefs.csh", "w") as fh: - for key in sorted(prefs_dict): - fh.write('setenv {0}={1}\n'.format(key, prefs_dict[key])) - - mpi_info = [ - 'PFLAGS = -DOMPI_SKIP_MPICXX -DMPICH_IGNORE_CXX_SEEK', - 'PINC = -I{0}'.format(self.spec['mpi'].prefix.include), - 'PLIBS = -L{0} -lmpi'.format(self.spec['mpi'].prefix.lib) - ] - - arch_path = ''.join([arch, prefs_dict['WM_ARCH_OPTION'], - foam_compiler]) - option_path = ''.join([arch_path, - prefs_dict['WM_PRECISION_OPTION'], - prefs_dict['WM_COMPILE_OPTION']]) - rule_path = join_path("wmake", "rules", arch_path) - build_path = join_path(self.stage.source_path, 'lib', option_path) - install_path = \ - join_path(self.prefix, - 'foam-extend-{0}'.format(self.version.up_to(2)), - option_path) - - rpaths_foam = ' '.join([ - '{0}{1}'.format(self.compiler.cxx_rpath_arg, - install_path), - '{0}{1}'.format(self.compiler.cxx_rpath_arg, - build_path) - ]) - - compiler_flags = { - 'DBUG': rpaths_foam, - 'OPT': '-O3', - } - - with working_dir(rule_path): - with open('mplibSPACK', "w") as fh: - fh.write('\n'.join(mpi_info)) - - for comp in ['c', 'c++']: - with open('{0}SPACKOpt'.format(comp), "w") as fh: - for key, val in compiler_flags.iteritems(): - fh.write('{0}{1} = {2}\n'.format(comp, key, val)) - - def setup_environment(self, spack_env, run_env): - with working_dir(self.stage.path): - spack_env.set('FOAM_INST_DIR', os.path.abspath('.')) - - (arch, foam_compiler) = self.set_arch() - - run_env.set('FOAM_INST_DIR', self.prefix) - - def install(self, spec, prefix): - self.patch() - - env_openfoam = EnvironmentModifications() - self.get_openfoam_environment(env_openfoam) - env_openfoam.apply_modifications() - - if self.parallel: - os.environ['WM_NCOMPPROCS'] = str(self.make_jobs) \ - if self.make_jobs else str(multiprocessing.cpu_count()) - - # for key in sorted(os.environ): - # print("{0} = {1}".format(key, os.environ[key])) - - allwmake = Executable('./Allwmake') - allwmake() - - install_path = \ - join_path(self.prefix, - 'foam-extend-{0}'.format(self.version.up_to(2))) - - if '+source' in spec: - install_tree('src', join_path(install_path, 'src')) - - install_tree('lib', join_path(install_path, 'lib')) - install_tree('bin', join_path(install_path, 'bin')) - install_tree('applications', join_path(install_path, 'applications')) - install_tree('etc', join_path(install_path, 'etc')) - install_tree('wmake', join_path(install_path, 'wmake')) -- cgit v1.2.3-70-g09d2 From 9f4e599232d614ef0611e4e89125b75d4a9d816e Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Mon, 30 May 2016 16:58:06 +0200 Subject: Ignoring the flake8 error for a line too long --- var/spack/repos/builtin/packages/foam-extend/package.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/foam-extend/package.py b/var/spack/repos/builtin/packages/foam-extend/package.py index 4bbb065d8b..71a61afaa6 100644 --- a/var/spack/repos/builtin/packages/foam-extend/package.py +++ b/var/spack/repos/builtin/packages/foam-extend/package.py @@ -99,9 +99,10 @@ class FoamExtend(Package): filter_file(r'-lIMlib -lMGridGen', r'-limlib -lmgrid', 'src/dbns/Make/options') - filter_file(r'-lMGridGen', - r'-lmgrid', - 'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options') + filter_file( + r'-lMGridGen', + r'-lmgrid', + 'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options') # NOQA: ignore=501 (arch, foam_compiler) = self.set_arch() -- cgit v1.2.3-70-g09d2 From 9db8dc18956520deae2f2e9a1e6827848df5bd51 Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Wed, 1 Jun 2016 00:57:01 +0200 Subject: Removing extra dependencies + minor fix according to remarks on #1002 --- .../repos/builtin/packages/foam-extend/package.py | 56 +++++++++++----------- .../repos/builtin/packages/parmgridgen/package.py | 20 ++++---- 2 files changed, 37 insertions(+), 39 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/foam-extend/package.py b/var/spack/repos/builtin/packages/foam-extend/package.py index 32104fea43..9043896863 100644 --- a/var/spack/repos/builtin/packages/foam-extend/package.py +++ b/var/spack/repos/builtin/packages/foam-extend/package.py @@ -3,7 +3,6 @@ from spack.environment import * import multiprocessing import subprocess -import re import os @@ -11,6 +10,8 @@ class FoamExtend(Package): """The foam-extend project is a fork of the OpenFOAM open source library for Computational Fluid Dynamics (CFD).""" + homepage = "http://www.extend-project.de/" + version('3.2', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.2') version('3.1', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.1') version('3.0', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.0') @@ -21,16 +22,13 @@ class FoamExtend(Package): variant('metis', default=True, description='Activate Metis as a possible decomposition library') variant('parmetis', default=True, description='Activate Parmetis as a possible decomposition library') variant('parmgridgen', default=True, description='Activate Parmgridgen support') + variant('source', default=True, description='Installs also the source folder') supported_compilers = {'clang': 'Clang', 'gcc': 'Gcc', 'intel': 'Icc'} depends_on('mpi') - depends_on('cmake') depends_on('python') depends_on('flex@:2.5.99') - depends_on('bison') - depends_on('m4') - depends_on('hwloc') depends_on('zlib') depends_on('scotch ~ metis', when='~ptscotch+scotch') @@ -40,17 +38,19 @@ class FoamExtend(Package): depends_on('parmgridgen', when='+parmgridgen') depends_on('paraview', when='+paraview') - depends_on('qt@:4', when='+paraview') def _get_env(self, command): - variable_set = re.compile(r'(.+?)=(.*)') proc = subprocess.Popen(['bash', '-c', command], stdout=subprocess.PIPE) env = {} for line in proc.stdout: - match_grp = variable_set.match(line) - if match_grp: - env[match_grp.group(1)] = match_grp.group(2) + try: + key, val = line.split('=', 1) + env[key] = val.strip() + except: + # it may fail due to some bash functions that are on + # multiple lines + pass return env def set_arch(self): @@ -64,13 +64,13 @@ class FoamExtend(Package): if sysname == 'Linux': arch = 'linux' if foam_compiler == 'Clang': - raise RuntimeError('OS, compiler combinaison not\ + raise RuntimeError('OS, compiler combination not\ supported ({0} {1})'.format(sysname, foam_compiler)) elif sysname == 'Darwin': if machine == 'x86_64': arch = 'darwinIntel' if foam_compiler == 'Icc': - raise RuntimeError('OS, compiler combinaison not\ + raise RuntimeError('OS, compiler combination not\ supported ({0} {1})'.format(sysname, foam_compiler)) else: raise RuntimeError('{0} {1} is not a \ @@ -80,24 +80,31 @@ class FoamExtend(Package): def get_openfoam_environment(self, env_openfoam): env_before = self._get_env('env') - + # This gets the environment set in case the etc/bashrc file is + # sourced with working_dir(self.stage.source_path): env_after = self._get_env('source etc/bashrc && env') + # Removes some PATH to not add useless information in the + # environment later on if 'PATH' in env_after: del env_after['PATH'] if 'LD_LIBRARY_PATH' in env_after: del env_after['LD_LIBRARY_PATH'] + # Checks what was set in addition to the current environment, + # that should be the variables set by the bashrc for key, value in env_after.iteritems(): if key not in env_before or not value == env_before[key]: env_openfoam.set(key, value) def patch(self): + # change names to match the package and not the one patch in + # the Third-Party of foam-extend if '+parmgridgen' in self.spec: - filter_file(r'-lIMlib -lMGridGen', - r'-limlib -lmgrid', + filter_file(r'-lMGridGen', + r'-lmgrid', 'src/dbns/Make/options') filter_file( @@ -105,6 +112,7 @@ class FoamExtend(Package): r'-lmgrid', 'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options') # NOQA: ignore=501 + # Get the wmake arch and compiler (arch, foam_compiler) = self.set_arch() prefs_dict = { @@ -126,15 +134,8 @@ class FoamExtend(Package): 'BISON_SYSTEM': 1, 'BISON_DIR': self.spec['flex'].prefix, - 'M4_SYSTEM': 1, - 'M4_DIR': self.spec['m4'].prefix, - 'ZLIB_SYSTEM': 1, 'ZLIB_DIR': self.spec['zlib'].prefix, - - 'HWLOC_SYSTEM': 1, - 'HWLOC_DIR': self.spec['hwloc'].prefix, - 'HWLOC_BIN_DIR': self.spec['hwloc'].prefix.bin, } if '+scotch' in self.spec or '+ptscotch' in self.spec: @@ -178,6 +179,9 @@ class FoamExtend(Package): prefs_dict['QT_DIR'] = self.spec['qt'].prefix, prefs_dict['QT_BIN_DIR'] = self.spec['qt'].prefix.bin, + # write the prefs files to define the configuration needed, + # only the prefs.sh is used by this script but both are + # installed for end users with working_dir('.'): with open("etc/prefs.sh", "w") as fh: for key in sorted(prefs_dict): @@ -187,6 +191,9 @@ class FoamExtend(Package): for key in sorted(prefs_dict): fh.write('setenv {0}={1}\n'.format(key, prefs_dict[key])) + # Defining a different mpi and optimisation file to be able to + # make wmake get spack info with minimum modifications on + # configurations scripts mpi_info = [ 'PFLAGS = -DOMPI_SKIP_MPICXX -DMPICH_IGNORE_CXX_SEEK', 'PINC = -I{0}'.format(self.spec['mpi'].prefix.include), @@ -235,8 +242,6 @@ class FoamExtend(Package): run_env.set('FOAM_INST_DIR', self.prefix) def install(self, spec, prefix): - self.patch() - env_openfoam = EnvironmentModifications() self.get_openfoam_environment(env_openfoam) env_openfoam.apply_modifications() @@ -245,9 +250,6 @@ class FoamExtend(Package): os.environ['WM_NCOMPPROCS'] = str(self.make_jobs) \ if self.make_jobs else str(multiprocessing.cpu_count()) - # for key in sorted(os.environ): - # print("{0} = {1}".format(key, os.environ[key])) - allwmake = Executable('./Allwmake') allwmake() diff --git a/var/spack/repos/builtin/packages/parmgridgen/package.py b/var/spack/repos/builtin/packages/parmgridgen/package.py index 11b19f2ec2..c880bb5b2b 100644 --- a/var/spack/repos/builtin/packages/parmgridgen/package.py +++ b/var/spack/repos/builtin/packages/parmgridgen/package.py @@ -57,19 +57,15 @@ class Parmgridgen(Package): make(*make_opts, parallel=False) - include_path = join_path(self.prefix, 'include') - lib_path = join_path(self.prefix, 'lib') - bin_path = join_path(self.prefix, 'bin') + mkdirp(self.prefix.include, self.prefix.lib, self.prefix.bin) - mkdirp(include_path, lib_path, bin_path) - - install("mgridgen.h", include_path) - install("parmgridgen.h", include_path) + install("mgridgen.h", self.prefix.include) + install("parmgridgen.h", self.prefix.include) install("MGridGen/IMlib/libIMlib.a", - join_path(lib_path, 'libimlib.a')) - install("libmgrid.a", lib_path) - install("libparmgrid.a", lib_path) + join_path(self.prefix.lib, 'libIMlib.a')) + install("libmgrid.a", self.prefix.lib) + install("libparmgrid.a", self.prefix.lib) - install("mgridgen", bin_path) - install("parmgridgen", bin_path) + install("mgridgen", self.prefix.bin) + install("parmgridgen", self.prefix.bin) -- cgit v1.2.3-70-g09d2 From 53dcc39b725cb3887bab2ba047b23db1435e73ea Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Wed, 1 Jun 2016 17:33:54 +0200 Subject: removing useless selfs --- .../repos/builtin/packages/parmgridgen/package.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/parmgridgen/package.py b/var/spack/repos/builtin/packages/parmgridgen/package.py index c880bb5b2b..02be777c36 100644 --- a/var/spack/repos/builtin/packages/parmgridgen/package.py +++ b/var/spack/repos/builtin/packages/parmgridgen/package.py @@ -46,9 +46,9 @@ class Parmgridgen(Package): 'COPTIONS=-fPIC', 'LDOPTIONS=-fPIC', 'CC={0}'.format(self.compiler.cc), - 'PARCC={0}'.format(self.spec['mpi'].mpicc), + 'PARCC={0}'.format(spec['mpi'].mpicc), 'LD={0}'.format(self.compiler.cc), - 'PARLD={0}'.format(self.spec['mpi'].mpicc), + 'PARLD={0}'.format(spec['mpi'].mpicc), 'LIBDIR=-L../..', 'PARLIBS=-L../../ -lparmgrid -lmgrid -lm', 'LIBS=-L../../ -lmgrid -lm', @@ -57,15 +57,15 @@ class Parmgridgen(Package): make(*make_opts, parallel=False) - mkdirp(self.prefix.include, self.prefix.lib, self.prefix.bin) + mkdirp(prefix.include, prefix.lib, prefix.bin) - install("mgridgen.h", self.prefix.include) - install("parmgridgen.h", self.prefix.include) + install("mgridgen.h", prefix.include) + install("parmgridgen.h", prefix.include) install("MGridGen/IMlib/libIMlib.a", - join_path(self.prefix.lib, 'libIMlib.a')) - install("libmgrid.a", self.prefix.lib) - install("libparmgrid.a", self.prefix.lib) + join_path(prefix.lib, 'libIMlib.a')) + install("libmgrid.a", prefix.lib) + install("libparmgrid.a", prefix.lib) - install("mgridgen", self.prefix.bin) - install("parmgridgen", self.prefix.bin) + install("mgridgen", prefix.bin) + install("parmgridgen", prefix.bin) -- cgit v1.2.3-70-g09d2 From 7cf1313572b24917ff77018424d77991312e6f5f Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Mon, 27 Jun 2016 00:55:26 +0200 Subject: changes to use from_sourcing_file --- .../repos/builtin/packages/foam-extend/package.py | 42 ++++------------------ 1 file changed, 6 insertions(+), 36 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/foam-extend/package.py b/var/spack/repos/builtin/packages/foam-extend/package.py index 9043896863..ca1a0e1710 100644 --- a/var/spack/repos/builtin/packages/foam-extend/package.py +++ b/var/spack/repos/builtin/packages/foam-extend/package.py @@ -39,20 +39,6 @@ class FoamExtend(Package): depends_on('paraview', when='+paraview') - def _get_env(self, command): - proc = subprocess.Popen(['bash', '-c', command], - stdout=subprocess.PIPE) - env = {} - for line in proc.stdout: - try: - key, val = line.split('=', 1) - env[key] = val.strip() - except: - # it may fail due to some bash functions that are on - # multiple lines - pass - return env - def set_arch(self): (sysname, nodename, release, version, machine) = os.uname() @@ -78,26 +64,11 @@ class FoamExtend(Package): return (arch, foam_compiler) - def get_openfoam_environment(self, env_openfoam): - env_before = self._get_env('env') - # This gets the environment set in case the etc/bashrc file is - # sourced - with working_dir(self.stage.source_path): - env_after = self._get_env('source etc/bashrc && env') - - # Removes some PATH to not add useless information in the - # environment later on - if 'PATH' in env_after: - del env_after['PATH'] - - if 'LD_LIBRARY_PATH' in env_after: - del env_after['LD_LIBRARY_PATH'] - - # Checks what was set in addition to the current environment, - # that should be the variables set by the bashrc - for key, value in env_after.iteritems(): - if key not in env_before or not value == env_before[key]: - env_openfoam.set(key, value) + def get_openfoam_environment(self): + return EnvironmentModifications.from_sourcing_files( + join_path(self.stage.source_path, + 'etc/bashrc') + ) def patch(self): # change names to match the package and not the one patch in @@ -242,8 +213,7 @@ class FoamExtend(Package): run_env.set('FOAM_INST_DIR', self.prefix) def install(self, spec, prefix): - env_openfoam = EnvironmentModifications() - self.get_openfoam_environment(env_openfoam) + env_openfoam = self.get_openfoam_environment() env_openfoam.apply_modifications() if self.parallel: -- cgit v1.2.3-70-g09d2 From f3accb111ef77e9e192305fb09797948cb984851 Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Mon, 27 Jun 2016 01:23:14 +0200 Subject: correcting flake8 --- var/spack/repos/builtin/packages/foam-extend/package.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/foam-extend/package.py b/var/spack/repos/builtin/packages/foam-extend/package.py index ca1a0e1710..4479fc9bee 100644 --- a/var/spack/repos/builtin/packages/foam-extend/package.py +++ b/var/spack/repos/builtin/packages/foam-extend/package.py @@ -2,7 +2,6 @@ from spack import * from spack.environment import * import multiprocessing -import subprocess import os @@ -67,8 +66,7 @@ class FoamExtend(Package): def get_openfoam_environment(self): return EnvironmentModifications.from_sourcing_files( join_path(self.stage.source_path, - 'etc/bashrc') - ) + 'etc/bashrc')) def patch(self): # change names to match the package and not the one patch in -- cgit v1.2.3-70-g09d2