英文:
How to set the compiler options in setup.py
问题
以下是翻译好的内容:
我正在尝试编译一个简单的 test.pyx 文件。为此,我创建了以下 setup.py 文件:
from setuptools import setup
from Cython.Build import cythonize
setup(
compiler_directives={'language_level': '3'},
extra_compile_args=['-Ofast', '-march=native'],
ext_modules=cythonize("test.pyx")
)
我收到了以下警告:
UserWarning: Unknown distribution option: 'compiler_directives'
warnings.warn(msg)
Unknown distribution option: 'extra_compile_args'
warnings.warn(msg)
我应该如何正确操作?
我正在使用 Cython 版本 0.29.35。
英文:
I am trying to compile a simple test.pyx file. To do this I made setup.py as follows:
from setuptools import setup
from Cython.Build import cythonize
setup(
compiler_directives={'language_level' : "3"},
extra_compile_args=['-Ofast', '-march=native'],
ext_modules = cythonize("test.pyx")
)
I get the warnings:
UserWarning: Unknown distribution option: 'compiler_directives'
warnings.warn(msg)
Unknown distribution option: 'extra_compile_args'
warnings.warn(msg)
How should I have done this?
I am using Cython version 0.29.35 .
答案1
得分: 1
Thanks to Marijn this compiles without warnings:
from setuptools import setup
from Cython.Build import cythonize
from setuptools.extension import Extension
ext_modules = [
Extension(
'test_sum',
language='c',
sources=['test.pyx'], # list of source files
extra_compile_args=['-Ofast', '-march=native'], # example extra compiler arguments
)
]
setup(
name="test module",
ext_modules=cythonize(ext_modules, compiler_directives={'language_level': "3"})
)
如果您需要进一步的帮助,请随时提问。
英文:
Thanks to Marijn this compiles without warnings:
from setuptools import setup
from Cython.Build import cythonize
from setuptools.extension import Extension
ext_modules = [
Extension(
'test_sum',
language='c',
sources=['test.pyx'], # list of source files
extra_compile_args=['-Ofast', '-march=native'], # example extra compiler arguments
)
]
setup(
name = "test module",
ext_modules = cythonize(ext_modules, compiler_directives={'language_level' : "3"})
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论