From 9c95ec0b299f7f0eb83362318f77e31701708902 Mon Sep 17 00:00:00 2001 From: Joseph Ciurej Date: Mon, 2 May 2016 16:41:55 -0700 Subject: [PATCH 1/8] Updated and added new versions to the METIS/ParMETIS packages. - Added a 'url_for_version' function to the METIS/ParMETIS packages. - Added installation support for METIS@5.0.2 and ParMETIS@4.0.2. - Changed the 'double' variant to 'real64' to make it more consistent with the 'idx64' variant naming. - Removed an unnecessary dependency on gdb. --- .../repos/builtin/packages/metis/package.py | 35 ++++++++----------- .../builtin/packages/parmetis/package.py | 18 +++++----- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py index 061179b78e..daeaf6245b 100644 --- a/var/spack/repos/builtin/packages/metis/package.py +++ b/var/spack/repos/builtin/packages/metis/package.py @@ -33,30 +33,30 @@ class Metis(Package): recursive-bisection, multilevel k-way, and multi-constraint partitioning schemes. """ - homepage = 'http://glaros.dtc.umn.edu/gkhome/metis/metis/overview' - url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz" + homepage = "http://glaros.dtc.umn.edu/gkhome/metis/metis/overview" + base_url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis" - version('5.1.0', '5465e67079419a69e0116de24fce58fe', - url='http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz') - version('4.0.3', '5efa35de80703c1b2c4d0de080fafbcf4e0d363a21149a1ad2f96e0144841a55', - url='http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/OLD/metis-4.0.3.tar.gz') + version('5.1.0', '5465e67079419a69e0116de24fce58fe') + version('5.0.2', 'acb521a4e8c2e6dd559a7f9abd0468c5') + version('4.0.3', 'd3848b454532ef18dc83e4fb160d1e10') variant('shared', default=True, description='Enables the build of shared libraries') variant('debug', default=False, description='Builds the library in debug mode') variant('gdb', default=False, description='Enables gdb support') variant('idx64', default=False, description='Use int64_t as default index type') - variant('double', default=False, description='Use double precision floating point types') + variant('real64', default=False, description='Use double precision floating point types') depends_on('cmake @2.8:', when='@5:') # build-time dependency - depends_on('gdb', when='+gdb') patch('install_gklib_defs_rename.patch', when='@5:') + def url_for_version(self, version): + version_dir = 'OLD/' if version < Version('4.0.3') else '' + return '%s/%smetis-%s.tar.gz' % (Metis.base_url, version_dir, version) @when('@4:4.0.3') def install(self, spec, prefix): - if '+gdb' in spec: raise InstallError('gdb support not implemented in METIS 4!') if '+idx64' in spec: @@ -128,7 +128,6 @@ def install(self, spec, prefix): @when('@5:') def install(self, spec, prefix): - options = [] options.extend(std_cmake_args) @@ -140,20 +139,15 @@ def install(self, spec, prefix): if '+shared' in spec: options.append('-DSHARED:BOOL=ON') - if '+debug' in spec: - options.extend(['-DDEBUG:BOOL=ON', - '-DCMAKE_BUILD_TYPE:STRING=Debug']) - + options.extend(['-DDEBUG:BOOL=ON', '-DCMAKE_BUILD_TYPE:STRING=Debug']) if '+gdb' in spec: options.append('-DGDB:BOOL=ON') metis_header = join_path(source_directory, 'include', 'metis.h') - if '+idx64' in spec: filter_file('IDXTYPEWIDTH 32', 'IDXTYPEWIDTH 64', metis_header) - - if '+double' in spec: + if '+real64' in spec: filter_file('REALTYPEWIDTH 32', 'REALTYPEWIDTH 64', metis_header) # Make clang 7.3 happy. @@ -166,9 +160,10 @@ def install(self, spec, prefix): with working_dir(build_directory, create=True): cmake(source_directory, *options) make() - make("install") + make('install') + # now run some tests: - for f in ["4elt", "copter2", "mdual"]: + for f in ['4elt', 'copter2', 'mdual']: graph = join_path(source_directory,'graphs','%s.graph' % f) Executable(join_path(prefix.bin,'graphchk'))(graph) Executable(join_path(prefix.bin,'gpmetis'))(graph,'2') @@ -182,6 +177,6 @@ def install(self, spec, prefix): # install GKlib headers, which will be needed for ParMETIS GKlib_dist = join_path(prefix.include,'GKlib') mkdirp(GKlib_dist) - fs = glob.glob(join_path(source_directory,'GKlib',"*.h")) + fs = glob.glob(join_path(source_directory,'GKlib','*.h')) for f in fs: install(f, GKlib_dist) diff --git a/var/spack/repos/builtin/packages/parmetis/package.py b/var/spack/repos/builtin/packages/parmetis/package.py index 2dead4a76a..a8456083b4 100644 --- a/var/spack/repos/builtin/packages/parmetis/package.py +++ b/var/spack/repos/builtin/packages/parmetis/package.py @@ -31,10 +31,12 @@ class Parmetis(Package): ParMETIS is an MPI-based parallel library that implements a variety of algorithms for partitioning unstructured graphs, meshes, and for computing fill-reducing orderings of sparse matrices. """ + homepage = 'http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview' - url = 'http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/parmetis-4.0.3.tar.gz' + base_url = 'http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis' version('4.0.3', 'f69c479586bf6bb7aff6a9bc0c739628') + version('4.0.2', '0912a953da5bb9b5e5e10542298ffdce') variant('shared', default=True, description='Enables the build of shared libraries') variant('debug', default=False, description='Builds the library in debug mode') @@ -42,17 +44,18 @@ class Parmetis(Package): depends_on('cmake @2.8:') # build dependency depends_on('mpi') - - patch('enable_external_metis.patch') depends_on('metis@5:') + patch('enable_external_metis.patch') # bug fixes from PETSc developers # https://bitbucket.org/petsc/pkg-parmetis/commits/1c1a9fd0f408dc4d42c57f5c3ee6ace411eb222b/raw/ patch('pkg-parmetis-1c1a9fd0f408dc4d42c57f5c3ee6ace411eb222b.patch') # https://bitbucket.org/petsc/pkg-parmetis/commits/82409d68aa1d6cbc70740d0f35024aae17f7d5cb/raw/ patch('pkg-parmetis-82409d68aa1d6cbc70740d0f35024aae17f7d5cb.patch') - depends_on('gdb', when='+gdb') + def url_for_version(self, version): + version_dir = 'OLD/' if version < Version('3.2.0') else '' + return '%s/%sparmetis-%s.tar.gz' % (Parmetis.base_url, version_dir, version) def install(self, spec, prefix): options = [] @@ -71,18 +74,15 @@ def install(self, spec, prefix): if '+shared' in spec: options.append('-DSHARED:BOOL=ON') - if '+debug' in spec: - options.extend(['-DDEBUG:BOOL=ON', - '-DCMAKE_BUILD_TYPE:STRING=Debug']) - + options.extend(['-DDEBUG:BOOL=ON', '-DCMAKE_BUILD_TYPE:STRING=Debug']) if '+gdb' in spec: options.append('-DGDB:BOOL=ON') with working_dir(build_directory, create=True): cmake(source_directory, *options) make() - make("install") + make('install') # The shared library is not installed correctly on Darwin; correct this if (sys.platform == 'darwin') and ('+shared' in spec): From 0ef6843d85a1b74659ed72bda18a72613276d4ec Mon Sep 17 00:00:00 2001 From: Joseph Ciurej Date: Mon, 9 May 2016 15:37:00 -0700 Subject: [PATCH 2/8] Improved MPI path specification for ParMETIS using PR #893 features. --- var/spack/repos/builtin/packages/parmetis/package.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/var/spack/repos/builtin/packages/parmetis/package.py b/var/spack/repos/builtin/packages/parmetis/package.py index a8456083b4..956a035f7b 100644 --- a/var/spack/repos/builtin/packages/parmetis/package.py +++ b/var/spack/repos/builtin/packages/parmetis/package.py @@ -65,12 +65,10 @@ def install(self, spec, prefix): source_directory = self.stage.source_path metis_source = join_path(source_directory, 'metis') - # FIXME : Once a contract is defined, MPI compilers should be retrieved indirectly via spec['mpi'] in case - # FIXME : they use a non-standard name options.extend(['-DGKLIB_PATH:PATH={metis_source}/GKlib'.format(metis_source=spec['metis'].prefix.include), '-DMETIS_PATH:PATH={metis_source}'.format(metis_source=spec['metis'].prefix), - '-DCMAKE_C_COMPILER:STRING=mpicc', - '-DCMAKE_CXX_COMPILER:STRING=mpicxx']) + '-DCMAKE_C_COMPILER:STRING={mpicc}'.format(mpicc=spec['mpi'].mpicc), + '-DCMAKE_CXX_COMPILER:STRING={mpicxx}'.format(mpicxx=spec['mpi'].mpicxx)]) if '+shared' in spec: options.append('-DSHARED:BOOL=ON') From 064d3584c0f95f19f159f0d7bc51c5172278638f Mon Sep 17 00:00:00 2001 From: Joseph Ciurej Date: Thu, 19 May 2016 09:33:47 -0700 Subject: [PATCH 3/8] Updating 'metis' and 'parmetis' to conform to PEP8 standards. --- .../repos/builtin/packages/metis/package.py | 93 ++++++++++--------- .../builtin/packages/parmetis/package.py | 34 +++---- 2 files changed, 65 insertions(+), 62 deletions(-) diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py index daeaf6245b..94e6fce6db 100644 --- a/var/spack/repos/builtin/packages/metis/package.py +++ b/var/spack/repos/builtin/packages/metis/package.py @@ -24,14 +24,17 @@ ############################################################################## from spack import * -import glob, sys, os +import glob +import sys +import os + class Metis(Package): - """ - METIS is a set of serial programs for partitioning graphs, partitioning finite element meshes, and producing fill - reducing orderings for sparse matrices. The algorithms implemented in METIS are based on the multilevel - recursive-bisection, multilevel k-way, and multi-constraint partitioning schemes. - """ + """METIS is a set of serial programs for partitioning graphs, partitioning + finite element meshes, and producing fill reducing orderings for sparse + matrices. The algorithms implemented in METIS are based on the + multilevel recursive-bisection, multilevel k-way, and multi-constraint + partitioning schemes.""" homepage = "http://glaros.dtc.umn.edu/gkhome/metis/metis/overview" base_url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis" @@ -47,22 +50,20 @@ class Metis(Package): variant('idx64', default=False, description='Use int64_t as default index type') variant('real64', default=False, description='Use double precision floating point types') - depends_on('cmake @2.8:', when='@5:') # build-time dependency + depends_on('cmake@2.8:', when='@5:') # build-time dependency patch('install_gklib_defs_rename.patch', when='@5:') def url_for_version(self, version): - version_dir = 'OLD/' if version < Version('4.0.3') else '' - return '%s/%smetis-%s.tar.gz' % (Metis.base_url, version_dir, version) + verdir = 'OLD/' if version < Version('4.0.3') else '' + return '%s/%smetis-%s.tar.gz' % (Metis.base_url, verdir, version) - @when('@4:4.0.3') + @when('@4') def install(self, spec, prefix): - if '+gdb' in spec: - raise InstallError('gdb support not implemented in METIS 4!') - if '+idx64' in spec: - raise InstallError('idx64 option not implemented in METIS 4!') - if '+double' in spec: - raise InstallError('double option not implemented for METIS 4!') + unsupp_vars = [v for v in ('+gdb', '+idx64', '+real64') if v in spec] + if unsupp_vars: + msg = 'Given variants %s are unsupported by METIS 4!' % unsupp_vars + raise InstallError(msg) options = ['COPTIONS=-fPIC'] if '+debug' in spec: @@ -70,9 +71,10 @@ def install(self, spec, prefix): make(*options) mkdir(prefix.bin) - for x in ('pmetis', 'kmetis', 'oemetis', 'onmetis', 'partnmesh', - 'partdmesh', 'mesh2nodal', 'mesh2dual', 'graphchk'): - install(x, prefix.bin) + binfiles = ('pmetis', 'kmetis', 'oemetis', 'onmetis', 'partnmesh', + 'partdmesh', 'mesh2nodal', 'mesh2dual', 'graphchk') + for binfile in binfiles: + install(binfile, prefix.bin) mkdir(prefix.lib) install('libmetis.a', prefix.lib) @@ -82,12 +84,10 @@ def install(self, spec, prefix): install(h, prefix.include) mkdir(prefix.share) - for f in (join_path(*p) - for p in (('Programs', 'io.c'), - ('Test','mtest.c'), - ('Graphs','4elt.graph'), - ('Graphs', 'metis.mesh'), - ('Graphs', 'test.mgraph'))): + sharefiles = (('Programs', 'io.c'), ('Test', 'mtest.c'), + ('Graphs', '4elt.graph'), ('Graphs', 'metis.mesh'), + ('Graphs', 'test.mgraph')) + for sharefile in tuple(join_path(*sf) for sf in sharefiles): install(f, prefix.share) if '+shared' in spec: @@ -100,10 +100,10 @@ def install(self, spec, prefix): load_flag = '-Wl,-whole-archive' no_load_flag = '-Wl,-no-whole-archive' - os.system(spack_cc + ' -fPIC -shared ' + load_flag + - ' libmetis.a ' + no_load_flag + ' -o libmetis.' + - lib_dsuffix) - install('libmetis.' + lib_dsuffix, prefix.lib) + flags = (self.compiler.cc, load_flag, no_load_flag, lib_dsuffix) + build_cmd = '%s -fPIC -shared %s libmetis.a %s libmetis.%s' % flags + os.system(build_cmd) + install('libmetis.%s' % lib_dsuffix, prefix.lib) # Set up and run tests on installation symlink(join_path(prefix.share, 'io.c'), 'io.c') @@ -125,7 +125,6 @@ def install(self, spec, prefix): os.system(join_path(prefix.bin, 'partdmesh') + metis_mesh + ' 10') os.system(join_path(prefix.bin, 'mesh2dual') + metis_mesh) - @when('@5:') def install(self, spec, prefix): options = [] @@ -134,13 +133,14 @@ def install(self, spec, prefix): build_directory = join_path(self.stage.path, 'spack-build') source_directory = self.stage.source_path - options.append('-DGKLIB_PATH:PATH={metis_source}/GKlib'.format(metis_source=source_directory)) + options.append('-DGKLIB_PATH:PATH=%s/GKlib' % source_directory) options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix) if '+shared' in spec: options.append('-DSHARED:BOOL=ON') if '+debug' in spec: - options.extend(['-DDEBUG:BOOL=ON', '-DCMAKE_BUILD_TYPE:STRING=Debug']) + options.extend(['-DDEBUG:BOOL=ON', + '-DCMAKE_BUILD_TYPE:STRING=Debug']) if '+gdb' in spec: options.append('-DGDB:BOOL=ON') @@ -153,9 +153,10 @@ def install(self, spec, prefix): # Make clang 7.3 happy. # Prevents "ld: section __DATA/__thread_bss extends beyond end of file" # See upstream LLVM issue https://llvm.org/bugs/show_bug.cgi?id=27059 - # Adopted from https://github.com/Homebrew/homebrew-science/blob/master/metis.rb + # and https://github.com/Homebrew/homebrew-science/blob/master/metis.rb if spec.satisfies('%clang@7.3.0'): - filter_file('#define MAX_JBUFS 128', '#define MAX_JBUFS 24', join_path(source_directory, 'GKlib', 'error.c')) + filter_file('#define MAX_JBUFS 128', '#define MAX_JBUFS 24', + join_path(source_directory, 'GKlib', 'error.c')) with working_dir(build_directory, create=True): cmake(source_directory, *options) @@ -164,19 +165,19 @@ def install(self, spec, prefix): # now run some tests: for f in ['4elt', 'copter2', 'mdual']: - graph = join_path(source_directory,'graphs','%s.graph' % f) - Executable(join_path(prefix.bin,'graphchk'))(graph) - Executable(join_path(prefix.bin,'gpmetis'))(graph,'2') - Executable(join_path(prefix.bin,'ndmetis'))(graph) + graph = join_path(source_directory, 'graphs', '%s.graph' % f) + Executable(join_path(prefix.bin, 'graphchk'))(graph) + Executable(join_path(prefix.bin, 'gpmetis'))(graph, '2') + Executable(join_path(prefix.bin, 'ndmetis'))(graph) - graph = join_path(source_directory,'graphs','test.mgraph') - Executable(join_path(prefix.bin,'gpmetis'))(graph,'2') - graph = join_path(source_directory,'graphs','metis.mesh') - Executable(join_path(prefix.bin,'mpmetis'))(graph,'2') + graph = join_path(source_directory, 'graphs', 'test.mgraph') + Executable(join_path(prefix.bin, 'gpmetis'))(graph, '2') + graph = join_path(source_directory, 'graphs', 'metis.mesh') + Executable(join_path(prefix.bin, 'mpmetis'))(graph, '2') # install GKlib headers, which will be needed for ParMETIS - GKlib_dist = join_path(prefix.include,'GKlib') + GKlib_dist = join_path(prefix.include, 'GKlib') mkdirp(GKlib_dist) - fs = glob.glob(join_path(source_directory,'GKlib','*.h')) - for f in fs: - install(f, GKlib_dist) + hfiles = glob.glob(join_path(source_directory, 'GKlib', '*.h')) + for hfile in hfiles: + install(hfile, GKlib_dist) diff --git a/var/spack/repos/builtin/packages/parmetis/package.py b/var/spack/repos/builtin/packages/parmetis/package.py index 956a035f7b..9b36f273e4 100644 --- a/var/spack/repos/builtin/packages/parmetis/package.py +++ b/var/spack/repos/builtin/packages/parmetis/package.py @@ -26,11 +26,11 @@ from spack import * import sys + class Parmetis(Package): - """ - ParMETIS is an MPI-based parallel library that implements a variety of algorithms for partitioning unstructured - graphs, meshes, and for computing fill-reducing orderings of sparse matrices. - """ + """ParMETIS is an MPI-based parallel library that implements a variety of + algorithms for partitioning unstructured graphs, meshes, and for + computing fill-reducing orderings of sparse matrices.""" homepage = 'http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview' base_url = 'http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis' @@ -42,20 +42,20 @@ class Parmetis(Package): variant('debug', default=False, description='Builds the library in debug mode') variant('gdb', default=False, description='Enables gdb support') - depends_on('cmake @2.8:') # build dependency + depends_on('cmake@2.8:') # build dependency depends_on('mpi') depends_on('metis@5:') patch('enable_external_metis.patch') # bug fixes from PETSc developers - # https://bitbucket.org/petsc/pkg-parmetis/commits/1c1a9fd0f408dc4d42c57f5c3ee6ace411eb222b/raw/ + # https://bitbucket.org/petsc/pkg-parmetis/commits/1c1a9fd0f408dc4d42c57f5c3ee6ace411eb222b/raw/ # NOQA: ignore=E501 patch('pkg-parmetis-1c1a9fd0f408dc4d42c57f5c3ee6ace411eb222b.patch') - # https://bitbucket.org/petsc/pkg-parmetis/commits/82409d68aa1d6cbc70740d0f35024aae17f7d5cb/raw/ + # https://bitbucket.org/petsc/pkg-parmetis/commits/82409d68aa1d6cbc70740d0f35024aae17f7d5cb/raw/ # NOQA: ignore=E501 patch('pkg-parmetis-82409d68aa1d6cbc70740d0f35024aae17f7d5cb.patch') def url_for_version(self, version): - version_dir = 'OLD/' if version < Version('3.2.0') else '' - return '%s/%sparmetis-%s.tar.gz' % (Parmetis.base_url, version_dir, version) + verdir = 'OLD/' if version < Version('3.2.0') else '' + return '%s/%sparmetis-%s.tar.gz' % (Parmetis.base_url, verdir, version) def install(self, spec, prefix): options = [] @@ -63,17 +63,19 @@ def install(self, spec, prefix): build_directory = join_path(self.stage.path, 'spack-build') source_directory = self.stage.source_path - metis_source = join_path(source_directory, 'metis') - options.extend(['-DGKLIB_PATH:PATH={metis_source}/GKlib'.format(metis_source=spec['metis'].prefix.include), - '-DMETIS_PATH:PATH={metis_source}'.format(metis_source=spec['metis'].prefix), - '-DCMAKE_C_COMPILER:STRING={mpicc}'.format(mpicc=spec['mpi'].mpicc), - '-DCMAKE_CXX_COMPILER:STRING={mpicxx}'.format(mpicxx=spec['mpi'].mpicxx)]) + options.extend([ + '-DGKLIB_PATH:PATH=%s/GKlib' % spec['metis'].prefix.include, + '-DMETIS_PATH:PATH=%s' % spec['metis'].prefix, + '-DCMAKE_C_COMPILER:STRING=%s' % spec['mpi'].mpicc, + '-DCMAKE_CXX_COMPILER:STRING=%s' % spec['mpi'].mpicxx + ]) if '+shared' in spec: options.append('-DSHARED:BOOL=ON') if '+debug' in spec: - options.extend(['-DDEBUG:BOOL=ON', '-DCMAKE_BUILD_TYPE:STRING=Debug']) + options.extend(['-DDEBUG:BOOL=ON', + '-DCMAKE_BUILD_TYPE:STRING=Debug']) if '+gdb' in spec: options.append('-DGDB:BOOL=ON') @@ -82,6 +84,6 @@ def install(self, spec, prefix): make() make('install') - # The shared library is not installed correctly on Darwin; correct this + # The shared library is not installed correctly on Darwin; fix this if (sys.platform == 'darwin') and ('+shared' in spec): fix_darwin_install_name(prefix.lib) From b5d0a388604f3c33bbbfdc1baff98f54ccdede5b Mon Sep 17 00:00:00 2001 From: Joseph Ciurej Date: Tue, 24 May 2016 15:03:21 -0700 Subject: [PATCH 4/8] Fixed a few linking/testing bugs in the METIS@:4 install method. --- .../repos/builtin/packages/metis/package.py | 52 +++++++++++-------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py index 94e6fce6db..eb0bdf28de 100644 --- a/var/spack/repos/builtin/packages/metis/package.py +++ b/var/spack/repos/builtin/packages/metis/package.py @@ -58,8 +58,9 @@ def url_for_version(self, version): verdir = 'OLD/' if version < Version('4.0.3') else '' return '%s/%smetis-%s.tar.gz' % (Metis.base_url, verdir, version) - @when('@4') + @when('@:4') def install(self, spec, prefix): + # Process library spec and options unsupp_vars = [v for v in ('+gdb', '+idx64', '+real64') if v in spec] if unsupp_vars: msg = 'Given variants %s are unsupported by METIS 4!' % unsupp_vars @@ -70,6 +71,7 @@ def install(self, spec, prefix): options.append('OPTFLAGS=-g -O0') make(*options) + # Compile and install library files mkdir(prefix.bin) binfiles = ('pmetis', 'kmetis', 'oemetis', 'onmetis', 'partnmesh', 'partdmesh', 'mesh2nodal', 'mesh2dual', 'graphchk') @@ -88,7 +90,7 @@ def install(self, spec, prefix): ('Graphs', '4elt.graph'), ('Graphs', 'metis.mesh'), ('Graphs', 'test.mgraph')) for sharefile in tuple(join_path(*sf) for sf in sharefiles): - install(f, prefix.share) + install(sharefile, prefix.share) if '+shared' in spec: if sys.platform == 'darwin': @@ -100,30 +102,38 @@ def install(self, spec, prefix): load_flag = '-Wl,-whole-archive' no_load_flag = '-Wl,-no-whole-archive' - flags = (self.compiler.cc, load_flag, no_load_flag, lib_dsuffix) - build_cmd = '%s -fPIC -shared %s libmetis.a %s libmetis.%s' % flags - os.system(build_cmd) + os.system('%s -fPIC -shared %s libmetis.a %s -o libmetis.%s' % \ + (self.compiler.cc, load_flag, no_load_flag, lib_dsuffix)) install('libmetis.%s' % lib_dsuffix, prefix.lib) # Set up and run tests on installation + inc_flags = '-I%s' % prefix.include + lib_flags = '-L%s' % prefix.lib + if '+shared' in spec: + lib_flags += ' -Wl,-rpath=%s' % prefix.lib + symlink(join_path(prefix.share, 'io.c'), 'io.c') symlink(join_path(prefix.share, 'mtest.c'), 'mtest.c') - os.system(spack_cc + ' -I%s' % prefix.include + ' -c io.c') - os.system(spack_cc + ' -I%s' % prefix.include + - ' -L%s' % prefix.lib + ' -lmetis mtest.c io.o -o mtest') - _4eltgraph = join_path(prefix.share, '4elt.graph') - test_mgraph = join_path(prefix.share, 'test.mgraph') - metis_mesh = join_path(prefix.share, 'metis.mesh') - kmetis = join_path(prefix.bin, 'kmetis') - os.system('./mtest ' + _4eltgraph) - os.system(kmetis + ' ' + _4eltgraph + ' 40') - os.system(join_path(prefix.bin, 'onmetis') + ' ' + _4eltgraph) - os.system(join_path(prefix.bin, 'pmetis') + ' ' + test_mgraph + ' 2') - os.system(kmetis + ' ' + test_mgraph + ' 2') - os.system(kmetis + ' ' + test_mgraph + ' 5') - os.system(join_path(prefix.bin, 'partnmesh') + metis_mesh + ' 10') - os.system(join_path(prefix.bin, 'partdmesh') + metis_mesh + ' 10') - os.system(join_path(prefix.bin, 'mesh2dual') + metis_mesh) + + os.system('%s %s -c io.c' % (self.compiler.cc, inc_flags)) + os.system('%s %s %s mtest.c io.o -o mtest -lmetis -lm' % \ + (self.compiler.cc, inc_flags, lib_flags)) + + test_bin = lambda testname: join_path(prefix.bin, testname) + test_graph = lambda graphname: join_path(prefix.share, graphname) + + graph = test_graph('4elt.graph') + os.system('./mtest %s' % graph) + os.system('%s %s 40' % (test_bin('kmetis'), graph)) + os.system('%s %s' % (test_bin('onmetis'), graph)) + graph = test_graph('test.mgraph') + os.system('%s %s 2' % (test_bin('pmetis'), graph)) + os.system('%s %s 2' % (test_bin('kmetis'), graph)) + os.system('%s %s 5' % (test_bin('kmetis'), graph)) + graph = test_graph('metis.mesh') + os.system('%s %s 10' % (test_bin('partnmesh'), graph)) + os.system('%s %s 10' % (test_bin('partdmesh'), graph)) + os.system('%s %s' % (test_bin('mesh2dual'), graph)) @when('@5:') def install(self, spec, prefix): From c9ba73d931439afd0670bcf6498154724d77cd45 Mon Sep 17 00:00:00 2001 From: Joseph Ciurej Date: Tue, 24 May 2016 16:05:29 -0700 Subject: [PATCH 5/8] Added staging support and improved error handling for METIS@:4 installs. --- .../repos/builtin/packages/metis/package.py | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py index eb0bdf28de..65595229c0 100644 --- a/var/spack/repos/builtin/packages/metis/package.py +++ b/var/spack/repos/builtin/packages/metis/package.py @@ -72,6 +72,8 @@ def install(self, spec, prefix): make(*options) # Compile and install library files + ccompile = Executable(self.compiler.cc) + mkdir(prefix.bin) binfiles = ('pmetis', 'kmetis', 'oemetis', 'onmetis', 'partnmesh', 'partdmesh', 'mesh2nodal', 'mesh2dual', 'graphchk') @@ -86,8 +88,7 @@ def install(self, spec, prefix): install(h, prefix.include) mkdir(prefix.share) - sharefiles = (('Programs', 'io.c'), ('Test', 'mtest.c'), - ('Graphs', '4elt.graph'), ('Graphs', 'metis.mesh'), + sharefiles = (('Graphs', '4elt.graph'), ('Graphs', 'metis.mesh'), ('Graphs', 'test.mgraph')) for sharefile in tuple(join_path(*sf) for sf in sharefiles): install(sharefile, prefix.share) @@ -102,28 +103,20 @@ def install(self, spec, prefix): load_flag = '-Wl,-whole-archive' no_load_flag = '-Wl,-no-whole-archive' - os.system('%s -fPIC -shared %s libmetis.a %s -o libmetis.%s' % \ - (self.compiler.cc, load_flag, no_load_flag, lib_dsuffix)) - install('libmetis.%s' % lib_dsuffix, prefix.lib) + ccompile('-fPIC', '-shared', load_flag, 'libmetis.a', no_load_flag, + '-o', '%s/libmetis.%s' % (prefix.lib, lib_dsuffix)) # Set up and run tests on installation - inc_flags = '-I%s' % prefix.include - lib_flags = '-L%s' % prefix.lib - if '+shared' in spec: - lib_flags += ' -Wl,-rpath=%s' % prefix.lib - - symlink(join_path(prefix.share, 'io.c'), 'io.c') - symlink(join_path(prefix.share, 'mtest.c'), 'mtest.c') - - os.system('%s %s -c io.c' % (self.compiler.cc, inc_flags)) - os.system('%s %s %s mtest.c io.o -o mtest -lmetis -lm' % \ - (self.compiler.cc, inc_flags, lib_flags)) + ccompile('-I%s' % prefix.include, '-L%s' % prefix.lib, + '-Wl,-rpath=%s' % (prefix.lib if '+shared' in spec else ''), + join_path('Programs', 'io.o'), join_path('Test', 'mtest.c'), + '-o', '%s/mtest' % prefix.bin, '-lmetis', '-lm') test_bin = lambda testname: join_path(prefix.bin, testname) test_graph = lambda graphname: join_path(prefix.share, graphname) graph = test_graph('4elt.graph') - os.system('./mtest %s' % graph) + os.system('%s %s' % (test_bin('mtest'), graph)) os.system('%s %s 40' % (test_bin('kmetis'), graph)) os.system('%s %s' % (test_bin('onmetis'), graph)) graph = test_graph('test.mgraph') From 483ec0d76275521579b2d1c93620a37841159e36 Mon Sep 17 00:00:00 2001 From: Joseph Ciurej Date: Tue, 24 May 2016 16:13:52 -0700 Subject: [PATCH 6/8] Added preliminary improved testing code for METIS@:4. --- .../repos/builtin/packages/metis/package.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py index 65595229c0..5ccc04bd5e 100644 --- a/var/spack/repos/builtin/packages/metis/package.py +++ b/var/spack/repos/builtin/packages/metis/package.py @@ -128,6 +128,25 @@ def install(self, spec, prefix): os.system('%s %s 10' % (test_bin('partdmesh'), graph)) os.system('%s %s' % (test_bin('mesh2dual'), graph)) + # TODO: The following code should replace the testing code in the + # block above since it causes installs to fail when one or more of the + # Metis tests fail, but it currently doesn't work because the 'mtest', + # 'onmetis', and 'partnmesh' tests return error codes that trigger + # false positives for failure. + """ + Executable(test_bin('mtest'))(test_graph('4elt.graph')) + Executable(test_bin('kmetis'))(test_graph('4elt.graph'), '40') + Executable(test_bin('onmetis'))(test_graph('4elt.graph')) + + Executable(test_bin('pmetis'))(test_graph('test.mgraph'), '2') + Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '2') + Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '5') + + Executable(test_bin('partnmesh'))(test_graph('metis.mesh'), '10') + Executable(test_bin('partdmesh'))(test_graph('metis.mesh'), '10') + Executable(test_bin('mesh2dual'))(test_graph('metis.mesh')) + """ + @when('@5:') def install(self, spec, prefix): options = [] From 734fb459a45896ee41881ca906643bd362be3e37 Mon Sep 17 00:00:00 2001 From: Joseph Ciurej Date: Wed, 25 May 2016 12:27:52 -0700 Subject: [PATCH 7/8] Fixing a small bug with metis@4+shared installs on the Mac platform. --- .../repos/builtin/packages/metis/package.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py index 5ccc04bd5e..c4f2afaff2 100644 --- a/var/spack/repos/builtin/packages/metis/package.py +++ b/var/spack/repos/builtin/packages/metis/package.py @@ -94,17 +94,19 @@ def install(self, spec, prefix): install(sharefile, prefix.share) if '+shared' in spec: + shared_flags = ['-fPIC', '-shared'] if sys.platform == 'darwin': - lib_dsuffix = 'dylib' - load_flag = '-Wl,-all_load' - no_load_flag = '' + shared_suffix = 'dylib' + shared_flags.extend(['-Wl,-all_load', 'libmetis.a']) else: - lib_dsuffix = 'so' - load_flag = '-Wl,-whole-archive' - no_load_flag = '-Wl,-no-whole-archive' + shared_suffix = 'so' + shared_flags.extend(['-Wl,-whole-archive', 'libmetis.a', + '-Wl,-no-whole-archive']) - ccompile('-fPIC', '-shared', load_flag, 'libmetis.a', no_load_flag, - '-o', '%s/libmetis.%s' % (prefix.lib, lib_dsuffix)) + shared_out = '%s/libmetis.%s' % (prefix.lib, shared_suffix) + shared_flags.extend(['-o', shared_out]) + + ccompile(*shared_flags) # Set up and run tests on installation ccompile('-I%s' % prefix.include, '-L%s' % prefix.lib, @@ -128,7 +130,7 @@ def install(self, spec, prefix): os.system('%s %s 10' % (test_bin('partdmesh'), graph)) os.system('%s %s' % (test_bin('mesh2dual'), graph)) - # TODO: The following code should replace the testing code in the + # FIXME: The following code should replace the testing code in the # block above since it causes installs to fail when one or more of the # Metis tests fail, but it currently doesn't work because the 'mtest', # 'onmetis', and 'partnmesh' tests return error codes that trigger From e95eedb165c54e00d22bd6d5acfdf8c7c55d140e Mon Sep 17 00:00:00 2001 From: Joseph Ciurej Date: Thu, 26 May 2016 14:27:15 -0700 Subject: [PATCH 8/8] Added a style checking exemption for lambda expressions. --- .flake8 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index a1e2fcc1f8..12ae2efa80 100644 --- a/.flake8 +++ b/.flake8 @@ -8,6 +8,9 @@ # - E221: multiple spaces before operator # - E241: multiple spaces after ‘,’ # +# Let people use terse Python features: +# - E731 : lambda expressions +# # Spack allows wildcard imports: # - F403: disable wildcard import # @@ -16,5 +19,5 @@ # - F999: name name be undefined or undefined from star imports. # [flake8] -ignore = E221,E241,F403,F821,F999 +ignore = E221,E241,E731,F403,F821,F999 max-line-length = 79