简体   繁体   中英

Remove a default compiler option when building with setup.py

I am exposing my C++ code to Python using pybind11. Let's say I'm doing exactly the example provided by the pybind developers. 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?

Try

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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