为 python 编写一个可以使用 setup.py 方法安装的 api

发布于 2024-08-30 17:46:32 字数 253 浏览 8 评论 0原文

我是用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风疏影 2024-09-06 17:46:32

值得注意的是,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

君勿笑 2024-09-06 17:46:32

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".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文