Build a module via Meson and import it.
(source_files, module_name=None, **kwargs)
| 311 | |
| 312 | |
| 313 | def build_meson(source_files, module_name=None, **kwargs): |
| 314 | """ |
| 315 | Build a module via Meson and import it. |
| 316 | """ |
| 317 | |
| 318 | # gh-27045 : Skip if no compilers are found |
| 319 | if not has_fortran_compiler(): |
| 320 | pytest.skip("No Fortran compiler available") |
| 321 | |
| 322 | build_dir = get_module_dir() |
| 323 | if module_name is None: |
| 324 | module_name = get_temp_module_name() |
| 325 | |
| 326 | # Initialize the MesonBackend |
| 327 | backend = SimplifiedMesonBackend( |
| 328 | modulename=module_name, |
| 329 | sources=source_files, |
| 330 | extra_objects=kwargs.get("extra_objects", []), |
| 331 | build_dir=build_dir, |
| 332 | include_dirs=kwargs.get("include_dirs", []), |
| 333 | library_dirs=kwargs.get("library_dirs", []), |
| 334 | libraries=kwargs.get("libraries", []), |
| 335 | define_macros=kwargs.get("define_macros", []), |
| 336 | undef_macros=kwargs.get("undef_macros", []), |
| 337 | f2py_flags=kwargs.get("f2py_flags", []), |
| 338 | sysinfo_flags=kwargs.get("sysinfo_flags", []), |
| 339 | fc_flags=kwargs.get("fc_flags", []), |
| 340 | flib_flags=kwargs.get("flib_flags", []), |
| 341 | setup_flags=kwargs.get("setup_flags", []), |
| 342 | remove_build_dir=kwargs.get("remove_build_dir", False), |
| 343 | extra_dat=kwargs.get("extra_dat", {}), |
| 344 | ) |
| 345 | |
| 346 | backend.compile() |
| 347 | |
| 348 | # Import the compiled module |
| 349 | sys.path.insert(0, f"{build_dir}/{backend.meson_build_dir}") |
| 350 | return import_module(module_name) |
| 351 | |
| 352 | |
| 353 | # |
nothing calls this directly
no test coverage detected
searching dependent graphs…