We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Threaded mpi should be disabled by default in SCOTCH for all toolchains
https://github.com/easybuilders/easybuild-easyblocks/blob/2ecd3c97fa1563c7634adf4467f5081fd2debca1/easybuild/easyblocks/s/scotch.py#L112-L115

Comment indicates that it should have been dropped a long time ago. Lets do it for EB 5.0

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `easybuild/easyblocks/s/scotch.py`
Content:
```
1 ##
2 # Copyright 2009-2023 Ghent University
3 #
4 # This file is part of EasyBuild,
5 # originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
6 # with support of Ghent University (http://ugent.be/hpc),
7 # the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),
8 # Flemish Research Foundation (FWO) (http://www.fwo.be/en)
9 # and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
10 #
11 # https://github.com/easybuilders/easybuild
12 #
13 # EasyBuild is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation v2.
16 #
17 # EasyBuild is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with EasyBuild.  If not, see <http://www.gnu.org/licenses/>.
24 ##
25 """
26 EasyBuild support for SCOTCH, implemented as an easyblock
27 
28 @author: Stijn De Weirdt (Ghent University)
29 @author: Dries Verdegem (Ghent University)
30 @author: Kenneth Hoste (Ghent University)
31 @author: Pieter De Baets (Ghent University)
32 @author: Jens Timmerman (Ghent University)
33 """
34 import os
35 from distutils.version import LooseVersion
36 
37 import easybuild.tools.toolchain as toolchain
38 from easybuild.framework.easyblock import EasyBlock
39 from easybuild.framework.easyconfig import CUSTOM
40 from easybuild.tools.build_log import EasyBuildError
41 from easybuild.tools.filetools import apply_regex_substitutions, change_dir, copy_dir, copy_file
42 from easybuild.tools.filetools import remove_file, write_file
43 from easybuild.tools.run import run_cmd
44 
45 
46 class EB_SCOTCH(EasyBlock):
47     """Support for building/installing SCOTCH."""
48 
49     @staticmethod
50     def extra_options(extra_vars=None):
51         """Define custom easyconfig parameters specific to Scotch."""
52         extra_vars = {
53             'threadedmpi': [None, "Use threaded MPI calls.", CUSTOM],
54         }
55         return EasyBlock.extra_options(extra_vars)
56 
57     def configure_step(self):
58         """Configure SCOTCH build: locate the template makefile, copy it to a general Makefile.inc and patch it."""
59 
60         # pick template makefile
61         comp_fam = self.toolchain.comp_family()
62         if comp_fam == toolchain.INTELCOMP:  # @UndefinedVariable
63             makefilename = 'Makefile.inc.x86-64_pc_linux2.icc'
64         elif comp_fam == toolchain.GCC:  # @UndefinedVariable
65             makefilename = 'Makefile.inc.x86-64_pc_linux2'
66         else:
67             raise EasyBuildError("Unknown compiler family used: %s", comp_fam)
68 
69         srcdir = os.path.join(self.cfg['start_dir'], 'src')
70 
71         # create Makefile.inc
72         makefile_inc = os.path.join(srcdir, 'Makefile.inc')
73         copy_file(os.path.join(srcdir, 'Make.inc', makefilename), makefile_inc)
74         self.log.debug("Successfully copied Makefile.inc to src dir: %s", makefile_inc)
75 
76         # the default behaviour of these makefiles is still wrong
77         # e.g., compiler settings, and we need -lpthread
78         regex_subs = [
79             (r"^CCS\s*=.*$", "CCS\t= $(CC)"),
80             (r"^CCP\s*=.*$", "CCP\t= $(MPICC)"),
81             (r"^CCD\s*=.*$", "CCD\t= $(MPICC)"),
82             # append -lpthread to LDFLAGS
83             (r"^LDFLAGS\s*=(?P<ldflags>.*$)", r"LDFLAGS\t=\g<ldflags> -lpthread"),
84             # prepend -L${EBROOTZLIB}/lib to LDFLAGS
85             (r"^LDFLAGS\s*=(?P<ldflags>.*$)", r"LDFLAGS\t=-L${EBROOTZLIB}/lib \g<ldflags>"),
86         ]
87         apply_regex_substitutions(makefile_inc, regex_subs)
88 
89         # change to src dir for building
90         change_dir(srcdir)
91 
92     def build_step(self):
93         """Build by running build_step, but with some special options for SCOTCH depending on the compiler."""
94 
95         ccs = os.environ['CC']
96         ccp = os.environ['MPICC']
97         ccd = os.environ['MPICC']
98 
99         cflags = "-fPIC -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME"
100         if self.toolchain.comp_family() == toolchain.GCC:  # @UndefinedVariable
101             cflags += " -Drestrict=__restrict"
102         else:
103             cflags += " -restrict -DIDXSIZE64"
104 
105         # USE 64 bit index
106         if self.toolchain.options['i8']:
107             cflags += " -DINTSIZE64"
108 
109         if self.cfg['threadedmpi']:
110             cflags += " -DSCOTCH_PTHREAD"
111 
112         # For backwards compatability of v2.8.0 this is necessary but could be removed on a major version upgrade
113         mpi_family = self.toolchain.mpi_family()
114         if self.cfg['threadedmpi'] is None and mpi_family not in [toolchain.INTELMPI, toolchain.QLOGICMPI]:
115             cflags += " -DSCOTCH_PTHREAD"
116 
117         # actually build
118         apps = ['scotch', 'ptscotch']
119         if LooseVersion(self.version) >= LooseVersion('6.0'):
120             # separate target for esmumps in recent versions
121             apps.extend(['esmumps', 'ptesmumps'])
122 
123         for app in apps:
124             cmd = 'make CCS="%s" CCP="%s" CCD="%s" CFLAGS="%s" %s' % (ccs, ccp, ccd, cflags, app)
125             run_cmd(cmd, log_all=True, simple=True)
126 
127     def install_step(self):
128         """Install by copying files and creating group library file."""
129 
130         self.log.debug("Installing SCOTCH by copying files")
131 
132         for subdir in ['bin', 'include', 'lib', 'man']:
133             copy_dir(os.path.join(self.cfg['start_dir'], subdir), os.path.join(self.installdir, subdir))
134 
135         # remove metis.h and parmetis.h include files, since those can only cause trouble
136         for header in ['metis.h', 'parmetis.h']:
137             remove_file(os.path.join(self.installdir, 'include', header))
138 
139         # create group library file
140         scotchlibdir = os.path.join(self.installdir, 'lib')
141         scotchgrouplib = os.path.join(scotchlibdir, 'libscotch_group.a')
142 
143         line = "GROUP (%s)" % ' '.join(os.listdir(scotchlibdir))
144         write_file(scotchgrouplib, line)
145         self.log.info("Successfully written group lib file: %s", scotchgrouplib)
146 
147     def sanity_check_step(self):
148         """Custom sanity check for SCOTCH."""
149 
150         custom_paths = {
151             'files': [],
152             'dirs': [],
153         }
154 
155         binaries = ['acpl', 'amk_ccc', 'amk_fft2', 'amk_grf', 'amk_hy', 'amk_m2', 'amk_p2', 'atst',
156                     'dggath', 'dgmap', 'dgord', 'dgpart', 'dgscat', 'dgtst', 'gbase', 'gcv', 'gmap',
157                     'gmk_hy', 'gmk_m2', 'gmk_m3', 'gmk_msh', 'gmk_ub2', 'gmtst', 'gord', 'gotst',
158                     'gout', 'gpart', 'gscat', 'gtst', 'mcv', 'mmk_m2', 'mmk_m3', 'mord', 'mtst']
159         custom_paths['files'].extend([os.path.join('bin', x) for x in binaries])
160 
161         headers = ['esmumps', 'ptscotch', 'ptscotchf', 'scotch', 'scotchf']
162         custom_paths['files'].extend([os.path.join('include', '%s.h' % x) for x in headers])
163 
164         libraries = ['esmumps', 'ptesmumps', 'ptscotch', 'ptscotcherr', 'ptscotcherrexit',
165                      'scotch', 'scotch_group', 'scotcherr', 'scotcherrexit']
166         custom_paths['files'].extend([os.path.join('lib', 'lib%s.a' % x) for x in libraries])
167 
168         custom_commands = []
169 
170         # only hard check for recent SCOTCH versions;
171         # older versions like '5.1.12b_esmumps' require more effort (not worth it)
172         if LooseVersion(self.version) > LooseVersion('6.0.0'):
173             # make sure installed SCOTCH version matches what we expect,
174             # since it's easy to download the wrong tarball
175             # cfr. https://github.com/easybuilders/easybuild-easyconfigs/issues/7154
176             # (for '5.1.12b_esmumps', check with 'version 5.1.12')
177             custom_commands.append("acpl -V 2>&1 | grep 'version %s'" % self.version.split('_')[0].strip('ab'))
178 
179         super(EB_SCOTCH, self).sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands)
180
```
--- 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/easybuild/easyblocks/s/scotch.py b/easybuild/easyblocks/s/scotch.py
--- a/easybuild/easyblocks/s/scotch.py
+++ b/easybuild/easyblocks/s/scotch.py
@@ -109,11 +109,6 @@
         if self.cfg['threadedmpi']:
             cflags += " -DSCOTCH_PTHREAD"
 
-        # For backwards compatability of v2.8.0 this is necessary but could be removed on a major version upgrade
-        mpi_family = self.toolchain.mpi_family()
-        if self.cfg['threadedmpi'] is None and mpi_family not in [toolchain.INTELMPI, toolchain.QLOGICMPI]:
-            cflags += " -DSCOTCH_PTHREAD"
-
         # actually build
         apps = ['scotch', 'ptscotch']
         if LooseVersion(self.version) >= LooseVersion('6.0'):

{"golden_diff": "diff --git a/easybuild/easyblocks/s/scotch.py b/easybuild/easyblocks/s/scotch.py\n--- a/easybuild/easyblocks/s/scotch.py\n+++ b/easybuild/easyblocks/s/scotch.py\n@@ -109,11 +109,6 @@\n         if self.cfg['threadedmpi']:\n             cflags += \" -DSCOTCH_PTHREAD\"\n \n-        # For backwards compatability of v2.8.0 this is necessary but could be removed on a major version upgrade\n-        mpi_family = self.toolchain.mpi_family()\n-        if self.cfg['threadedmpi'] is None and mpi_family not in [toolchain.INTELMPI, toolchain.QLOGICMPI]:\n-            cflags += \" -DSCOTCH_PTHREAD\"\n-\n         # actually build\n         apps = ['scotch', 'ptscotch']\n         if LooseVersion(self.version) >= LooseVersion('6.0'):\n", "issue": "Threaded mpi should be disabled by default in SCOTCH for all toolchains\nhttps://github.com/easybuilders/easybuild-easyblocks/blob/2ecd3c97fa1563c7634adf4467f5081fd2debca1/easybuild/easyblocks/s/scotch.py#L112-L115\r\n\r\nComment indicates that it should have been dropped a long time ago. Lets do it for EB 5.0\n", "before_files": [{"content": "##\n# Copyright 2009-2023 Ghent University\n#\n# This file is part of EasyBuild,\n# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),\n# with support of Ghent University (http://ugent.be/hpc),\n# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),\n# Flemish Research Foundation (FWO) (http://www.fwo.be/en)\n# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).\n#\n# https://github.com/easybuilders/easybuild\n#\n# EasyBuild is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation v2.\n#\n# EasyBuild is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with EasyBuild.  If not, see <http://www.gnu.org/licenses/>.\n##\n\"\"\"\nEasyBuild support for SCOTCH, implemented as an easyblock\n\n@author: Stijn De Weirdt (Ghent University)\n@author: Dries Verdegem (Ghent University)\n@author: Kenneth Hoste (Ghent University)\n@author: Pieter De Baets (Ghent University)\n@author: Jens Timmerman (Ghent University)\n\"\"\"\nimport os\nfrom distutils.version import LooseVersion\n\nimport easybuild.tools.toolchain as toolchain\nfrom easybuild.framework.easyblock import EasyBlock\nfrom easybuild.framework.easyconfig import CUSTOM\nfrom easybuild.tools.build_log import EasyBuildError\nfrom easybuild.tools.filetools import apply_regex_substitutions, change_dir, copy_dir, copy_file\nfrom easybuild.tools.filetools import remove_file, write_file\nfrom easybuild.tools.run import run_cmd\n\n\nclass EB_SCOTCH(EasyBlock):\n    \"\"\"Support for building/installing SCOTCH.\"\"\"\n\n    @staticmethod\n    def extra_options(extra_vars=None):\n        \"\"\"Define custom easyconfig parameters specific to Scotch.\"\"\"\n        extra_vars = {\n            'threadedmpi': [None, \"Use threaded MPI calls.\", CUSTOM],\n        }\n        return EasyBlock.extra_options(extra_vars)\n\n    def configure_step(self):\n        \"\"\"Configure SCOTCH build: locate the template makefile, copy it to a general Makefile.inc and patch it.\"\"\"\n\n        # pick template makefile\n        comp_fam = self.toolchain.comp_family()\n        if comp_fam == toolchain.INTELCOMP:  # @UndefinedVariable\n            makefilename = 'Makefile.inc.x86-64_pc_linux2.icc'\n        elif comp_fam == toolchain.GCC:  # @UndefinedVariable\n            makefilename = 'Makefile.inc.x86-64_pc_linux2'\n        else:\n            raise EasyBuildError(\"Unknown compiler family used: %s\", comp_fam)\n\n        srcdir = os.path.join(self.cfg['start_dir'], 'src')\n\n        # create Makefile.inc\n        makefile_inc = os.path.join(srcdir, 'Makefile.inc')\n        copy_file(os.path.join(srcdir, 'Make.inc', makefilename), makefile_inc)\n        self.log.debug(\"Successfully copied Makefile.inc to src dir: %s\", makefile_inc)\n\n        # the default behaviour of these makefiles is still wrong\n        # e.g., compiler settings, and we need -lpthread\n        regex_subs = [\n            (r\"^CCS\\s*=.*$\", \"CCS\\t= $(CC)\"),\n            (r\"^CCP\\s*=.*$\", \"CCP\\t= $(MPICC)\"),\n            (r\"^CCD\\s*=.*$\", \"CCD\\t= $(MPICC)\"),\n            # append -lpthread to LDFLAGS\n            (r\"^LDFLAGS\\s*=(?P<ldflags>.*$)\", r\"LDFLAGS\\t=\\g<ldflags> -lpthread\"),\n            # prepend -L${EBROOTZLIB}/lib to LDFLAGS\n            (r\"^LDFLAGS\\s*=(?P<ldflags>.*$)\", r\"LDFLAGS\\t=-L${EBROOTZLIB}/lib \\g<ldflags>\"),\n        ]\n        apply_regex_substitutions(makefile_inc, regex_subs)\n\n        # change to src dir for building\n        change_dir(srcdir)\n\n    def build_step(self):\n        \"\"\"Build by running build_step, but with some special options for SCOTCH depending on the compiler.\"\"\"\n\n        ccs = os.environ['CC']\n        ccp = os.environ['MPICC']\n        ccd = os.environ['MPICC']\n\n        cflags = \"-fPIC -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME\"\n        if self.toolchain.comp_family() == toolchain.GCC:  # @UndefinedVariable\n            cflags += \" -Drestrict=__restrict\"\n        else:\n            cflags += \" -restrict -DIDXSIZE64\"\n\n        # USE 64 bit index\n        if self.toolchain.options['i8']:\n            cflags += \" -DINTSIZE64\"\n\n        if self.cfg['threadedmpi']:\n            cflags += \" -DSCOTCH_PTHREAD\"\n\n        # For backwards compatability of v2.8.0 this is necessary but could be removed on a major version upgrade\n        mpi_family = self.toolchain.mpi_family()\n        if self.cfg['threadedmpi'] is None and mpi_family not in [toolchain.INTELMPI, toolchain.QLOGICMPI]:\n            cflags += \" -DSCOTCH_PTHREAD\"\n\n        # actually build\n        apps = ['scotch', 'ptscotch']\n        if LooseVersion(self.version) >= LooseVersion('6.0'):\n            # separate target for esmumps in recent versions\n            apps.extend(['esmumps', 'ptesmumps'])\n\n        for app in apps:\n            cmd = 'make CCS=\"%s\" CCP=\"%s\" CCD=\"%s\" CFLAGS=\"%s\" %s' % (ccs, ccp, ccd, cflags, app)\n            run_cmd(cmd, log_all=True, simple=True)\n\n    def install_step(self):\n        \"\"\"Install by copying files and creating group library file.\"\"\"\n\n        self.log.debug(\"Installing SCOTCH by copying files\")\n\n        for subdir in ['bin', 'include', 'lib', 'man']:\n            copy_dir(os.path.join(self.cfg['start_dir'], subdir), os.path.join(self.installdir, subdir))\n\n        # remove metis.h and parmetis.h include files, since those can only cause trouble\n        for header in ['metis.h', 'parmetis.h']:\n            remove_file(os.path.join(self.installdir, 'include', header))\n\n        # create group library file\n        scotchlibdir = os.path.join(self.installdir, 'lib')\n        scotchgrouplib = os.path.join(scotchlibdir, 'libscotch_group.a')\n\n        line = \"GROUP (%s)\" % ' '.join(os.listdir(scotchlibdir))\n        write_file(scotchgrouplib, line)\n        self.log.info(\"Successfully written group lib file: %s\", scotchgrouplib)\n\n    def sanity_check_step(self):\n        \"\"\"Custom sanity check for SCOTCH.\"\"\"\n\n        custom_paths = {\n            'files': [],\n            'dirs': [],\n        }\n\n        binaries = ['acpl', 'amk_ccc', 'amk_fft2', 'amk_grf', 'amk_hy', 'amk_m2', 'amk_p2', 'atst',\n                    'dggath', 'dgmap', 'dgord', 'dgpart', 'dgscat', 'dgtst', 'gbase', 'gcv', 'gmap',\n                    'gmk_hy', 'gmk_m2', 'gmk_m3', 'gmk_msh', 'gmk_ub2', 'gmtst', 'gord', 'gotst',\n                    'gout', 'gpart', 'gscat', 'gtst', 'mcv', 'mmk_m2', 'mmk_m3', 'mord', 'mtst']\n        custom_paths['files'].extend([os.path.join('bin', x) for x in binaries])\n\n        headers = ['esmumps', 'ptscotch', 'ptscotchf', 'scotch', 'scotchf']\n        custom_paths['files'].extend([os.path.join('include', '%s.h' % x) for x in headers])\n\n        libraries = ['esmumps', 'ptesmumps', 'ptscotch', 'ptscotcherr', 'ptscotcherrexit',\n                     'scotch', 'scotch_group', 'scotcherr', 'scotcherrexit']\n        custom_paths['files'].extend([os.path.join('lib', 'lib%s.a' % x) for x in libraries])\n\n        custom_commands = []\n\n        # only hard check for recent SCOTCH versions;\n        # older versions like '5.1.12b_esmumps' require more effort (not worth it)\n        if LooseVersion(self.version) > LooseVersion('6.0.0'):\n            # make sure installed SCOTCH version matches what we expect,\n            # since it's easy to download the wrong tarball\n            # cfr. https://github.com/easybuilders/easybuild-easyconfigs/issues/7154\n            # (for '5.1.12b_esmumps', check with 'version 5.1.12')\n            custom_commands.append(\"acpl -V 2>&1 | grep 'version %s'\" % self.version.split('_')[0].strip('ab'))\n\n        super(EB_SCOTCH, self).sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands)\n", "path": "easybuild/easyblocks/s/scotch.py"}], "after_files": [{"content": "##\n# Copyright 2009-2022 Ghent University\n#\n# This file is part of EasyBuild,\n# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),\n# with support of Ghent University (http://ugent.be/hpc),\n# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),\n# Flemish Research Foundation (FWO) (http://www.fwo.be/en)\n# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).\n#\n# https://github.com/easybuilders/easybuild\n#\n# EasyBuild is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation v2.\n#\n# EasyBuild is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with EasyBuild.  If not, see <http://www.gnu.org/licenses/>.\n##\n\"\"\"\nEasyBuild support for SCOTCH, implemented as an easyblock\n\n@author: Stijn De Weirdt (Ghent University)\n@author: Dries Verdegem (Ghent University)\n@author: Kenneth Hoste (Ghent University)\n@author: Pieter De Baets (Ghent University)\n@author: Jens Timmerman (Ghent University)\n\"\"\"\nimport os\nfrom distutils.version import LooseVersion\n\nimport easybuild.tools.toolchain as toolchain\nfrom easybuild.framework.easyblock import EasyBlock\nfrom easybuild.framework.easyconfig import CUSTOM\nfrom easybuild.tools.build_log import EasyBuildError\nfrom easybuild.tools.filetools import apply_regex_substitutions, change_dir, copy_dir, copy_file\nfrom easybuild.tools.filetools import remove_file, write_file\nfrom easybuild.tools.run import run_cmd\n\n\nclass EB_SCOTCH(EasyBlock):\n    \"\"\"Support for building/installing SCOTCH.\"\"\"\n\n    @staticmethod\n    def extra_options(extra_vars=None):\n        \"\"\"Define custom easyconfig parameters specific to Scotch.\"\"\"\n        extra_vars = {\n            'threadedmpi': [None, \"Use threaded MPI calls.\", CUSTOM],\n        }\n        return EasyBlock.extra_options(extra_vars)\n\n    def configure_step(self):\n        \"\"\"Configure SCOTCH build: locate the template makefile, copy it to a general Makefile.inc and patch it.\"\"\"\n\n        # pick template makefile\n        comp_fam = self.toolchain.comp_family()\n        if comp_fam == toolchain.INTELCOMP:  # @UndefinedVariable\n            makefilename = 'Makefile.inc.x86-64_pc_linux2.icc'\n        elif comp_fam == toolchain.GCC:  # @UndefinedVariable\n            makefilename = 'Makefile.inc.x86-64_pc_linux2'\n        else:\n            raise EasyBuildError(\"Unknown compiler family used: %s\", comp_fam)\n\n        srcdir = os.path.join(self.cfg['start_dir'], 'src')\n\n        # create Makefile.inc\n        makefile_inc = os.path.join(srcdir, 'Makefile.inc')\n        copy_file(os.path.join(srcdir, 'Make.inc', makefilename), makefile_inc)\n        self.log.debug(\"Successfully copied Makefile.inc to src dir: %s\", makefile_inc)\n\n        # the default behaviour of these makefiles is still wrong\n        # e.g., compiler settings, and we need -lpthread\n        regex_subs = [\n            (r\"^CCS\\s*=.*$\", \"CCS\\t= $(CC)\"),\n            (r\"^CCP\\s*=.*$\", \"CCP\\t= $(MPICC)\"),\n            (r\"^CCD\\s*=.*$\", \"CCD\\t= $(MPICC)\"),\n            # append -lpthread to LDFLAGS\n            (r\"^LDFLAGS\\s*=(?P<ldflags>.*$)\", r\"LDFLAGS\\t=\\g<ldflags> -lpthread\"),\n            # prepend -L${EBROOTZLIB}/lib to LDFLAGS\n            (r\"^LDFLAGS\\s*=(?P<ldflags>.*$)\", r\"LDFLAGS\\t=-L${EBROOTZLIB}/lib \\g<ldflags>\"),\n        ]\n        apply_regex_substitutions(makefile_inc, regex_subs)\n\n        # change to src dir for building\n        change_dir(srcdir)\n\n    def build_step(self):\n        \"\"\"Build by running build_step, but with some special options for SCOTCH depending on the compiler.\"\"\"\n\n        ccs = os.environ['CC']\n        ccp = os.environ['MPICC']\n        ccd = os.environ['MPICC']\n\n        cflags = \"-fPIC -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME\"\n        if self.toolchain.comp_family() == toolchain.GCC:  # @UndefinedVariable\n            cflags += \" -Drestrict=__restrict\"\n        else:\n            cflags += \" -restrict -DIDXSIZE64\"\n\n        # USE 64 bit index\n        if self.toolchain.options['i8']:\n            cflags += \" -DINTSIZE64\"\n\n        if self.cfg['threadedmpi']:\n            cflags += \" -DSCOTCH_PTHREAD\"\n\n        # actually build\n        apps = ['scotch', 'ptscotch']\n        if LooseVersion(self.version) >= LooseVersion('6.0'):\n            # separate target for esmumps in recent versions\n            apps.extend(['esmumps', 'ptesmumps'])\n\n        for app in apps:\n            cmd = 'make CCS=\"%s\" CCP=\"%s\" CCD=\"%s\" CFLAGS=\"%s\" %s' % (ccs, ccp, ccd, cflags, app)\n            run_cmd(cmd, log_all=True, simple=True)\n\n    def install_step(self):\n        \"\"\"Install by copying files and creating group library file.\"\"\"\n\n        self.log.debug(\"Installing SCOTCH by copying files\")\n\n        for subdir in ['bin', 'include', 'lib', 'man']:\n            copy_dir(os.path.join(self.cfg['start_dir'], subdir), os.path.join(self.installdir, subdir))\n\n        # remove metis.h and parmetis.h include files, since those can only cause trouble\n        for header in ['metis.h', 'parmetis.h']:\n            remove_file(os.path.join(self.installdir, 'include', header))\n\n        # create group library file\n        scotchlibdir = os.path.join(self.installdir, 'lib')\n        scotchgrouplib = os.path.join(scotchlibdir, 'libscotch_group.a')\n\n        line = \"GROUP (%s)\" % ' '.join(os.listdir(scotchlibdir))\n        write_file(scotchgrouplib, line)\n        self.log.info(\"Successfully written group lib file: %s\", scotchgrouplib)\n\n    def sanity_check_step(self):\n        \"\"\"Custom sanity check for SCOTCH.\"\"\"\n\n        custom_paths = {\n            'files': [],\n            'dirs': [],\n        }\n\n        binaries = ['acpl', 'amk_ccc', 'amk_fft2', 'amk_grf', 'amk_hy', 'amk_m2', 'amk_p2', 'atst',\n                    'dggath', 'dgmap', 'dgord', 'dgpart', 'dgscat', 'dgtst', 'gbase', 'gcv', 'gmap',\n                    'gmk_hy', 'gmk_m2', 'gmk_m3', 'gmk_msh', 'gmk_ub2', 'gmtst', 'gord', 'gotst',\n                    'gout', 'gpart', 'gscat', 'gtst', 'mcv', 'mmk_m2', 'mmk_m3', 'mord', 'mtst']\n        custom_paths['files'].extend([os.path.join('bin', x) for x in binaries])\n\n        headers = ['esmumps', 'ptscotch', 'ptscotchf', 'scotch', 'scotchf']\n        custom_paths['files'].extend([os.path.join('include', '%s.h' % x) for x in headers])\n\n        libraries = ['esmumps', 'ptesmumps', 'ptscotch', 'ptscotcherr', 'ptscotcherrexit',\n                     'scotch', 'scotch_group', 'scotcherr', 'scotcherrexit']\n        custom_paths['files'].extend([os.path.join('lib', 'lib%s.a' % x) for x in libraries])\n\n        custom_commands = []\n\n        # only hard check for recent SCOTCH versions;\n        # older versions like '5.1.12b_esmumps' require more effort (not worth it)\n        if LooseVersion(self.version) > LooseVersion('6.0.0'):\n            # make sure installed SCOTCH version matches what we expect,\n            # since it's easy to download the wrong tarball\n            # cfr. https://github.com/easybuilders/easybuild-easyconfigs/issues/7154\n            # (for '5.1.12b_esmumps', check with 'version 5.1.12')\n            custom_commands.append(\"acpl -V 2>&1 | grep 'version %s'\" % self.version.split('_')[0].strip('ab'))\n\n        super(EB_SCOTCH, self).sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands)\n", "path": "easybuild/easyblocks/s/scotch.py"}]}