几个 .pyx 的 Cython setup.py [英] Cython setup.py for several .pyx

查看:31
本文介绍了几个 .pyx 的 Cython setup.py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更快地进行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")
)

如果我想cythonize怎么办

What if i want to cythonize

  • 几个扩展名为 .pyx 的文件,我会用它们的名字来称呼它们

  • several files with ext .pyx, that i will call by their name

文件夹中的所有 .pyx 文件

all .pyx files in a folder

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

What would be python code for the setup.py in both cases ?

推荐答案

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

这篇关于几个 .pyx 的 Cython setup.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆