小编典典

Cython setup.py用于几个.pyx

python

我想更快地进行cythonize。一个.pyx的代码是

from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("MyFile.pyx")
)

如果我想进行囊肿化怎么办

  • ext .pyx的几个文件,我将通过它们的名称来调用

  • 文件夹中的所有.pyx文件

在这两种情况下,setup.py的python代码是什么?


阅读 213

收藏
2020-12-20

共1个答案

小编典典

来自: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"]),
)
2020-12-20