We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Require parallel tools when depending on HDF5
I have an application that specifically requires the availability of `h5pcc` instead of `h5cc`: https://github.com/mesonbuild/meson/blob/39ceb677744e1f959a0db6406d51a26d78f0ab68/mesonbuild/dependencies/hdf5.py#L97-L99

In my case HDF5 is only build with parallel compatibility and therefore `h5cc` is not available. 
My current workaround is to simple edit this line and specify the other tool directly. 

It there a more appropriate workaround for this issue?
Alternatively: Is it possible to add an optional parameter to `hdf5_dep = dependency('hdf5')` e.g. `dependency('hdf5', parallel: true)`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mesonbuild/dependencies/hdf5.py`
Content:
```
1 # Copyright 2013-2019 The Meson development team
2 
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 # This file contains the detection logic for miscellaneous external dependencies.
16 
17 import functools
18 import os
19 import re
20 import shutil
21 import subprocess
22 from pathlib import Path
23 
24 from ..mesonlib import OrderedSet, join_args
25 from .base import DependencyException, DependencyMethods
26 from .configtool import ConfigToolDependency
27 from .pkgconfig import PkgConfigDependency
28 from .factory import factory_methods
29 import typing as T
30 
31 if T.TYPE_CHECKING:
32     from .factory import DependencyGenerator
33     from ..environment import Environment
34     from ..mesonlib import MachineChoice
35 
36 
37 class HDF5PkgConfigDependency(PkgConfigDependency):
38 
39     """Handle brokenness in the HDF5 pkg-config files."""
40 
41     def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None) -> None:
42         language = language or 'c'
43         if language not in {'c', 'cpp', 'fortran'}:
44             raise DependencyException(f'Language {language} is not supported with HDF5.')
45 
46         super().__init__(name, environment, kwargs, language)
47         if not self.is_found:
48             return
49 
50         # some broken pkgconfig don't actually list the full path to the needed includes
51         newinc = []  # type: T.List[str]
52         for arg in self.compile_args:
53             if arg.startswith('-I'):
54                 stem = 'static' if kwargs.get('static', False) else 'shared'
55                 if (Path(arg[2:]) / stem).is_dir():
56                     newinc.append('-I' + str(Path(arg[2:]) / stem))
57         self.compile_args += newinc
58 
59         link_args = []  # type: T.List[str]
60         for larg in self.get_link_args():
61             lpath = Path(larg)
62             # some pkg-config hdf5.pc (e.g. Ubuntu) don't include the commonly-used HL HDF5 libraries,
63             # so let's add them if they exist
64             # additionally, some pkgconfig HDF5 HL files are malformed so let's be sure to find HL anyway
65             if lpath.is_file():
66                 hl = []
67                 if language == 'cpp':
68                     hl += ['_hl_cpp', '_cpp']
69                 elif language == 'fortran':
70                     hl += ['_hl_fortran', 'hl_fortran', '_fortran']
71                 hl += ['_hl']  # C HL library, always needed
72 
73                 suffix = '.' + lpath.name.split('.', 1)[1]  # in case of .dll.a
74                 for h in hl:
75                     hlfn = lpath.parent / (lpath.name.split('.', 1)[0] + h + suffix)
76                     if hlfn.is_file():
77                         link_args.append(str(hlfn))
78                 # HDF5 C libs are required by other HDF5 languages
79                 link_args.append(larg)
80             else:
81                 link_args.append(larg)
82 
83         self.link_args = link_args
84 
85 
86 class HDF5ConfigToolDependency(ConfigToolDependency):
87 
88     """Wrapper around hdf5 binary config tools."""
89 
90     version_arg = '-showconfig'
91 
92     def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None) -> None:
93         language = language or 'c'
94         if language not in {'c', 'cpp', 'fortran'}:
95             raise DependencyException(f'Language {language} is not supported with HDF5.')
96 
97         if language == 'c':
98             cenv = 'CC'
99             tools = ['h5cc']
100         elif language == 'cpp':
101             cenv = 'CXX'
102             tools = ['h5c++']
103         elif language == 'fortran':
104             cenv = 'FC'
105             tools = ['h5fc']
106         else:
107             raise DependencyException('How did you get here?')
108 
109         # We need this before we call super()
110         for_machine = self.get_for_machine_from_kwargs(kwargs)
111 
112         nkwargs = kwargs.copy()
113         nkwargs['tools'] = tools
114 
115         # Override the compiler that the config tools are going to use by
116         # setting the environment variables that they use for the compiler and
117         # linkers.
118         compiler = environment.coredata.compilers[for_machine][language]
119         try:
120             os.environ[f'HDF5_{cenv}'] = join_args(compiler.get_exelist())
121             os.environ[f'HDF5_{cenv}LINKER'] = join_args(compiler.get_linker_exelist())
122             super().__init__(name, environment, nkwargs, language)
123         finally:
124             del os.environ[f'HDF5_{cenv}']
125             del os.environ[f'HDF5_{cenv}LINKER']
126         if not self.is_found:
127             return
128 
129         # We first need to call the tool with -c to get the compile arguments
130         # and then without -c to get the link arguments.
131         args = self.get_config_value(['-show', '-c'], 'args')[1:]
132         args += self.get_config_value(['-show', '-noshlib' if kwargs.get('static', False) else '-shlib'], 'args')[1:]
133         for arg in args:
134             if arg.startswith(('-I', '-f', '-D')) or arg == '-pthread':
135                 self.compile_args.append(arg)
136             elif arg.startswith(('-L', '-l', '-Wl')):
137                 self.link_args.append(arg)
138             elif Path(arg).is_file():
139                 self.link_args.append(arg)
140 
141         # If the language is not C we need to add C as a subdependency
142         if language != 'c':
143             nkwargs = kwargs.copy()
144             nkwargs['language'] = 'c'
145             # I'm being too clever for mypy and pylint
146             self.is_found = self._add_sub_dependency(hdf5_factory(environment, for_machine, nkwargs))  # pylint: disable=no-value-for-parameter
147 
148     def _sanitize_version(self, ver: str) -> str:
149         v = re.search(r'\s*HDF5 Version: (\d+\.\d+\.\d+)', ver)
150         return v.group(1)
151 
152 
153 @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL})
154 def hdf5_factory(env: 'Environment', for_machine: 'MachineChoice',
155                  kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
156     language = kwargs.get('language')
157     candidates: T.List['DependencyGenerator'] = []
158 
159     if DependencyMethods.PKGCONFIG in methods:
160         # Use an ordered set so that these remain the first tried pkg-config files
161         pkgconfig_files = OrderedSet(['hdf5', 'hdf5-serial'])
162         # FIXME: This won't honor pkg-config paths, and cross-native files
163         PCEXE = shutil.which('pkg-config')
164         if PCEXE:
165             # some distros put hdf5-1.2.3.pc with version number in .pc filename.
166             ret = subprocess.run([PCEXE, '--list-all'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
167                                     universal_newlines=True)
168             if ret.returncode == 0:
169                 for pkg in ret.stdout.split('\n'):
170                     if pkg.startswith('hdf5'):
171                         pkgconfig_files.add(pkg.split(' ', 1)[0])
172 
173         for pkg in pkgconfig_files:
174             candidates.append(functools.partial(HDF5PkgConfigDependency, pkg, env, kwargs, language))
175 
176     if DependencyMethods.CONFIG_TOOL in methods:
177         candidates.append(functools.partial(HDF5ConfigToolDependency, 'hdf5', env, kwargs, language))
178 
179     return candidates
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/mesonbuild/dependencies/hdf5.py b/mesonbuild/dependencies/hdf5.py
--- a/mesonbuild/dependencies/hdf5.py
+++ b/mesonbuild/dependencies/hdf5.py
@@ -96,13 +96,13 @@
 
         if language == 'c':
             cenv = 'CC'
-            tools = ['h5cc']
+            tools = ['h5cc', 'h5pcc']
         elif language == 'cpp':
             cenv = 'CXX'
-            tools = ['h5c++']
+            tools = ['h5c++', 'h5pc++']
         elif language == 'fortran':
             cenv = 'FC'
-            tools = ['h5fc']
+            tools = ['h5fc', 'h5pfc']
         else:
             raise DependencyException('How did you get here?')

{"golden_diff": "diff --git a/mesonbuild/dependencies/hdf5.py b/mesonbuild/dependencies/hdf5.py\n--- a/mesonbuild/dependencies/hdf5.py\n+++ b/mesonbuild/dependencies/hdf5.py\n@@ -96,13 +96,13 @@\n \n         if language == 'c':\n             cenv = 'CC'\n-            tools = ['h5cc']\n+            tools = ['h5cc', 'h5pcc']\n         elif language == 'cpp':\n             cenv = 'CXX'\n-            tools = ['h5c++']\n+            tools = ['h5c++', 'h5pc++']\n         elif language == 'fortran':\n             cenv = 'FC'\n-            tools = ['h5fc']\n+            tools = ['h5fc', 'h5pfc']\n         else:\n             raise DependencyException('How did you get here?')\n", "issue": "Require parallel tools when depending on HDF5\nI have an application that specifically requires the availability of `h5pcc` instead of `h5cc`: https://github.com/mesonbuild/meson/blob/39ceb677744e1f959a0db6406d51a26d78f0ab68/mesonbuild/dependencies/hdf5.py#L97-L99\r\n\r\nIn my case HDF5 is only build with parallel compatibility and therefore `h5cc` is not available. \r\nMy current workaround is to simple edit this line and specify the other tool directly. \r\n\r\nIt there a more appropriate workaround for this issue?\r\nAlternatively: Is it possible to add an optional parameter to `hdf5_dep = dependency('hdf5')` e.g. `dependency('hdf5', parallel: true)`\n", "before_files": [{"content": "# Copyright 2013-2019 The Meson development team\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# This file contains the detection logic for miscellaneous external dependencies.\n\nimport functools\nimport os\nimport re\nimport shutil\nimport subprocess\nfrom pathlib import Path\n\nfrom ..mesonlib import OrderedSet, join_args\nfrom .base import DependencyException, DependencyMethods\nfrom .configtool import ConfigToolDependency\nfrom .pkgconfig import PkgConfigDependency\nfrom .factory import factory_methods\nimport typing as T\n\nif T.TYPE_CHECKING:\n    from .factory import DependencyGenerator\n    from ..environment import Environment\n    from ..mesonlib import MachineChoice\n\n\nclass HDF5PkgConfigDependency(PkgConfigDependency):\n\n    \"\"\"Handle brokenness in the HDF5 pkg-config files.\"\"\"\n\n    def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None) -> None:\n        language = language or 'c'\n        if language not in {'c', 'cpp', 'fortran'}:\n            raise DependencyException(f'Language {language} is not supported with HDF5.')\n\n        super().__init__(name, environment, kwargs, language)\n        if not self.is_found:\n            return\n\n        # some broken pkgconfig don't actually list the full path to the needed includes\n        newinc = []  # type: T.List[str]\n        for arg in self.compile_args:\n            if arg.startswith('-I'):\n                stem = 'static' if kwargs.get('static', False) else 'shared'\n                if (Path(arg[2:]) / stem).is_dir():\n                    newinc.append('-I' + str(Path(arg[2:]) / stem))\n        self.compile_args += newinc\n\n        link_args = []  # type: T.List[str]\n        for larg in self.get_link_args():\n            lpath = Path(larg)\n            # some pkg-config hdf5.pc (e.g. Ubuntu) don't include the commonly-used HL HDF5 libraries,\n            # so let's add them if they exist\n            # additionally, some pkgconfig HDF5 HL files are malformed so let's be sure to find HL anyway\n            if lpath.is_file():\n                hl = []\n                if language == 'cpp':\n                    hl += ['_hl_cpp', '_cpp']\n                elif language == 'fortran':\n                    hl += ['_hl_fortran', 'hl_fortran', '_fortran']\n                hl += ['_hl']  # C HL library, always needed\n\n                suffix = '.' + lpath.name.split('.', 1)[1]  # in case of .dll.a\n                for h in hl:\n                    hlfn = lpath.parent / (lpath.name.split('.', 1)[0] + h + suffix)\n                    if hlfn.is_file():\n                        link_args.append(str(hlfn))\n                # HDF5 C libs are required by other HDF5 languages\n                link_args.append(larg)\n            else:\n                link_args.append(larg)\n\n        self.link_args = link_args\n\n\nclass HDF5ConfigToolDependency(ConfigToolDependency):\n\n    \"\"\"Wrapper around hdf5 binary config tools.\"\"\"\n\n    version_arg = '-showconfig'\n\n    def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None) -> None:\n        language = language or 'c'\n        if language not in {'c', 'cpp', 'fortran'}:\n            raise DependencyException(f'Language {language} is not supported with HDF5.')\n\n        if language == 'c':\n            cenv = 'CC'\n            tools = ['h5cc']\n        elif language == 'cpp':\n            cenv = 'CXX'\n            tools = ['h5c++']\n        elif language == 'fortran':\n            cenv = 'FC'\n            tools = ['h5fc']\n        else:\n            raise DependencyException('How did you get here?')\n\n        # We need this before we call super()\n        for_machine = self.get_for_machine_from_kwargs(kwargs)\n\n        nkwargs = kwargs.copy()\n        nkwargs['tools'] = tools\n\n        # Override the compiler that the config tools are going to use by\n        # setting the environment variables that they use for the compiler and\n        # linkers.\n        compiler = environment.coredata.compilers[for_machine][language]\n        try:\n            os.environ[f'HDF5_{cenv}'] = join_args(compiler.get_exelist())\n            os.environ[f'HDF5_{cenv}LINKER'] = join_args(compiler.get_linker_exelist())\n            super().__init__(name, environment, nkwargs, language)\n        finally:\n            del os.environ[f'HDF5_{cenv}']\n            del os.environ[f'HDF5_{cenv}LINKER']\n        if not self.is_found:\n            return\n\n        # We first need to call the tool with -c to get the compile arguments\n        # and then without -c to get the link arguments.\n        args = self.get_config_value(['-show', '-c'], 'args')[1:]\n        args += self.get_config_value(['-show', '-noshlib' if kwargs.get('static', False) else '-shlib'], 'args')[1:]\n        for arg in args:\n            if arg.startswith(('-I', '-f', '-D')) or arg == '-pthread':\n                self.compile_args.append(arg)\n            elif arg.startswith(('-L', '-l', '-Wl')):\n                self.link_args.append(arg)\n            elif Path(arg).is_file():\n                self.link_args.append(arg)\n\n        # If the language is not C we need to add C as a subdependency\n        if language != 'c':\n            nkwargs = kwargs.copy()\n            nkwargs['language'] = 'c'\n            # I'm being too clever for mypy and pylint\n            self.is_found = self._add_sub_dependency(hdf5_factory(environment, for_machine, nkwargs))  # pylint: disable=no-value-for-parameter\n\n    def _sanitize_version(self, ver: str) -> str:\n        v = re.search(r'\\s*HDF5 Version: (\\d+\\.\\d+\\.\\d+)', ver)\n        return v.group(1)\n\n\n@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL})\ndef hdf5_factory(env: 'Environment', for_machine: 'MachineChoice',\n                 kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:\n    language = kwargs.get('language')\n    candidates: T.List['DependencyGenerator'] = []\n\n    if DependencyMethods.PKGCONFIG in methods:\n        # Use an ordered set so that these remain the first tried pkg-config files\n        pkgconfig_files = OrderedSet(['hdf5', 'hdf5-serial'])\n        # FIXME: This won't honor pkg-config paths, and cross-native files\n        PCEXE = shutil.which('pkg-config')\n        if PCEXE:\n            # some distros put hdf5-1.2.3.pc with version number in .pc filename.\n            ret = subprocess.run([PCEXE, '--list-all'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,\n                                    universal_newlines=True)\n            if ret.returncode == 0:\n                for pkg in ret.stdout.split('\\n'):\n                    if pkg.startswith('hdf5'):\n                        pkgconfig_files.add(pkg.split(' ', 1)[0])\n\n        for pkg in pkgconfig_files:\n            candidates.append(functools.partial(HDF5PkgConfigDependency, pkg, env, kwargs, language))\n\n    if DependencyMethods.CONFIG_TOOL in methods:\n        candidates.append(functools.partial(HDF5ConfigToolDependency, 'hdf5', env, kwargs, language))\n\n    return candidates\n", "path": "mesonbuild/dependencies/hdf5.py"}], "after_files": [{"content": "# Copyright 2013-2019 The Meson development team\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# This file contains the detection logic for miscellaneous external dependencies.\n\nimport functools\nimport os\nimport re\nimport shutil\nimport subprocess\nfrom pathlib import Path\n\nfrom ..mesonlib import OrderedSet, join_args\nfrom .base import DependencyException, DependencyMethods\nfrom .configtool import ConfigToolDependency\nfrom .pkgconfig import PkgConfigDependency\nfrom .factory import factory_methods\nimport typing as T\n\nif T.TYPE_CHECKING:\n    from .factory import DependencyGenerator\n    from ..environment import Environment\n    from ..mesonlib import MachineChoice\n\n\nclass HDF5PkgConfigDependency(PkgConfigDependency):\n\n    \"\"\"Handle brokenness in the HDF5 pkg-config files.\"\"\"\n\n    def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None) -> None:\n        language = language or 'c'\n        if language not in {'c', 'cpp', 'fortran'}:\n            raise DependencyException(f'Language {language} is not supported with HDF5.')\n\n        super().__init__(name, environment, kwargs, language)\n        if not self.is_found:\n            return\n\n        # some broken pkgconfig don't actually list the full path to the needed includes\n        newinc = []  # type: T.List[str]\n        for arg in self.compile_args:\n            if arg.startswith('-I'):\n                stem = 'static' if kwargs.get('static', False) else 'shared'\n                if (Path(arg[2:]) / stem).is_dir():\n                    newinc.append('-I' + str(Path(arg[2:]) / stem))\n        self.compile_args += newinc\n\n        link_args = []  # type: T.List[str]\n        for larg in self.get_link_args():\n            lpath = Path(larg)\n            # some pkg-config hdf5.pc (e.g. Ubuntu) don't include the commonly-used HL HDF5 libraries,\n            # so let's add them if they exist\n            # additionally, some pkgconfig HDF5 HL files are malformed so let's be sure to find HL anyway\n            if lpath.is_file():\n                hl = []\n                if language == 'cpp':\n                    hl += ['_hl_cpp', '_cpp']\n                elif language == 'fortran':\n                    hl += ['_hl_fortran', 'hl_fortran', '_fortran']\n                hl += ['_hl']  # C HL library, always needed\n\n                suffix = '.' + lpath.name.split('.', 1)[1]  # in case of .dll.a\n                for h in hl:\n                    hlfn = lpath.parent / (lpath.name.split('.', 1)[0] + h + suffix)\n                    if hlfn.is_file():\n                        link_args.append(str(hlfn))\n                # HDF5 C libs are required by other HDF5 languages\n                link_args.append(larg)\n            else:\n                link_args.append(larg)\n\n        self.link_args = link_args\n\n\nclass HDF5ConfigToolDependency(ConfigToolDependency):\n\n    \"\"\"Wrapper around hdf5 binary config tools.\"\"\"\n\n    version_arg = '-showconfig'\n\n    def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None) -> None:\n        language = language or 'c'\n        if language not in {'c', 'cpp', 'fortran'}:\n            raise DependencyException(f'Language {language} is not supported with HDF5.')\n\n        if language == 'c':\n            cenv = 'CC'\n            tools = ['h5cc', 'h5pcc']\n        elif language == 'cpp':\n            cenv = 'CXX'\n            tools = ['h5c++', 'h5pc++']\n        elif language == 'fortran':\n            cenv = 'FC'\n            tools = ['h5fc', 'h5pfc']\n        else:\n            raise DependencyException('How did you get here?')\n\n        # We need this before we call super()\n        for_machine = self.get_for_machine_from_kwargs(kwargs)\n\n        nkwargs = kwargs.copy()\n        nkwargs['tools'] = tools\n\n        # Override the compiler that the config tools are going to use by\n        # setting the environment variables that they use for the compiler and\n        # linkers.\n        compiler = environment.coredata.compilers[for_machine][language]\n        try:\n            os.environ[f'HDF5_{cenv}'] = join_args(compiler.get_exelist())\n            os.environ[f'HDF5_{cenv}LINKER'] = join_args(compiler.get_linker_exelist())\n            super().__init__(name, environment, nkwargs, language)\n        finally:\n            del os.environ[f'HDF5_{cenv}']\n            del os.environ[f'HDF5_{cenv}LINKER']\n        if not self.is_found:\n            return\n\n        # We first need to call the tool with -c to get the compile arguments\n        # and then without -c to get the link arguments.\n        args = self.get_config_value(['-show', '-c'], 'args')[1:]\n        args += self.get_config_value(['-show', '-noshlib' if kwargs.get('static', False) else '-shlib'], 'args')[1:]\n        for arg in args:\n            if arg.startswith(('-I', '-f', '-D')) or arg == '-pthread':\n                self.compile_args.append(arg)\n            elif arg.startswith(('-L', '-l', '-Wl')):\n                self.link_args.append(arg)\n            elif Path(arg).is_file():\n                self.link_args.append(arg)\n\n        # If the language is not C we need to add C as a subdependency\n        if language != 'c':\n            nkwargs = kwargs.copy()\n            nkwargs['language'] = 'c'\n            # I'm being too clever for mypy and pylint\n            self.is_found = self._add_sub_dependency(hdf5_factory(environment, for_machine, nkwargs))  # pylint: disable=no-value-for-parameter\n\n    def _sanitize_version(self, ver: str) -> str:\n        v = re.search(r'\\s*HDF5 Version: (\\d+\\.\\d+\\.\\d+)', ver)\n        return v.group(1)\n\n\n@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL})\ndef hdf5_factory(env: 'Environment', for_machine: 'MachineChoice',\n                 kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:\n    language = kwargs.get('language')\n    candidates: T.List['DependencyGenerator'] = []\n\n    if DependencyMethods.PKGCONFIG in methods:\n        # Use an ordered set so that these remain the first tried pkg-config files\n        pkgconfig_files = OrderedSet(['hdf5', 'hdf5-serial'])\n        # FIXME: This won't honor pkg-config paths, and cross-native files\n        PCEXE = shutil.which('pkg-config')\n        if PCEXE:\n            # some distros put hdf5-1.2.3.pc with version number in .pc filename.\n            ret = subprocess.run([PCEXE, '--list-all'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,\n                                    universal_newlines=True)\n            if ret.returncode == 0:\n                for pkg in ret.stdout.split('\\n'):\n                    if pkg.startswith('hdf5'):\n                        pkgconfig_files.add(pkg.split(' ', 1)[0])\n\n        for pkg in pkgconfig_files:\n            candidates.append(functools.partial(HDF5PkgConfigDependency, pkg, env, kwargs, language))\n\n    if DependencyMethods.CONFIG_TOOL in methods:\n        candidates.append(functools.partial(HDF5ConfigToolDependency, 'hdf5', env, kwargs, language))\n\n    return candidates\n", "path": "mesonbuild/dependencies/hdf5.py"}]}