问题描述
我想用cython编译我的python项目.我创建了这个setup.py文件:
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",
),
)
在此线程中,我们可以看到可以添加一些额外的编译args,但是我们可以做相反的事情并删除其中一个吗?
In this thread, we can see it's possible to add some extra compile args, but can we do the opposite and remove one?
当我使用此命令时: python setup.py build_ext --inplace
我得到了这个gcc配置:
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
如何删除 -g
选项?
推荐答案
参考与此类似的问题:(我不认为相当重复).他们通过添加额外的命令行参数来撤消 setup.py
默认情况下添加的参数,来解决类似的问题.
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.
在这种情况下, -g0
否定 -g
".因此,将 -g0
添加到 extra_compile_args
In this case -g0
"negates -g
". Therefore add -g0
to extra_compile_args
setup(... # everything as before
extra_compile_args = ['-g0'])
这篇关于删除Cython中的编译args的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!