python - 几个 .pyx 的 Cython setup.py

标签 python compilation installation cython setup.py

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

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

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

如果我想cythonize怎么办

  • 几个扩展名为 .pyx 的文件,我将用它们的名字来调用

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

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

最佳答案

发件人: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"]),
)

关于python - 几个 .pyx 的 Cython setup.py,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21826137/

相关文章:

windows-installer - 替换 MSI 中的小文件的最简单解决方案?

python - 如何根据字符串中的两个字符 "["和 "]"进行拆分

python - 字典中的递归

python - 如何使用 python - selenium 截屏?

c++ - 使用 gcc 链接库在 Ubuntu 中编译 C++ 代码

linux - 安装一个包的多个版本

javascript - 无法让 Node 时间正常运行

python - NLTK:过滤具有特定结构的句子

VBA:.copy 后编译错误

c++ - CMAKE:在函数内创建和构建列表——具有目录或全局范围