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=None, library_dirs=None)
| 81 | |
| 82 | |
| 83 | def compile_extension_module( |
| 84 | name, builddir, include_dirs, |
| 85 | source_string, libraries=None, library_dirs=None): |
| 86 | """ |
| 87 | Build an extension module and return the filename of the resulting |
| 88 | native code file. |
| 89 | |
| 90 | Parameters |
| 91 | ---------- |
| 92 | name : string |
| 93 | name of the module, possibly including dots if it is a module inside a |
| 94 | package. |
| 95 | builddir : pathlib.Path |
| 96 | Where to build the module, usually a temporary directory |
| 97 | include_dirs : list |
| 98 | Extra directories to find include files when compiling |
| 99 | libraries : list |
| 100 | Libraries to link into the extension module |
| 101 | library_dirs: list |
| 102 | Where to find the libraries, ``-L`` passed to the linker |
| 103 | """ |
| 104 | modname = name.split('.')[-1] |
| 105 | dirname = builddir / name |
| 106 | dirname.mkdir(exist_ok=True) |
| 107 | cfile = _convert_str_to_file(source_string, dirname) |
| 108 | include_dirs = include_dirs or [] |
| 109 | libraries = libraries or [] |
| 110 | library_dirs = library_dirs or [] |
| 111 | |
| 112 | return _c_compile( |
| 113 | cfile, outputfilename=dirname / modname, |
| 114 | include_dirs=include_dirs, libraries=libraries, |
| 115 | library_dirs=library_dirs, |
| 116 | ) |
| 117 | |
| 118 | |
| 119 | def _convert_str_to_file(source, dirname): |
no test coverage detected
searching dependent graphs…