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=[])
| 78 | |
| 79 | |
| 80 | def 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 | |
| 113 | def _convert_str_to_file(source, dirname): |
no test coverage detected