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

Function compile_extension_module

numpy/testing/_private/extbuild.py:80–110  ·  view source on GitHub ↗

Build an extension module and return the filename of the resulting native code file. Parameters ---------- name : string name of the module, possibly including dots if it is a module inside a package. builddir : pathlib.Path Where to build the module

(
        name, builddir, include_dirs,
        source_string, libraries=[], library_dirs=[])

Source from the content-addressed store, hash-verified

78
79
80def compile_extension_module(
81 name, builddir, include_dirs,
82 source_string, libraries=[], library_dirs=[]):
83 """
84 Build an extension module and return the filename of the resulting
85 native code file.
86
87 Parameters
88 ----------
89 name : string
90 name of the module, possibly including dots if it is a module inside a
91 package.
92 builddir : pathlib.Path
93 Where to build the module, usually a temporary directory
94 include_dirs : list
95 Extra directories to find include files when compiling
96 libraries : list
97 Libraries to link into the extension module
98 library_dirs: list
99 Where to find the libraries, ``-L`` passed to the linker
100 """
101 modname = name.split('.')[-1]
102 dirname = builddir / name
103 dirname.mkdir(exist_ok=True)
104 cfile = _convert_str_to_file(source_string, dirname)
105 include_dirs = include_dirs + [sysconfig.get_config_var('INCLUDEPY')]
106
107 return _c_compile(
108 cfile, outputfilename=dirname / modname,
109 include_dirs=include_dirs, libraries=[], library_dirs=[],
110 )
111
112
113def _convert_str_to_file(source, dirname):

Callers 1

Calls 3

_convert_str_to_fileFunction · 0.85
_c_compileFunction · 0.85
splitMethod · 0.45

Tested by

no test coverage detected