Cython中的extra_compile_args [英] extra_compile_args in Cython
本文介绍了Cython中的extra_compile_args的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过使用 extra_compile_args
将一些额外的选项传递给 Cython
编译器。
I want to pass some extra options to the Cython
compiler by using extra_compile_args
.
我的 setup.py
:
from distutils.core import setup
from Cython.Build import cythonize
setup(
name = 'Test app',
ext_modules = cythonize("test.pyx", language="c++", extra_compile_args=["-O3"]),
)
但是,当我运行 python setup.py build_ext --inplace
时,出现以下警告:
However, when I run python setup.py build_ext --inplace
, I get the following warning:
UserWarning: got unknown compilation option, please remove: extra_compile_args
问题:一个人如何正确使用 extra_compile_args
?
Question: How does one use extra_compile_args
correctly?
我使用 Cython 0.23.4
在 Ubuntu 14.04.3
下。
推荐答案
使用不带 cythonize
的更传统的方式来提供额外的编译器选项:
Use the more traditional way without cythonize
to supply extra compiler options:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
name = 'Test app',
ext_modules=[
Extension('test',
sources=['test.pyx'],
extra_compile_args=['-O3'],
language='c++')
],
cmdclass = {'build_ext': build_ext}
)
这篇关于Cython中的extra_compile_args的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文