分发使用自定义c模块扩展的python程序的最佳方法是什么?

时间:2021-10-14 20:15:35

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.

我已经探索了几年的python,但现在我正在慢慢学习如何使用c。使用python文档,我学习了如何用一些c扩展我的python程序,因为这似乎是开始使用它的逻辑方式。我现在的问题是如何分发这样的程序。

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?

我想我的问题的核心是如何编译东西。我可以在我自己的机器(gentoo)上轻松完成这项工作,但是像Ubuntu这样的二​​进制发行版可能没有默认的编译器。另外,我有几个朋友是mac用户。我的直觉说我不能用我自己的机器编译然后在另一台机器上运行它。任何人都知道我能做什么,或者一些在线资源来学习这样的东西?

2 个解决方案

#1


6  

Please read up on distutils. Specifically, the section on Extension Modules.

请阅读distutils。具体来说,有关扩展模块的部分。

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.

创建正确的distutils setup.py并查看谁可以运行它以及谁不可以运行它相对容易。

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.

构建的二进制分发很常见。也许你可以注册一些用户将帮助创建二进制发行版 - 使用OS本机安装程序 - 出于某些考虑。

#2


1  

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.

S. Lott是对的。你应该先看看distutils。在您从distutils中了解了所需内容后,请查看setuptools。 Setuptools构建于distutils之上,使您的用户可以轻松安装。你曾经使用过easy_install或Python Eggs吗?这就是接下来的事情。

#1


6  

Please read up on distutils. Specifically, the section on Extension Modules.

请阅读distutils。具体来说,有关扩展模块的部分。

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.

创建正确的distutils setup.py并查看谁可以运行它以及谁不可以运行它相对容易。

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.

构建的二进制分发很常见。也许你可以注册一些用户将帮助创建二进制发行版 - 使用OS本机安装程序 - 出于某些考虑。

#2


1  

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.

S. Lott是对的。你应该先看看distutils。在您从distutils中了解了所需内容后,请查看setuptools。 Setuptools构建于distutils之上,使您的用户可以轻松安装。你曾经使用过easy_install或Python Eggs吗?这就是接下来的事情。