我可以配置 pydev 自动编译 cython 文件吗?
我刚刚拿起 Cython。我正在使用它在我的 Python 项目中构建核心库。目前,我已经使用 distutils
配置了一个 setup.py
文件,并且每当我想重新编译 Cython 文件时都会运行以下命令:
python ./setup.py build_ext --inplace
但是,我经常忘记。我喜欢 Eclipse 在每次编辑/保存时自动为 Java 构建类文件。是否可以为 PyDev、Eclipse 或其他一些巧妙的方式配置类似的行为?
I'm just picking up Cython. I'm using it to build a core library in my Python project. Currently I've configured a setup.py
file with distutils
and am running the following command whenever I want to recompile the Cython file:
python ./setup.py build_ext --inplace
However, I often forget. I like how Eclipse automatically builds class files for Java every time I edit/save. Is it possible to configure similar behavior for PyDev, Eclipse, or some other clever way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
目前,PyDev 中没有特殊支持在 cython 文件发生更改时自动编译它们...如果您愿意,可以创建一个外部构建器:
右键单击项目 >属性>建设者>新的>程序,然后将程序配置为 python,将要运行的模块作为参数,并接收 ${build_files} 变量作为参数。
您可能应该检查某些更改的文件是否是 .pyx 文件,如果是,则调用该文件的实际构建命令 - 也许还有依赖项。
For now there's no special support in PyDev to automatically compile cython files when they change... if you want you can create an external builder:
Right click project > properties > builders > new > program, then configure the program as python having as a parameter the module to run and receiving as arguments also the ${build_files} variable.
You should probably check if some changed file is a .pyx file and if it is, call the actual build command for that file -- and maybe dependencies.
您可以使用“魔法”sitecustomize.py 自动获得 cython 编译在你的基础 PYTHONPATH 中调用 pyximport,即使需要一些安装详细信息(例如,在 Windows 下,您的 mingw 位置),这里是一个示例:
作为旁注,如果您在 Windows 下,请记住您的 cython 必须是 稍微修改以使用 mingw。
您还应该将您的文件命名为 *.pyx 才能使其正常工作。另一个建议:您应该使用 cython "pure python" syntax 以便Pydev 编辑器不会抱怨。
You can obtain automatically cython compiling using a "magic" sitecustomize.py in your base PYTHONPATH that calls pyximport, even if it requires some installation details (such as, under windows, your mingw location), here is an example :
As a side note, if you are under windows, please keep in mind that your cython must be slightly modified to use mingw.
You should also call your files *.pyx for this to work. Another advice : you should use the cython "pure python" syntax so that the Pydev editor will not complain.