Cythonize,但不使用setup.py编译.pyx文件 [英] Cythonize but not compile .pyx files using setup.py

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

问题描述

我有一个Cython项目,其中包含几个 .pyx 文件。为了分发我的项目,我想提供我推荐的在Cython文档中,以最大程度地减少不同Cython版本的问题。

I have a Cython project containing several .pyx files. To distribute my project I would like to provide my generated .c files as recommended in the Cython documentation, to minimize problems with different Cython versions.

我目前的工作流程是使用以下项目来构建项目:

My current work flow is to build the project using:

me@machine$ python setup.py build_ext --inplace

此Cythonize(即使用Cython将 .pyx 文件转换为 .c / .cpp 文件) .pyx 文件,然后进行编译。
对于发行版,我不需要编译的( .so )文件,因此我基本上忽略了它们。问题是,我浪费了很多时间进行无用的编译。

This cythonizes (i.e. translate .pyx files to .c / .cpp files using Cython) all .pyx files and then compiles them. For a release I do not need the compiled (.so) files, so I basically ignore them. The problem is, I waste a lot of time with the useless compilation.

有没有办法对文件夹中的所有 .pyx 文件进行cythonize处理使用 setup.py 而不进行编译?

Is there a way to cythonize all .pyx files in the folder using the setup.py, without compiling them?

我大约有20个 .pyx 文件,这些文件具有不同的编译器指令。在命令行上为每个文件调用 cython 会比仅等待其编译慢。

I have about 20 .pyx files which have different compiler directives. Calling cython on the command line for each file would be slower than just waiting for it to compile.

另一方面,创建一个shell脚本来对它们进行cythonize处理将使我留下第二个需要保持最新状态的编译器指令列表。我宁愿不这样做,以尽量减少可能的故障点。

On the other hand creating a shell script to cythonize them would leave me with a second list of compiler directives that needs to be kept up to date. I would rather not do this, in order to keep my possible points of failure minimal.

推荐答案

创建C文件的一种方法不进行编译的方法是先在setup.py setup(...)行中删除,然后仅将其替换为 cythonize( *。pyx)部分。然后运行:

One way to create the C files without compiling them is first remove in setup.py "setup(...)" line and replace it with only the "cythonize("*.pyx")" part. Then run:

me@machine$ python setup.py

这篇关于Cythonize,但不使用setup.py编译.pyx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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