MCPcopy Index your code
hub / github.com/numpy/numpy / build

Function build

numpy/testing/_private/extbuild.py:203–241  ·  view source on GitHub ↗

use meson to build

(cfile, outputfilename, compile_extra, link_extra,
          include_dirs, libraries, library_dirs)

Source from the content-addressed store, hash-verified

201
202
203def build(cfile, outputfilename, compile_extra, link_extra,
204 include_dirs, libraries, library_dirs):
205 "use meson to build"
206
207 build_dir = cfile.parent / "build"
208 os.makedirs(build_dir, exist_ok=True)
209 with open(cfile.parent / "meson.build", "wt") as fid:
210 link_dirs = ['-L' + d for d in library_dirs]
211 fid.write(textwrap.dedent(f"""\
212 project('foo', 'c')
213 py = import('python').find_installation(pure: false)
214 py.extension_module(
215 '{outputfilename.parts[-1]}',
216 '{cfile.parts[-1]}',
217 c_args: {compile_extra},
218 link_args: {link_dirs},
219 include_directories: {include_dirs},
220 )
221 """))
222 native_file_name = cfile.parent / ".mesonpy-native-file.ini"
223 with open(native_file_name, "wt") as fid:
224 fid.write(textwrap.dedent(f"""\
225 [binaries]
226 python = '{sys.executable}'
227 """))
228 if sys.platform == "win32":
229 run_subprocess(["meson", "setup",
230 "--buildtype=release",
231 "--vsenv", ".."],
232 build_dir)
233 else:
234 run_subprocess(["meson", "setup", "--vsenv",
235 "..", f'--native-file={os.fspath(native_file_name)}'],
236 build_dir)
237
238 so_name = outputfilename.parts[-1] + get_so_suffix()
239 run_subprocess(["meson", "compile"], build_dir)
240 os.rename(str(build_dir / so_name), cfile.parent / so_name)
241 return cfile.parent / so_name
242
243
244def get_so_suffix():

Callers 1

_c_compileFunction · 0.85

Calls 4

openFunction · 0.85
run_subprocessFunction · 0.85
get_so_suffixFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…