python项目需要MANIFEST.in吗,里面应该有什么? [英] Do python projects need a MANIFEST.in, and what should be in it?

查看:94
本文介绍了python项目需要MANIFEST.in吗,里面应该有什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python 分发"指南(位于 python-distribute.org,但注册已失效)告诉我要包含 doc/txt 文件和 .py 文件被排除在 MANIFEST.in 文件中

The "Python Distribute" guide (was at python-distribute.org, but that registration has lapsed) tells me to include doc/txt files and .py files are excluded in MANIFEST.in file

sourcedist 文档 告诉我只有 sdist 使用 MANIFEST.in 并且仅包含您指定的文件并包含 .py 文件.它还告诉我使用:python setup.py sdist --manifest-only 来生成 MANIFEST,但 python 告诉我这不存在

The sourcedist documentation tells me only sdist uses MANIFEST.in and only includes file you specify and to include .py files. It also tells me to use: python setup.py sdist --manifest-only to generate a MANIFEST, but python tells me this doesn't exist

我很欣赏这些来自不同版本的 python 并且分发系统在一个一团糟,但假设我使用的是 python 3 和 setuptools(新的包括分发但现在称为 setuptools,而不是旧的 setuptools,它被弃用用于分发工具,只是为了重新进入分发和分发重命名为 setuptools.....)

I appreciate these are from different versions of python and the distribution system is in a complete mess, but assuming I am using python 3 and setuptools (the new one that includes distribute but now called setuptools, not the old setuptools that was deprecated for distribute tools only to be brought back into distribute and distribute renamed to setuptools.....)

我遵循标准"文件夹结构和 setup.py 文件,

and I'm following the 'standard' folder structure and setup.py file,

  1. 我需要 MANIFEST.in 吗?
  2. 里面应该有什么?
  3. 什么时候才能将所有这些不同的封装系统和方法整合到一个简单的流程中?

推荐答案

回复:我需要 MANIFEST.in 吗?

不,您不必使用 MANIFEST.in.distutilssetuptools 都包含在源代码中分发包setup.py中提到的所有文件——模块,打包python文件,README.txttest/test*.py.如果这就是您想要在分发包中拥有的全部内容,那么您可以不必使用 MANIFEST.in.

Re: "Do I need a MANIFEST.in?

No, you do not have to use MANIFEST.in. Both, distutils and setuptools are including in source distribution package all the files mentioned in setup.py - modules, package python files, README.txt and test/test*.py. If this is all you want to have in distribution package, you do not have to use MANIFEST.in.

如果要操作(添加或删除)要包含的默认文件,则必须使用 MANIFEST.in.

If you want to manipulate (add or remove) default files to include, you have to use MANIFEST.in.

程序很简单:

  1. 确保在您的 setup.py 中包含(通过 setup 参数)您认为对程序运行很重要的所有文件(模块、包、脚本...)

  1. Make sure, in your setup.py you include (by means of setup arguments) all the files you feel important for the program to run (modules, packages, scripts ...)

澄清,如果有一些文件要添加或一些文件要排除.如果两者都不需要,则不需要使用 MANIFEST.in.

Clarify, if there are some files to add or some files to exclude. If neither is needed, then there is no need for using MANIFEST.in.

如果需要 MANIFEST.in,请创建它.通常,你在那里添加 tests*/*.py 文件,README.rst 如果你不使用 README.txtdocs 文件,可能还有一些用于测试套件的数据文件(如有必要).

If MANIFEST.in is needed, create it. Usually, you add there tests*/*.py files, README.rst if you do not use README.txt, docs files and possibly some data files for test suite, if necessary.

例如:

include README.rst
include COPYING.txt

要测试它,请运行 python setup.py sdist,并检查在 dist/ 下创建的 tarball.

To test it, run python setup.py sdist, and examine the tarball created under dist/.

比较今天和 2 年前的情况 - 情况要好得多 - setuptools 是要走的路.你可以忽略这个事实,distutils 有点坏,它是 setuptools 的低级基础,因为 setuptools 会负责向你隐藏这些东西.

Comparing the situation today and 2 years ago - the situation is much much better - setuptools is the way to go. You can ignore the fact, distutils is a bit broken and is low level base for setuptools as setuptools shall take care of hiding these things from you.

EDIT:我使用 pbr 构建具有三行 setup.py 的分发包的最后几个项目,其余在 setup 中.cfgrequirements.txt.无需关心 MANIFEST.in 和其他奇怪的东西.即使这个包应该得到更多的文档.请参阅 http://docs.openstack.org/developer/pbr/

EDIT: Last few projects I use pbr for building distribution packages with three line setup.py and rest being in setup.cfg and requirements.txt. No need to care about MANIFEST.in and other strange stuff. Even though the package would deserve a bit more documentation. See http://docs.openstack.org/developer/pbr/

这篇关于python项目需要MANIFEST.in吗,里面应该有什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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