Customize compiler using distutils command. Parameters ---------- cmd : class instance An instance inheriting from `distutils.cmd.Command`. ignore : sequence of str, optional List of `CCompiler` commands (without ``'set_'``) that should not be altered. S
(self, cmd, ignore=())
| 374 | replace_method(CCompiler, 'compile', CCompiler_compile) |
| 375 | |
| 376 | def CCompiler_customize_cmd(self, cmd, ignore=()): |
| 377 | """ |
| 378 | Customize compiler using distutils command. |
| 379 | |
| 380 | Parameters |
| 381 | ---------- |
| 382 | cmd : class instance |
| 383 | An instance inheriting from `distutils.cmd.Command`. |
| 384 | ignore : sequence of str, optional |
| 385 | List of `CCompiler` commands (without ``'set_'``) that should not be |
| 386 | altered. Strings that are checked for are: |
| 387 | ``('include_dirs', 'define', 'undef', 'libraries', 'library_dirs', |
| 388 | 'rpath', 'link_objects')``. |
| 389 | |
| 390 | Returns |
| 391 | ------- |
| 392 | None |
| 393 | |
| 394 | """ |
| 395 | log.info('customize %s using %s' % (self.__class__.__name__, |
| 396 | cmd.__class__.__name__)) |
| 397 | |
| 398 | if ( |
| 399 | hasattr(self, 'compiler') and |
| 400 | 'clang' in self.compiler[0] and |
| 401 | not (platform.machine() == 'arm64' and sys.platform == 'darwin') |
| 402 | ): |
| 403 | # clang defaults to a non-strict floating error point model. |
| 404 | # However, '-ftrapping-math' is not currently supported (2023-04-08) |
| 405 | # for macosx_arm64. |
| 406 | # Since NumPy and most Python libs give warnings for these, override: |
| 407 | self.compiler.append('-ftrapping-math') |
| 408 | self.compiler_so.append('-ftrapping-math') |
| 409 | |
| 410 | def allow(attr): |
| 411 | return getattr(cmd, attr, None) is not None and attr not in ignore |
| 412 | |
| 413 | if allow('include_dirs'): |
| 414 | self.set_include_dirs(cmd.include_dirs) |
| 415 | if allow('define'): |
| 416 | for (name, value) in cmd.define: |
| 417 | self.define_macro(name, value) |
| 418 | if allow('undef'): |
| 419 | for macro in cmd.undef: |
| 420 | self.undefine_macro(macro) |
| 421 | if allow('libraries'): |
| 422 | self.set_libraries(self.libraries + cmd.libraries) |
| 423 | if allow('library_dirs'): |
| 424 | self.set_library_dirs(self.library_dirs + cmd.library_dirs) |
| 425 | if allow('rpath'): |
| 426 | self.set_runtime_library_dirs(cmd.rpath) |
| 427 | if allow('link_objects'): |
| 428 | self.set_link_objects(cmd.link_objects) |
| 429 | |
| 430 | replace_method(CCompiler, 'customize_cmd', CCompiler_customize_cmd) |
| 431 |