简体   繁体   English

使用 setup.py 构建时删除默认编译器选项

[英]Remove a default compiler option when building with setup.py

I am exposing my C++ code to Python using pybind11.我正在使用 pybind11 将我的 C++ 代码暴露给 Python。 Let's say I'm doing exactly the example provided by the pybind developers.假设我正在做 pybind 开发人员提供的示例 In the end, I'm building using最后,我正在使用

python setup.py build

The compiler is invoked with编译器被调用

clang ... -DNDEBUG ... -O3 ... -I... -std=c++14

My question is simple:我的问题很简单:

How can I, at least temporarily, switch on the assertions in my code?我怎样才能至少暂时打开代码中的断言? Ie how can I tell the setuptools to omit the -DNDEBUG compiler option?即如何告诉 setuptools 省略-DNDEBUG编译器选项?

Try尝试

setup(…
    ext_modules=[Extension(…
        undef_macros=['DEBUG']
    …)]
…)

See https://docs.python.org/3/distutils/apiref.html#distutils.core.Extension请参阅https://docs.python.org/3/distutils/apiref.html#distutils.core.Extension

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM