问题
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