本文介绍了Cython setup.py用于几个.pyx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更快地cythonize。一个.pyx的代码是
来自distutils.core import setup
来自Cython.Build import cythonize
setup(
ext_modules = cythonize(MyFile.pyx)
)
$ b b
如果我想cythonize
-
几个文件与ext .pyx,我会调用他们的名字
>
解决方案
发件人:
#几个文件与ext .pyx,我将调用他们的名字
从distutils.core import setup
从distutils.extension import扩展
来自Cython.Distutils import build_ext
ext_modules = [
Extension(primes,[primes.pyx]),
Extension(spam,[spam。 pyx]),
...
]
setup(
name ='MyProject',
cmdclass = {'build_ext':build_ext} ,
ext_modules = ext_modules,
)
#所有文件夹中的.pyx文件
从distutils.core导入安装
来自Cython.Build import cythonize
setup(
name ='MyProject',
ext_modules = cythonize([*。pyx]),
)
I would like to cythonize faster. Code for one .pyx is
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("MyFile.pyx")
)
What if i want to cythonize
several files with ext .pyx, that i will call by their name
all .pyx files in a folder
What would be python code for the setup.py in both cases ?
解决方案
From: https://github.com/cython/cython/wiki/enhancements-distutils_preprocessing
# several files with ext .pyx, that i will call by their name
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules=[
Extension("primes", ["primes.pyx"]),
Extension("spam", ["spam.pyx"]),
...
]
setup(
name = 'MyProject',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules,
)
# all .pyx files in a folder
from distutils.core import setup
from Cython.Build import cythonize
setup(
name = 'MyProject',
ext_modules = cythonize(["*.pyx"]),
)
这篇关于Cython setup.py用于几个.pyx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!