Remove compile args in Cython

穿精又带淫゛_ 提交于 2019-12-24 01:18:37

问题


I want to compile my python project with cython. I created this setup.py file :

from setuptools import setup, find_packages
from Cython.Build import cythonize

recursive_tree = [file for file in glob.iglob("sample/**/*.py",  recursive=True)]

setup(
    name                                     = 'sample',
    version                                  = sample.__version__,
    packages                                 = find_packages(),
    author                                   = "42",
    description                              = "Cython Sample",
    include_package_data                     = True,
    ext_modules                              = cythonize(
        recursive_tree,
        nthreads=2,
        exclude="setup.py",
        build_dir = "out",
    ),
)

In this thread, we can see it's possible to add some extra compile args, but can we do the opposite and remove one?

When I use this command : python setup.py build_ext --inplace I got this gcc configuration :

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python3.6m -c out/sample/hello.c -o build/temp.linux-x86_64-3.6/out/sample/hello.o

gcc -pthread -shared build/temp.linux-x86_64-3.6/out/sample/hello.o -o build/lib.linux-x86_64-3.6/hello.cpython-36m-x86_64-linux-gnu.so

How can i remove the -g option?


回答1:


With reference to similar this question: How may I override the compiler (gcc) flags that setup.py uses by default? (which I don't think it quite a duplicate). They solve a similar problem by adding extra command line arguments to undo the ones that setup.py adds by default.

In this case -g0 "negates -g". Therefore add -g0 to extra_compile_args

setup(... # everything as before
      extra_compile_args = ['-g0'])


来源:https://stackoverflow.com/questions/41984016/remove-compile-args-in-cython

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!