Produce the list of extension modules when a shared library is needed. This creates one shared library extension module that all the others import, and one shim extension module for each module in the build. Each shim simply calls an initialization function in the shared library.
(
sources: list[BuildSource],
group_name: str,
cfiles: list[str],
deps: list[str],
build_dir: str,
extra_compile_args: list[str],
extra_include_dirs: list[str],
)
| 354 | |
| 355 | |
| 356 | def build_using_shared_lib( |
| 357 | sources: list[BuildSource], |
| 358 | group_name: str, |
| 359 | cfiles: list[str], |
| 360 | deps: list[str], |
| 361 | build_dir: str, |
| 362 | extra_compile_args: list[str], |
| 363 | extra_include_dirs: list[str], |
| 364 | ) -> list[Extension]: |
| 365 | """Produce the list of extension modules when a shared library is needed. |
| 366 | |
| 367 | This creates one shared library extension module that all the |
| 368 | others import, and one shim extension module for each |
| 369 | module in the build. Each shim simply calls an initialization function |
| 370 | in the shared library. |
| 371 | |
| 372 | The shared library (which lib_name is the name of) is a Python |
| 373 | extension module that exports the real initialization functions in |
| 374 | Capsules stored in module attributes. |
| 375 | """ |
| 376 | extensions = [ |
| 377 | get_extension()( |
| 378 | shared_lib_name(group_name), |
| 379 | sources=cfiles, |
| 380 | include_dirs=[include_dir(), build_dir] + extra_include_dirs, |
| 381 | depends=deps, |
| 382 | extra_compile_args=extra_compile_args, |
| 383 | ) |
| 384 | ] |
| 385 | |
| 386 | for source in sources: |
| 387 | module_name = source.module.split(".")[-1] |
| 388 | shim_file = generate_c_extension_shim(source.module, module_name, build_dir, group_name) |
| 389 | |
| 390 | # We include the __init__ in the "module name" we stick in the Extension, |
| 391 | # since this seems to be needed for it to end up in the right place. |
| 392 | full_module_name = source.module |
| 393 | assert source.path |
| 394 | if is_package_source(source): |
| 395 | full_module_name += ".__init__" |
| 396 | extensions.append( |
| 397 | get_extension()( |
| 398 | full_module_name, sources=[shim_file], extra_compile_args=extra_compile_args |
| 399 | ) |
| 400 | ) |
| 401 | |
| 402 | return extensions |
| 403 | |
| 404 | |
| 405 | def build_single_module( |
no test coverage detected
searching dependent graphs…