Depends on config.h: generate_config_h has to be called before !
(ext, build_dir)
| 547 | return target |
| 548 | |
| 549 | def generate_numpyconfig_h(ext, build_dir): |
| 550 | """Depends on config.h: generate_config_h has to be called before !""" |
| 551 | # put common include directory in build_dir on search path |
| 552 | # allows using code generation in headers |
| 553 | config.add_include_dirs(join(build_dir, "src", "common")) |
| 554 | config.add_include_dirs(join(build_dir, "src", "npymath")) |
| 555 | |
| 556 | target = join(build_dir, header_dir, '_numpyconfig.h') |
| 557 | d = os.path.dirname(target) |
| 558 | if not os.path.exists(d): |
| 559 | os.makedirs(d) |
| 560 | if newer(__file__, target): |
| 561 | config_cmd = config.get_config_cmd() |
| 562 | log.info('Generating %s', target) |
| 563 | |
| 564 | # Check sizeof |
| 565 | ignored, moredefs = cocache.check_types(config_cmd, ext, build_dir) |
| 566 | |
| 567 | if is_npy_no_signal(): |
| 568 | moredefs.append(('NPY_NO_SIGNAL', 1)) |
| 569 | |
| 570 | if is_npy_no_smp(): |
| 571 | moredefs.append(('NPY_NO_SMP', 1)) |
| 572 | else: |
| 573 | moredefs.append(('NPY_NO_SMP', 0)) |
| 574 | |
| 575 | mathlibs = check_mathlib(config_cmd) |
| 576 | moredefs.extend(cocache.check_complex(config_cmd, mathlibs)[1]) |
| 577 | |
| 578 | if NPY_RELAXED_STRIDES_DEBUG: |
| 579 | moredefs.append(('NPY_RELAXED_STRIDES_DEBUG', 1)) |
| 580 | |
| 581 | # Check whether we can use inttypes (C99) formats |
| 582 | if config_cmd.check_decl('PRIdPTR', headers=['inttypes.h']): |
| 583 | moredefs.append(('NPY_USE_C99_FORMATS', 1)) |
| 584 | |
| 585 | # visibility check |
| 586 | hidden_visibility = visibility_define(config_cmd) |
| 587 | moredefs.append(('NPY_VISIBILITY_HIDDEN', hidden_visibility)) |
| 588 | |
| 589 | # Add the C API/ABI versions |
| 590 | moredefs.append(('NPY_ABI_VERSION', '0x%.8X' % C_ABI_VERSION)) |
| 591 | moredefs.append(('NPY_API_VERSION', '0x%.8X' % C_API_VERSION)) |
| 592 | |
| 593 | # Add moredefs to header |
| 594 | with open(target, 'w') as target_f: |
| 595 | for d in moredefs: |
| 596 | if isinstance(d, str): |
| 597 | target_f.write('#define %s\n' % (d)) |
| 598 | else: |
| 599 | target_f.write('#define %s %s\n' % (d[0], d[1])) |
| 600 | |
| 601 | # Define __STDC_FORMAT_MACROS |
| 602 | target_f.write(textwrap.dedent(""" |
| 603 | #ifndef __STDC_FORMAT_MACROS |
| 604 | #define __STDC_FORMAT_MACROS 1 |
| 605 | #endif |
| 606 | """)) |
nothing calls this directly
no test coverage detected