为 python 编写一个可以使用 setup.py 方法安装的 api
我是用 python 编写 API 的新手,无论是用任何语言编写 API。我希望得到关于如何创建一个可以使用 setup.py 方法安装并在其他 python 项目中使用的 API 的指示。类似于 twitterapi 的东西。
我已经创建并编码了想要包含在 API 中的所有方法。我只需要知道如何实现安装,以便其他人可以使用我的代码来利用他们可能有的想法。或者如果我需要以某种方式格式化代码以方便安装。
我通过示例或教程学得最好。
非常感谢。
I am new at writing APIs in python, in any language for that matter. I was hoping to get pointers on how i can create an API that can be installed using setup.py method and used in other python projects. Something similar to the twitterapi.
I have already created and coded all the methods i want to include in the API. I just need to know how to implement the installation so other can use my code to leverage ideas they may have. Or if i need to format the code a certain way to facilitate installation.
I learn best with examples or tutorials.
Thanks so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
值得注意的是,Python 的这一部分现在正在发生一些变化。一切都有点乱。我所知道的最新概述是 Hitchhiker's Guide to Packaging: http://guide.python-distribute.org /
打包部分的当前状态很重要: http://guide.python-distribute.org/introduction.html#current-state-of-packaging
It's worth noting that this part of python is undergoing some changes right now. It's all a bit messy. The most current overview I know of is the Hitchhiker's Guide to Packaging: http://guide.python-distribute.org/
The current state of packaging section is important: http://guide.python-distribute.org/introduction.html#current-state-of-packaging
python 包装世界一团糟(就像 poswald 说的)。这是一个简短的概述以及一些提示。您的基本问题(使用 setup.py 等)可以通过阅读 msw 提到的 distutils 指南 来解决在他的评论中。
现在来说说污垢。 Python 标准库中的分发模块的基本基础设施是上面提到的 distutils。它在某些方面受到限制,因此在其之上编写了一系列扩展,称为 setuptools。安装工具除了实际增加的功能之外,还提供了一个名为“easy_install”的命令行“安装程序”。
setuptools 的维护不太好,因此它被分叉了,并设置了一个更活跃的分支,称为“distribute”,它是目前的首选替代方案。除此之外,还创建了名为 pip 的 easy_install 替代品,它更加模块化和有用。
现在有一个巨大的项目正在进行,它试图将所有来自分发和填充的更改折叠到一个统一的库中,该库将进入 stdlib。它暂定名为“distutils2”。
The python packaging world is a mess (like poswald said). Here's a brief overview along with a bunch of pointers. Your basic problem (using setup.py etc.) is solved by reading the distutils guide which msw has mentioned in his comment.
Now for the dirt. The basic infrastructure of the distribution modules which is in the Python standard library is distutils referred to above. It's limited in some ways and so a series of extensions was written on top of it called setuptools. Setuptools along with actually increasing the functionality provided a command line "installer" called "easy_install".
Setuptools maintenance was not too great and so it was forked and a more active branch called "distribute" was setup and it is the preferred alternative right now. In addition to this, a replacement for easy_install named pip was created which was more modular and useful.
Now there's a huge project going which attempts to fold in all changes from distribute and stuff into a unified library that will go into the stdlib. It's tentatively called "distutils2".