|
2 | 2 | # |
3 | 3 | # SPDX-License-Identifier: MIT |
4 | 4 |
|
5 | | -import argparse |
6 | 5 | import contextlib |
7 | 6 | import importlib.metadata |
8 | 7 | import os |
@@ -199,22 +198,16 @@ def cleanenv(): |
199 | 198 | def meson_fatal_warnings(): |
200 | 199 | # Cannot use the 'monkeypatch' fixture because of scope mismatch. |
201 | 200 | mpatch = pytest.MonkeyPatch() |
202 | | - mesonpy_get_meson_args = mesonpy._get_meson_args |
203 | | - |
204 | | - def _get_meson_args(args): |
205 | | - meson_args = mesonpy_get_meson_args(args) |
206 | | - meson_setup_args = meson_args['setup'] |
207 | | - |
208 | | - # Add ``--fatal-meson-warnings`` to the ``meson setup`` arguments |
209 | | - # unless the project specifies ``--no-fatal-meson-warnings`` in |
210 | | - # ``tool.meson-build.args.setup``. |
211 | | - parser = argparse.ArgumentParser(add_help=False) |
212 | | - parser.add_argument('--no-fatal-meson-warnings', action='store_true') |
213 | | - args, meson_setup_args = parser.parse_known_args(meson_setup_args) |
214 | | - if not args.no_fatal_meson_warnings: |
215 | | - meson_setup_args.append('--fatal-meson-warnings') |
216 | | - |
217 | | - meson_args['setup'] = meson_setup_args |
218 | | - return meson_args |
219 | | - |
220 | | - mpatch.setattr(mesonpy, '_get_meson_args', _get_meson_args) |
| 201 | + mesonpy_project_init = mesonpy.Project.__init__ |
| 202 | + |
| 203 | + def __init__(self, source_dir, build_dir, meson_args=None, editable_verbose=False): |
| 204 | + if pathlib.Path(source_dir).absolutre().name not in { |
| 205 | + 'cmake-subproject', |
| 206 | + 'link-against-local-lib', |
| 207 | + }: |
| 208 | + if meson_args is None: |
| 209 | + meson_args = {} |
| 210 | + meson_args.setdefault('setup', []).append('--fatal-meson-warnings') |
| 211 | + mesonpy_project_init(self, source_dir, build_dir, meson_args, editable_verbose) |
| 212 | + |
| 213 | + mpatch.setattr(mesonpy.Project, '__init__', __init__) |
0 commit comments