MCPcopy Create free account
hub / github.com/numpy/numpy / MesonTemplate

Class MesonTemplate

numpy/f2py/_backends/_meson.py:14–134  ·  view source on GitHub ↗

Template meson build file generation class.

Source from the content-addressed store, hash-verified

12
13
14class MesonTemplate:
15 """Template meson build file generation class."""
16
17 def __init__(
18 self,
19 modulename: str,
20 sources: list[Path],
21 deps: list[str],
22 libraries: list[str],
23 library_dirs: list[Path],
24 include_dirs: list[Path],
25 object_files: list[Path],
26 linker_args: list[str],
27 fortran_args: list[str],
28 build_type: str,
29 python_exe: str,
30 ):
31 self.modulename = modulename
32 self.build_template_path = (
33 Path(__file__).parent.absolute() / "meson.build.template"
34 )
35 self.sources = sources
36 self.deps = deps
37 self.libraries = libraries
38 self.library_dirs = library_dirs
39 if include_dirs is not None:
40 self.include_dirs = include_dirs
41 else:
42 self.include_dirs = []
43 self.substitutions = {}
44 self.objects = object_files
45 # Convert args to '' wrapped variant for meson
46 self.fortran_args = [
47 f"'{x}'" if not (x.startswith("'") and x.endswith("'")) else x
48 for x in fortran_args
49 ]
50 self.pipeline = [
51 self.initialize_template,
52 self.sources_substitution,
53 self.objects_substitution,
54 self.deps_substitution,
55 self.include_substitution,
56 self.libraries_substitution,
57 self.fortran_args_substitution,
58 ]
59 self.build_type = build_type
60 self.python_exe = python_exe
61 self.indent = " " * 21
62
63 def meson_build_template(self) -> str:
64 if not self.build_template_path.is_file():
65 raise FileNotFoundError(
66 errno.ENOENT,
67 "Meson build template"
68 f" {self.build_template_path.absolute()}"
69 " does not exist.",
70 )
71 return self.build_template_path.read_text()

Callers 1

write_meson_buildMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…