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

Class MesonTemplate

numpy/f2py/_backends/_meson.py:17–118  ·  view source on GitHub ↗

Template meson build file generation class.

Source from the content-addressed store, hash-verified

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

Callers 1

write_meson_buildMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected