简体   繁体   English

如何组织和分发带有C扩展的Python应用程序?

[英]How to organize and distribute a Python Application with C extensions?

I'm working on a Python application that is distributed as source (zipped) and via py2exe (majority). 我正在开发一个Python应用程序,它以源代码(zipped)和py2exe(大多数)分发。

Now I want to speed up some modules by replacing them with C extensions. 现在我想通过用C扩展替换它们来加速一些模块。 Which works quite well for the development part. 这对开发部分非常有效。 But the distribution and organization gives me a headache... 但是分配和组织给我带来了麻烦......

My current structure looks like this: 我目前的结构如下:

.
|-- py_submodule_a/
|-- py_submodule_b/
|   |-- c_extension_ba/
|-- c_extension_x/
|-- setup.py
|-- main.py

My question is, where should I place the setup calls/files for my C extensions? 我的问题是,我应该在哪里放置我的C扩展的设置调用/文件? I want to make sure that I can always run my application via main.py (so I'd rather not wait until distribution to compile the C extensions) but I also want to make sure that the distribution always has the latest C extensions. 我想确保我总是可以通过main.py运行我的应用程序(所以我宁愿等到分发编译C扩展)但我也想确保分发总是有最新的C扩展。

Thanks in advance for any help! 在此先感谢您的帮助!

If you're just trying to optimize out hot-loops with C-code snippets you could always try something like scipy.weave . 如果您只是尝试使用C代码片段优化热循环,您可以尝试像scipy.weave这样的东西 It is extremely convenient to have the C-code nicely wrapped up in the python package that calls it, and to be able to perform efficient C operations on memory in place. 将C代码很好地包装在调用它的python包中,并且能够在内存上执行有效的C操作是非常方便的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM