分发使用自定义 c 模块扩展的 python 程序的最佳方法是什么?
我已经探索 python 好几年了,但现在我正在慢慢学习如何使用 c。 使用 python 文档,我学会了如何扩展我的 python带有一些 c 的程序,因为这似乎是开始使用它的合乎逻辑的方式。 我现在的问题是如何分发这样的程序。
我想我的问题的核心是如何编译东西。 我可以在自己的机器(gentoo)上轻松完成此操作,但是像 Ubuntu 这样的二进制发行版默认情况下可能没有可用的编译器。 另外,我有几个朋友是 mac 用户。 我的直觉告诉我,我不能只用自己的机器进行编译,然后在另一台机器上运行它。 有人知道我能做什么,或者一些学习此类内容的在线资源吗?
I've explored python for several years, but now I'm slowly learning how to work with c. Using the python documentation, I learned how to extend my python programs with some c, since this seemed like the logical way to start playing with it. My question now is how to distribute a program like this.
I suppose the heart of my question is how to compile things. I can do this easily on my own machine (gentoo), but a binary distribution like Ubuntu probably doesn't have a compiler available by default. Plus, I have a few friends who are mac users. My instinct says that I can't just compile with my own machine and then run it on another. Anyone know what I can do, or some online resources for learning things like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请阅读 distutils。 具体来说,扩展模块部分。
对编译器做出假设是糟糕的策略; 你的直觉可能并不包含所有事实。 您可以做一些市场调查 - 询问他们可以处理有关扩展模块的源分发的问题。
创建适当的 distutils
setup.py
并查看谁可以运行它、谁不能运行它相对容易。构建的二进制发行版非常常见。 出于某些考虑,也许您可以注册一些用户来帮助创建二进制发行版(使用操作系统本机安装程序)。
Please read up on distutils. Specifically, the section on Extension Modules.
Making assumptions about compilers is bad policy; your instinct may not have all the facts. You could do some marketplace survey -- ask what they can handle regarding source distribution of extension modules.
It's relatively easy to create the proper distutils
setup.py
and see who can run it and who can't.Built binary distributions are pretty common. Perhaps you can sign up some users will help create binary distributions -- with OS-native installers -- for some considerations.
S.洛特是对的。 您应该首先查看 distutils。 从 distutils 了解所需内容后,请查看 setuptools。 Setuptools 构建在 distutils 之上,使用户可以轻松安装。 你用过 easy_install 或 Python Eggs 吗? 这就是接下来的事情。
S. Lott is right. You should first look at distutils. After you've learned what you need from distutils, look at setuptools. Setuptools is built on top of distutils and makes installation easy for your users. Have you ever used easy_install or Python Eggs? That's what's next.