【发布时间】:2018-12-03 18:25:27
【问题描述】:
我目前使用“setuptools”在 Linux 上使用 gcc 自动 cythonize 和编译我的 Cython 模块。从现在开始,我需要更多地控制提供给 gcc 的构建标志。如果我在setup.py 中使用以下内容:
cythonize(
[Extension("*", ["project/*.pyx"])
nthreads=4
)
我得到了构建标志,看起来像:
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fPIC -I./fastmat/core -I/home/seb/.local/lib/python3.6/site-packages/numpy/core/include -Iproject/core -Ifastmat/inspect -Iutil -I/usr/include/python3.6m -c project/BlockDiag.c -o build/temp.linux-x86_64-3.6/project/BlockDiag.o
在这里,我完全惊讶于几个构建标志多次出现并且没有以任何(对我来说显而易见的)方式发出的事实。
如何清理这些构建标志,使它们看起来像建议的here?我希望在此过程中学习一些关于 setuptools 的知识,以便最终完全控制构建过程,而无需使用自维护的 makefile。
【问题讨论】:
标签: python cython setuptools compiler-flags cythonize