We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
metis 4.0.3 doesn't install on macOS 10.11.6 with appleclang 7.0.3
A gist of the installation log is at https://gist.github.com/goxberry/b9ca39f4d7c5cd6b0905aaaa42f53746

If I had to guess, the error at the end of the log re: the RPATH option `-rpath=$STUFF` is the problem; IIRC, that syntax works on GCC, but not with LLVM/clang. Replacing `-rpath=` with `-rpath,` (that is, replace the equals sign with a comma) should work for both GCC and LLVM/clang compilers.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `var/spack/repos/builtin/packages/metis/package.py`
Content:
```
1 ##############################################################################
2 # Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
3 # Produced at the Lawrence Livermore National Laboratory.
4 #
5 # This file is part of Spack.
6 # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
7 # LLNL-CODE-647188
8 #
9 # For details, see https://github.com/llnl/spack
10 # Please also see the LICENSE file for our notice and the LGPL.
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License (as
14 # published by the Free Software Foundation) version 2.1, February 1999.
15 #
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
19 # conditions of the GNU Lesser General Public License for more details.
20 #
21 # You should have received a copy of the GNU Lesser General Public
22 # License along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ##############################################################################
25 
26 from spack import *
27 import glob
28 import sys
29 import os
30 
31 
32 class Metis(Package):
33     """METIS is a set of serial programs for partitioning graphs, partitioning
34        finite element meshes, and producing fill reducing orderings for sparse
35        matrices. The algorithms implemented in METIS are based on the
36        multilevel recursive-bisection, multilevel k-way, and multi-constraint
37        partitioning schemes."""
38 
39     homepage = "http://glaros.dtc.umn.edu/gkhome/metis/metis/overview"
40     url      = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz"
41     list_url = "http://glaros.dtc.umn.edu/gkhome/fsroot/sw/metis/OLD"
42 
43     version('5.1.0', '5465e67079419a69e0116de24fce58fe')
44     version('5.0.2', 'acb521a4e8c2e6dd559a7f9abd0468c5')
45     version('4.0.3', 'd3848b454532ef18dc83e4fb160d1e10')
46 
47     variant('shared', default=True, description='Enables the build of shared libraries.')
48     variant('debug', default=False, description='Builds the library in debug mode.')
49     variant('gdb', default=False, description='Enables gdb support.')
50 
51     variant('int64', default=False, description='Sets the bit width of METIS\'s index type to 64.')
52     variant('real64', default=False, description='Sets the bit width of METIS\'s real type to 64.')
53 
54     depends_on('cmake@2.8:', when='@5:', type='build')
55 
56     patch('install_gklib_defs_rename.patch', when='@5:')
57 
58     def url_for_version(self, version):
59         url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis"
60         if version < Version('4.0.3'):
61             url += "/OLD"
62         url += "/metis-{0}.tar.gz".format(version)
63         return url
64 
65     @when('@5:')
66     def patch(self):
67         source_path = self.stage.source_path
68         metis_header = FileFilter(join_path(source_path, 'include', 'metis.h'))
69 
70         metis_header.filter(
71             r'(\b)(IDXTYPEWIDTH )(\d+)(\b)',
72             r'\1\2{0}\4'.format('64' if '+int64' in self.spec else '32'),
73         )
74         metis_header.filter(
75             r'(\b)(REALTYPEWIDTH )(\d+)(\b)',
76             r'\1\2{0}\4'.format('64' if '+real64' in self.spec else '32'),
77         )
78 
79         # Make clang 7.3 happy.
80         # Prevents "ld: section __DATA/__thread_bss extends beyond end of file"
81         # See upstream LLVM issue https://llvm.org/bugs/show_bug.cgi?id=27059
82         # and https://github.com/Homebrew/homebrew-science/blob/master/metis.rb
83         if self.spec.satisfies('%clang@7.3.0'):
84             filter_file('#define MAX_JBUFS 128', '#define MAX_JBUFS 24',
85                         join_path(source_path, 'GKlib', 'error.c'))
86 
87     @when('@:4')
88     def install(self, spec, prefix):
89         # Process library spec and options
90         if any('+{0}'.format(v) in spec for v in ['gdb', 'int64', 'real64']):
91             raise InstallError('METIS@:4 does not support the following '
92                                'variants: gdb, int64, real64.')
93 
94         options = ['COPTIONS=-fPIC']
95         if '+debug' in spec:
96             options.append('OPTFLAGS=-g -O0')
97         make(*options)
98 
99         # Compile and install library files
100         ccompile = Executable(self.compiler.cc)
101 
102         mkdir(prefix.bin)
103         binfiles = ('pmetis', 'kmetis', 'oemetis', 'onmetis', 'partnmesh',
104                     'partdmesh', 'mesh2nodal', 'mesh2dual', 'graphchk')
105         for binfile in binfiles:
106             install(binfile, prefix.bin)
107 
108         mkdir(prefix.lib)
109         install('libmetis.a', prefix.lib)
110 
111         mkdir(prefix.include)
112         for h in glob.glob(join_path('Lib', '*.h')):
113             install(h, prefix.include)
114 
115         mkdir(prefix.share)
116         sharefiles = (('Graphs', '4elt.graph'), ('Graphs', 'metis.mesh'),
117                       ('Graphs', 'test.mgraph'))
118         for sharefile in tuple(join_path(*sf) for sf in sharefiles):
119             install(sharefile, prefix.share)
120 
121         if '+shared' in spec:
122             shared_flags = ['-fPIC', '-shared']
123             if sys.platform == 'darwin':
124                 shared_suffix = 'dylib'
125                 shared_flags.extend(['-Wl,-all_load', 'libmetis.a'])
126             else:
127                 shared_suffix = 'so'
128                 shared_flags.extend(['-Wl,-whole-archive', 'libmetis.a',
129                                      '-Wl,-no-whole-archive'])
130 
131             shared_out = '%s/libmetis.%s' % (prefix.lib, shared_suffix)
132             shared_flags.extend(['-o', shared_out])
133 
134             ccompile(*shared_flags)
135 
136         # Set up and run tests on installation
137         ccompile('-I%s' % prefix.include, '-L%s' % prefix.lib,
138                  '-Wl,-rpath=%s' % (prefix.lib if '+shared' in spec else ''),
139                  join_path('Programs', 'io.o'), join_path('Test', 'mtest.c'),
140                  '-o', '%s/mtest' % prefix.bin, '-lmetis', '-lm')
141 
142         if self.run_tests:
143             test_bin = lambda testname: join_path(prefix.bin, testname)
144             test_graph = lambda graphname: join_path(prefix.share, graphname)
145 
146             graph = test_graph('4elt.graph')
147             os.system('%s %s' % (test_bin('mtest'), graph))
148             os.system('%s %s 40' % (test_bin('kmetis'), graph))
149             os.system('%s %s' % (test_bin('onmetis'), graph))
150             graph = test_graph('test.mgraph')
151             os.system('%s %s 2' % (test_bin('pmetis'), graph))
152             os.system('%s %s 2' % (test_bin('kmetis'), graph))
153             os.system('%s %s 5' % (test_bin('kmetis'), graph))
154             graph = test_graph('metis.mesh')
155             os.system('%s %s 10' % (test_bin('partnmesh'), graph))
156             os.system('%s %s 10' % (test_bin('partdmesh'), graph))
157             os.system('%s %s' % (test_bin('mesh2dual'), graph))
158 
159             # FIXME: The following code should replace the testing code in the
160             # block above since it causes installs to fail when one or more of
161             # the Metis tests fail, but it currently doesn't work because the
162             # 'mtest', 'onmetis', and 'partnmesh' tests return error codes that
163             # trigger false positives for failure.
164             """
165             Executable(test_bin('mtest'))(test_graph('4elt.graph'))
166             Executable(test_bin('kmetis'))(test_graph('4elt.graph'), '40')
167             Executable(test_bin('onmetis'))(test_graph('4elt.graph'))
168 
169             Executable(test_bin('pmetis'))(test_graph('test.mgraph'), '2')
170             Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '2')
171             Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '5')
172 
173             Executable(test_bin('partnmesh'))(test_graph('metis.mesh'), '10')
174             Executable(test_bin('partdmesh'))(test_graph('metis.mesh'), '10')
175             Executable(test_bin('mesh2dual'))(test_graph('metis.mesh'))
176             """
177 
178     @when('@5:')
179     def install(self, spec, prefix):
180         source_directory = self.stage.source_path
181         build_directory = join_path(source_directory, 'build')
182 
183         options = std_cmake_args[:]
184         options.append('-DGKLIB_PATH:PATH=%s/GKlib' % source_directory)
185         options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix)
186 
187         if '+shared' in spec:
188             options.append('-DSHARED:BOOL=ON')
189         else:
190             # Remove all RPATH options
191             # (RPATHxxx options somehow trigger cmake to link dynamically)
192             rpath_options = []
193             for o in options:
194                 if o.find('RPATH') >= 0:
195                     rpath_options.append(o)
196             for o in rpath_options:
197                 options.remove(o)
198         if '+debug' in spec:
199             options.extend(['-DDEBUG:BOOL=ON',
200                             '-DCMAKE_BUILD_TYPE:STRING=Debug'])
201         if '+gdb' in spec:
202             options.append('-DGDB:BOOL=ON')
203 
204         with working_dir(build_directory, create=True):
205             cmake(source_directory, *options)
206             make()
207             make('install')
208 
209             # install GKlib headers, which will be needed for ParMETIS
210             GKlib_dist = join_path(prefix.include, 'GKlib')
211             mkdirp(GKlib_dist)
212             hfiles = glob.glob(join_path(source_directory, 'GKlib', '*.h'))
213             for hfile in hfiles:
214                 install(hfile, GKlib_dist)
215 
216         if self.run_tests:
217             # FIXME: On some systems, the installed binaries for METIS cannot
218             # be executed without first being read.
219             ls = which('ls')
220             ls('-a', '-l', prefix.bin)
221 
222             for f in ['4elt', 'copter2', 'mdual']:
223                 graph = join_path(source_directory, 'graphs', '%s.graph' % f)
224                 Executable(join_path(prefix.bin, 'graphchk'))(graph)
225                 Executable(join_path(prefix.bin, 'gpmetis'))(graph, '2')
226                 Executable(join_path(prefix.bin, 'ndmetis'))(graph)
227 
228             graph = join_path(source_directory, 'graphs', 'test.mgraph')
229             Executable(join_path(prefix.bin, 'gpmetis'))(graph, '2')
230             graph = join_path(source_directory, 'graphs', 'metis.mesh')
231             Executable(join_path(prefix.bin, 'mpmetis'))(graph, '2')
232
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py
--- a/var/spack/repos/builtin/packages/metis/package.py
+++ b/var/spack/repos/builtin/packages/metis/package.py
@@ -135,7 +135,8 @@
 
         # Set up and run tests on installation
         ccompile('-I%s' % prefix.include, '-L%s' % prefix.lib,
-                 '-Wl,-rpath=%s' % (prefix.lib if '+shared' in spec else ''),
+                 self.compiler.cc_rpath_arg +
+                 '%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')

{"golden_diff": "diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py\n--- a/var/spack/repos/builtin/packages/metis/package.py\n+++ b/var/spack/repos/builtin/packages/metis/package.py\n@@ -135,7 +135,8 @@\n \n         # Set up and run tests on installation\n         ccompile('-I%s' % prefix.include, '-L%s' % prefix.lib,\n-                 '-Wl,-rpath=%s' % (prefix.lib if '+shared' in spec else ''),\n+                 self.compiler.cc_rpath_arg +\n+                 '%s' % (prefix.lib if '+shared' in spec else ''),\n                  join_path('Programs', 'io.o'), join_path('Test', 'mtest.c'),\n                  '-o', '%s/mtest' % prefix.bin, '-lmetis', '-lm')\n", "issue": "metis 4.0.3 doesn't install on macOS 10.11.6 with appleclang 7.0.3\nA gist of the installation log is at https://gist.github.com/goxberry/b9ca39f4d7c5cd6b0905aaaa42f53746\r\n\r\nIf I had to guess, the error at the end of the log re: the RPATH option `-rpath=$STUFF` is the problem; IIRC, that syntax works on GCC, but not with LLVM/clang. Replacing `-rpath=` with `-rpath,` (that is, replace the equals sign with a comma) should work for both GCC and LLVM/clang compilers.\n", "before_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/llnl/spack\n# Please also see the LICENSE file for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\n\nfrom spack import *\nimport glob\nimport sys\nimport os\n\n\nclass Metis(Package):\n    \"\"\"METIS is a set of serial programs for partitioning graphs, partitioning\n       finite element meshes, and producing fill reducing orderings for sparse\n       matrices. The algorithms implemented in METIS are based on the\n       multilevel recursive-bisection, multilevel k-way, and multi-constraint\n       partitioning schemes.\"\"\"\n\n    homepage = \"http://glaros.dtc.umn.edu/gkhome/metis/metis/overview\"\n    url      = \"http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz\"\n    list_url = \"http://glaros.dtc.umn.edu/gkhome/fsroot/sw/metis/OLD\"\n\n    version('5.1.0', '5465e67079419a69e0116de24fce58fe')\n    version('5.0.2', 'acb521a4e8c2e6dd559a7f9abd0468c5')\n    version('4.0.3', 'd3848b454532ef18dc83e4fb160d1e10')\n\n    variant('shared', default=True, description='Enables the build of shared libraries.')\n    variant('debug', default=False, description='Builds the library in debug mode.')\n    variant('gdb', default=False, description='Enables gdb support.')\n\n    variant('int64', default=False, description='Sets the bit width of METIS\\'s index type to 64.')\n    variant('real64', default=False, description='Sets the bit width of METIS\\'s real type to 64.')\n\n    depends_on('cmake@2.8:', when='@5:', type='build')\n\n    patch('install_gklib_defs_rename.patch', when='@5:')\n\n    def url_for_version(self, version):\n        url = \"http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis\"\n        if version < Version('4.0.3'):\n            url += \"/OLD\"\n        url += \"/metis-{0}.tar.gz\".format(version)\n        return url\n\n    @when('@5:')\n    def patch(self):\n        source_path = self.stage.source_path\n        metis_header = FileFilter(join_path(source_path, 'include', 'metis.h'))\n\n        metis_header.filter(\n            r'(\\b)(IDXTYPEWIDTH )(\\d+)(\\b)',\n            r'\\1\\2{0}\\4'.format('64' if '+int64' in self.spec else '32'),\n        )\n        metis_header.filter(\n            r'(\\b)(REALTYPEWIDTH )(\\d+)(\\b)',\n            r'\\1\\2{0}\\4'.format('64' if '+real64' in self.spec else '32'),\n        )\n\n        # Make clang 7.3 happy.\n        # Prevents \"ld: section __DATA/__thread_bss extends beyond end of file\"\n        # See upstream LLVM issue https://llvm.org/bugs/show_bug.cgi?id=27059\n        # and https://github.com/Homebrew/homebrew-science/blob/master/metis.rb\n        if self.spec.satisfies('%clang@7.3.0'):\n            filter_file('#define MAX_JBUFS 128', '#define MAX_JBUFS 24',\n                        join_path(source_path, 'GKlib', 'error.c'))\n\n    @when('@:4')\n    def install(self, spec, prefix):\n        # Process library spec and options\n        if any('+{0}'.format(v) in spec for v in ['gdb', 'int64', 'real64']):\n            raise InstallError('METIS@:4 does not support the following '\n                               'variants: gdb, int64, real64.')\n\n        options = ['COPTIONS=-fPIC']\n        if '+debug' in spec:\n            options.append('OPTFLAGS=-g -O0')\n        make(*options)\n\n        # Compile and install library files\n        ccompile = Executable(self.compiler.cc)\n\n        mkdir(prefix.bin)\n        binfiles = ('pmetis', 'kmetis', 'oemetis', 'onmetis', 'partnmesh',\n                    'partdmesh', 'mesh2nodal', 'mesh2dual', 'graphchk')\n        for binfile in binfiles:\n            install(binfile, prefix.bin)\n\n        mkdir(prefix.lib)\n        install('libmetis.a', prefix.lib)\n\n        mkdir(prefix.include)\n        for h in glob.glob(join_path('Lib', '*.h')):\n            install(h, prefix.include)\n\n        mkdir(prefix.share)\n        sharefiles = (('Graphs', '4elt.graph'), ('Graphs', 'metis.mesh'),\n                      ('Graphs', 'test.mgraph'))\n        for sharefile in tuple(join_path(*sf) for sf in sharefiles):\n            install(sharefile, prefix.share)\n\n        if '+shared' in spec:\n            shared_flags = ['-fPIC', '-shared']\n            if sys.platform == 'darwin':\n                shared_suffix = 'dylib'\n                shared_flags.extend(['-Wl,-all_load', 'libmetis.a'])\n            else:\n                shared_suffix = 'so'\n                shared_flags.extend(['-Wl,-whole-archive', 'libmetis.a',\n                                     '-Wl,-no-whole-archive'])\n\n            shared_out = '%s/libmetis.%s' % (prefix.lib, shared_suffix)\n            shared_flags.extend(['-o', shared_out])\n\n            ccompile(*shared_flags)\n\n        # Set up and run tests on installation\n        ccompile('-I%s' % prefix.include, '-L%s' % prefix.lib,\n                 '-Wl,-rpath=%s' % (prefix.lib if '+shared' in spec else ''),\n                 join_path('Programs', 'io.o'), join_path('Test', 'mtest.c'),\n                 '-o', '%s/mtest' % prefix.bin, '-lmetis', '-lm')\n\n        if self.run_tests:\n            test_bin = lambda testname: join_path(prefix.bin, testname)\n            test_graph = lambda graphname: join_path(prefix.share, graphname)\n\n            graph = test_graph('4elt.graph')\n            os.system('%s %s' % (test_bin('mtest'), graph))\n            os.system('%s %s 40' % (test_bin('kmetis'), graph))\n            os.system('%s %s' % (test_bin('onmetis'), graph))\n            graph = test_graph('test.mgraph')\n            os.system('%s %s 2' % (test_bin('pmetis'), graph))\n            os.system('%s %s 2' % (test_bin('kmetis'), graph))\n            os.system('%s %s 5' % (test_bin('kmetis'), graph))\n            graph = test_graph('metis.mesh')\n            os.system('%s %s 10' % (test_bin('partnmesh'), graph))\n            os.system('%s %s 10' % (test_bin('partdmesh'), graph))\n            os.system('%s %s' % (test_bin('mesh2dual'), graph))\n\n            # FIXME: The following code should replace the testing code in the\n            # block above since it causes installs to fail when one or more of\n            # the Metis tests fail, but it currently doesn't work because the\n            # 'mtest', 'onmetis', and 'partnmesh' tests return error codes that\n            # trigger false positives for failure.\n            \"\"\"\n            Executable(test_bin('mtest'))(test_graph('4elt.graph'))\n            Executable(test_bin('kmetis'))(test_graph('4elt.graph'), '40')\n            Executable(test_bin('onmetis'))(test_graph('4elt.graph'))\n\n            Executable(test_bin('pmetis'))(test_graph('test.mgraph'), '2')\n            Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '2')\n            Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '5')\n\n            Executable(test_bin('partnmesh'))(test_graph('metis.mesh'), '10')\n            Executable(test_bin('partdmesh'))(test_graph('metis.mesh'), '10')\n            Executable(test_bin('mesh2dual'))(test_graph('metis.mesh'))\n            \"\"\"\n\n    @when('@5:')\n    def install(self, spec, prefix):\n        source_directory = self.stage.source_path\n        build_directory = join_path(source_directory, 'build')\n\n        options = std_cmake_args[:]\n        options.append('-DGKLIB_PATH:PATH=%s/GKlib' % source_directory)\n        options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix)\n\n        if '+shared' in spec:\n            options.append('-DSHARED:BOOL=ON')\n        else:\n            # Remove all RPATH options\n            # (RPATHxxx options somehow trigger cmake to link dynamically)\n            rpath_options = []\n            for o in options:\n                if o.find('RPATH') >= 0:\n                    rpath_options.append(o)\n            for o in rpath_options:\n                options.remove(o)\n        if '+debug' in spec:\n            options.extend(['-DDEBUG:BOOL=ON',\n                            '-DCMAKE_BUILD_TYPE:STRING=Debug'])\n        if '+gdb' in spec:\n            options.append('-DGDB:BOOL=ON')\n\n        with working_dir(build_directory, create=True):\n            cmake(source_directory, *options)\n            make()\n            make('install')\n\n            # install GKlib headers, which will be needed for ParMETIS\n            GKlib_dist = join_path(prefix.include, 'GKlib')\n            mkdirp(GKlib_dist)\n            hfiles = glob.glob(join_path(source_directory, 'GKlib', '*.h'))\n            for hfile in hfiles:\n                install(hfile, GKlib_dist)\n\n        if self.run_tests:\n            # FIXME: On some systems, the installed binaries for METIS cannot\n            # be executed without first being read.\n            ls = which('ls')\n            ls('-a', '-l', prefix.bin)\n\n            for f in ['4elt', 'copter2', 'mdual']:\n                graph = join_path(source_directory, 'graphs', '%s.graph' % f)\n                Executable(join_path(prefix.bin, 'graphchk'))(graph)\n                Executable(join_path(prefix.bin, 'gpmetis'))(graph, '2')\n                Executable(join_path(prefix.bin, 'ndmetis'))(graph)\n\n            graph = join_path(source_directory, 'graphs', 'test.mgraph')\n            Executable(join_path(prefix.bin, 'gpmetis'))(graph, '2')\n            graph = join_path(source_directory, 'graphs', 'metis.mesh')\n            Executable(join_path(prefix.bin, 'mpmetis'))(graph, '2')\n", "path": "var/spack/repos/builtin/packages/metis/package.py"}], "after_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/llnl/spack\n# Please also see the LICENSE file for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\n\nfrom spack import *\nimport glob\nimport sys\nimport os\n\n\nclass Metis(Package):\n    \"\"\"METIS is a set of serial programs for partitioning graphs, partitioning\n       finite element meshes, and producing fill reducing orderings for sparse\n       matrices. The algorithms implemented in METIS are based on the\n       multilevel recursive-bisection, multilevel k-way, and multi-constraint\n       partitioning schemes.\"\"\"\n\n    homepage = \"http://glaros.dtc.umn.edu/gkhome/metis/metis/overview\"\n    url      = \"http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz\"\n    list_url = \"http://glaros.dtc.umn.edu/gkhome/fsroot/sw/metis/OLD\"\n\n    version('5.1.0', '5465e67079419a69e0116de24fce58fe')\n    version('5.0.2', 'acb521a4e8c2e6dd559a7f9abd0468c5')\n    version('4.0.3', 'd3848b454532ef18dc83e4fb160d1e10')\n\n    variant('shared', default=True, description='Enables the build of shared libraries.')\n    variant('debug', default=False, description='Builds the library in debug mode.')\n    variant('gdb', default=False, description='Enables gdb support.')\n\n    variant('int64', default=False, description='Sets the bit width of METIS\\'s index type to 64.')\n    variant('real64', default=False, description='Sets the bit width of METIS\\'s real type to 64.')\n\n    depends_on('cmake@2.8:', when='@5:', type='build')\n\n    patch('install_gklib_defs_rename.patch', when='@5:')\n\n    def url_for_version(self, version):\n        url = \"http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis\"\n        if version < Version('4.0.3'):\n            url += \"/OLD\"\n        url += \"/metis-{0}.tar.gz\".format(version)\n        return url\n\n    @when('@5:')\n    def patch(self):\n        source_path = self.stage.source_path\n        metis_header = FileFilter(join_path(source_path, 'include', 'metis.h'))\n\n        metis_header.filter(\n            r'(\\b)(IDXTYPEWIDTH )(\\d+)(\\b)',\n            r'\\1\\2{0}\\4'.format('64' if '+int64' in self.spec else '32'),\n        )\n        metis_header.filter(\n            r'(\\b)(REALTYPEWIDTH )(\\d+)(\\b)',\n            r'\\1\\2{0}\\4'.format('64' if '+real64' in self.spec else '32'),\n        )\n\n        # Make clang 7.3 happy.\n        # Prevents \"ld: section __DATA/__thread_bss extends beyond end of file\"\n        # See upstream LLVM issue https://llvm.org/bugs/show_bug.cgi?id=27059\n        # and https://github.com/Homebrew/homebrew-science/blob/master/metis.rb\n        if self.spec.satisfies('%clang@7.3.0'):\n            filter_file('#define MAX_JBUFS 128', '#define MAX_JBUFS 24',\n                        join_path(source_path, 'GKlib', 'error.c'))\n\n    @when('@:4')\n    def install(self, spec, prefix):\n        # Process library spec and options\n        if any('+{0}'.format(v) in spec for v in ['gdb', 'int64', 'real64']):\n            raise InstallError('METIS@:4 does not support the following '\n                               'variants: gdb, int64, real64.')\n\n        options = ['COPTIONS=-fPIC']\n        if '+debug' in spec:\n            options.append('OPTFLAGS=-g -O0')\n        make(*options)\n\n        # Compile and install library files\n        ccompile = Executable(self.compiler.cc)\n\n        mkdir(prefix.bin)\n        binfiles = ('pmetis', 'kmetis', 'oemetis', 'onmetis', 'partnmesh',\n                    'partdmesh', 'mesh2nodal', 'mesh2dual', 'graphchk')\n        for binfile in binfiles:\n            install(binfile, prefix.bin)\n\n        mkdir(prefix.lib)\n        install('libmetis.a', prefix.lib)\n\n        mkdir(prefix.include)\n        for h in glob.glob(join_path('Lib', '*.h')):\n            install(h, prefix.include)\n\n        mkdir(prefix.share)\n        sharefiles = (('Graphs', '4elt.graph'), ('Graphs', 'metis.mesh'),\n                      ('Graphs', 'test.mgraph'))\n        for sharefile in tuple(join_path(*sf) for sf in sharefiles):\n            install(sharefile, prefix.share)\n\n        if '+shared' in spec:\n            shared_flags = ['-fPIC', '-shared']\n            if sys.platform == 'darwin':\n                shared_suffix = 'dylib'\n                shared_flags.extend(['-Wl,-all_load', 'libmetis.a'])\n            else:\n                shared_suffix = 'so'\n                shared_flags.extend(['-Wl,-whole-archive', 'libmetis.a',\n                                     '-Wl,-no-whole-archive'])\n\n            shared_out = '%s/libmetis.%s' % (prefix.lib, shared_suffix)\n            shared_flags.extend(['-o', shared_out])\n\n            ccompile(*shared_flags)\n\n        # Set up and run tests on installation\n        ccompile('-I%s' % prefix.include, '-L%s' % prefix.lib,\n                 self.compiler.cc_rpath_arg +\n                 '%s' % (prefix.lib if '+shared' in spec else ''),\n                 join_path('Programs', 'io.o'), join_path('Test', 'mtest.c'),\n                 '-o', '%s/mtest' % prefix.bin, '-lmetis', '-lm')\n\n        if self.run_tests:\n            test_bin = lambda testname: join_path(prefix.bin, testname)\n            test_graph = lambda graphname: join_path(prefix.share, graphname)\n\n            graph = test_graph('4elt.graph')\n            os.system('%s %s' % (test_bin('mtest'), graph))\n            os.system('%s %s 40' % (test_bin('kmetis'), graph))\n            os.system('%s %s' % (test_bin('onmetis'), graph))\n            graph = test_graph('test.mgraph')\n            os.system('%s %s 2' % (test_bin('pmetis'), graph))\n            os.system('%s %s 2' % (test_bin('kmetis'), graph))\n            os.system('%s %s 5' % (test_bin('kmetis'), graph))\n            graph = test_graph('metis.mesh')\n            os.system('%s %s 10' % (test_bin('partnmesh'), graph))\n            os.system('%s %s 10' % (test_bin('partdmesh'), graph))\n            os.system('%s %s' % (test_bin('mesh2dual'), graph))\n\n            # FIXME: The following code should replace the testing code in the\n            # block above since it causes installs to fail when one or more of\n            # the Metis tests fail, but it currently doesn't work because the\n            # 'mtest', 'onmetis', and 'partnmesh' tests return error codes that\n            # trigger false positives for failure.\n            \"\"\"\n            Executable(test_bin('mtest'))(test_graph('4elt.graph'))\n            Executable(test_bin('kmetis'))(test_graph('4elt.graph'), '40')\n            Executable(test_bin('onmetis'))(test_graph('4elt.graph'))\n\n            Executable(test_bin('pmetis'))(test_graph('test.mgraph'), '2')\n            Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '2')\n            Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '5')\n\n            Executable(test_bin('partnmesh'))(test_graph('metis.mesh'), '10')\n            Executable(test_bin('partdmesh'))(test_graph('metis.mesh'), '10')\n            Executable(test_bin('mesh2dual'))(test_graph('metis.mesh'))\n            \"\"\"\n\n    @when('@5:')\n    def install(self, spec, prefix):\n        source_directory = self.stage.source_path\n        build_directory = join_path(source_directory, 'build')\n\n        options = std_cmake_args[:]\n        options.append('-DGKLIB_PATH:PATH=%s/GKlib' % source_directory)\n        options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix)\n\n        if '+shared' in spec:\n            options.append('-DSHARED:BOOL=ON')\n        else:\n            # Remove all RPATH options\n            # (RPATHxxx options somehow trigger cmake to link dynamically)\n            rpath_options = []\n            for o in options:\n                if o.find('RPATH') >= 0:\n                    rpath_options.append(o)\n            for o in rpath_options:\n                options.remove(o)\n        if '+debug' in spec:\n            options.extend(['-DDEBUG:BOOL=ON',\n                            '-DCMAKE_BUILD_TYPE:STRING=Debug'])\n        if '+gdb' in spec:\n            options.append('-DGDB:BOOL=ON')\n\n        with working_dir(build_directory, create=True):\n            cmake(source_directory, *options)\n            make()\n            make('install')\n\n            # install GKlib headers, which will be needed for ParMETIS\n            GKlib_dist = join_path(prefix.include, 'GKlib')\n            mkdirp(GKlib_dist)\n            hfiles = glob.glob(join_path(source_directory, 'GKlib', '*.h'))\n            for hfile in hfiles:\n                install(hfile, GKlib_dist)\n\n        if self.run_tests:\n            # FIXME: On some systems, the installed binaries for METIS cannot\n            # be executed without first being read.\n            ls = which('ls')\n            ls('-a', '-l', prefix.bin)\n\n            for f in ['4elt', 'copter2', 'mdual']:\n                graph = join_path(source_directory, 'graphs', '%s.graph' % f)\n                Executable(join_path(prefix.bin, 'graphchk'))(graph)\n                Executable(join_path(prefix.bin, 'gpmetis'))(graph, '2')\n                Executable(join_path(prefix.bin, 'ndmetis'))(graph)\n\n            graph = join_path(source_directory, 'graphs', 'test.mgraph')\n            Executable(join_path(prefix.bin, 'gpmetis'))(graph, '2')\n            graph = join_path(source_directory, 'graphs', 'metis.mesh')\n            Executable(join_path(prefix.bin, 'mpmetis'))(graph, '2')\n", "path": "var/spack/repos/builtin/packages/metis/package.py"}]}