Python发行版有哪些用例? [英] What are the use cases for a Python distribution?

查看:88
本文介绍了Python发行版有哪些用例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我编写的Python包开发发行版,因此我可以发布 它在PyPI上.这是我第一次使用distutils,setuptools,distribute, pip,setup.py以及所有这些,我在学习曲线上有些挣扎 比我预想的要陡得多:)

I'm developing a distribution for the Python package I'm writing so I can post it on PyPI. It's my first time working with distutils, setuptools, distribute, pip, setup.py and all that and I'm struggling a bit with a learning curve that's quite a bit steeper than I anticipated :)

我在获取一些测试数据文件时遇到了一些麻烦 通过在setup.py的data_files参数中指定它们,将它们包含在压缩包中,直到我遇到另一条指向我的帖子 指向MANIFEST.in文件.就在这时,我突然想到 包含在tarball/zip文件中(使用MANIFEST.in),以及安装在 用户的Python环境(当他们进行easy_install或其他操作时)(基于 您在setup.py中指定)是两件截然不同的事情;总的来说 压缩包中的数量远远超过实际安装的数量.

I was having a little trouble getting some of my test data files to be included in the tarball by specifying them in the data_files parameter in setup.py until I came across a different post here that pointed me toward the MANIFEST.in file. Just then I snapped to the notion that what you include in the tarball/zip (using MANIFEST.in) and what gets installed in a user's Python environment when they do easy_install or whatever (based on what you specify in setup.py) are two very different things; in general there being a lot more in the tarball than actually gets installed.

这立即触发了我的代码气味,并意识到 分发必须有多个用例;我被固定在 我真正参与过的只有一个人,使用easy_install或pip安装了一个 图书馆.然后我意识到我正在开发的工作产品中,我只有一个 对我正在开发的最终用户的部分了解.

This immediately triggered a code-smell for me and the realization that there must be more than one use case for a distribution; I had been fixated on the only one I've really participated in, using easy_install or pip to install a library. And then I realized I was developing work product where I had only a partial understanding of the end-users I was developing for.

所以我的问题是:"Python发行版有哪些用例? 而不是将其安装在自己的Python环境中?我还为谁服务 通过这种分布方式,他们最关心的是什么?"

So my question is this: "What are the use cases for a Python distribution other than installing it in one's Python environment? Who else am I serving with this distribution and what do they care most about?"

以下是我尚未发现的一些工作问题,这些问题影响了 答案:

Here are some of the working issues I haven't figured out yet that bear on the answer:

  • 包括受源代码控制的所有内容是否明智? (git)在源代码中分发?在github时代,有人下载吗 源代码发行版可以访问完整的项目源代码?还是我应该 只是发布一个链接到我的github仓库?不会包括所有膨胀的东西 分发,花了更长的时间供那些只想下载的人下载 安装吗?

  • Is it a sensible thing to include everything that's under source control (git) in the source distribution? In the age of github, does anyone download a source distribution to get access to the full project source? Or should I just post a link to my github repo? Won't including everything bloat the distribution and make it take longer to download for folks who just want to install it?

我将把文档保存在readthedocs.org上.有什么用吗 在源代码中包含文档的HTML版本对我来说很有意义 分布?

I'm going to host the documentation on readthedocs.org. Does it make any sense for me to include HTML versions of the docs in the source distribution?

是否有人使用python setup.py test在源上运行测试 分配?如果是这样,他们将扮演什么角色,他们处于什么情况?一世 不知道我是否应该打扰做那个工作,如果我做,谁去做 它适用于.

Does anyone use python setup.py test to run tests on a source distribution? If so, what role are they in and what situation are they in? I don't know if I should bother with making that work and if I do, who to make it work for.

推荐答案

您可能希望包含在源代码发行版中但可能未安装的某些内容包括:

Some things that you might want to include in the source distribution but maybe not install include:

  • 包裹的许可证
  • 测试套件
  • 文档(除了源文件外,还可能是HTML之类的经过处理的表单)
  • 可能有用于构建源代码发行版的任何其他脚本

通常,这将是您在版本控制中管理的大部分或全部内容,可能还会生成一些生成的文件.

Quite often this will be the majority or all of what you are managing in version control and possibly a few generated files.

当这些文件在线或通过版本控制可用时,您这样做的主要原因是,使人们知道他们的文档或测试版本与正在运行的代码相匹配.

The main reason why you would do this when those files are available online or through version control is so that people know they have the version of the docs or tests that matches the code they're running.

如果您仅在线托管文档的最新版本,那么对于由于某些原因必须使用旧版本的人员而言,它们可能无用.而且版本控制技巧中的测试套件可能与源代码发行版中的代码版本不兼容(例如,如果它测试自那时以来添加的功能).为了获得正确版本的文档或测试,他们需要梳理版本控制,以寻找与源代码发行版相对应的标签(假设开发人员烦扰了对树的标签).在源代码发行版中提供文件可以避免此问题.

If you only host the most recent version of the docs online, then they might not be useful to someone who has to use an older version for some reason. And the test suite on the tip in version control may not be compatible with the version of the code in the source distribution (e.g. if it tests features added since then). To get the right version of the docs or tests, they would need to comb through version control looking for a tag that corresponds to the source distribution (assuming the developers bothered tagging the tree). Having the files available in the source distribution avoids this problem.

对于希望运行测试套件的人来说,我在许多Linux发行版中打包了许多Python模块,偶尔会收到与环境中测试失败相关的错误报告.当我遇到错误并想要检查外部代码是否符合作者在我的环境中的期望时,我还使用了其他人模块的测试套件.

As for people wanting to run the test suite, I have a number of my Python modules packaged in various Linux distributions and occasionally get bug reports related to test failures in their environments. I've also used the test suites of other people's modules when I encounter a bug and want to check whether the external code is behaving as the author expects in my environment.

这篇关于Python发行版有哪些用例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆