问题:python项目需要MANIFEST.in吗,应该在其中吗?

“ Python分发”指南(位于python-distribute.org,但注册已失败)告诉我包括doc/txt文件,并且.py文件中排除了MANIFEST.in文件

sourcedist文档告诉我只有sdist用途MANIFEST.in,并只包括文件指定和包含.py文件。它还告诉我使用:python setup.py sdist --manifest-only生成一个MANIFEST,但是python告诉我这不存在

我很欣赏它们来自不同版本的python,并且分发系统完全混乱,但是假设我使用的是python 3,并且setuptools(新的包括distribution,但现在称为setuptools,而不是不赞成仅用于分发工具的旧setuptools重新分配到发行版,并将发行版重命名为setuptools …..)

我遵循的是“标准”文件夹结构和setup.py文件,

  1. 我需要一个MANIFEST.in吗?
  2. 应该是什么?
  3. 所有这些不同的包装系统和方法何时才能形成一个简单的过程?

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

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

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…..)

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

  1. Do I need a MANIFEST.in ?
  2. What should be in it ?
  3. When will all these different package systems and methods be made into one single simple process ?

回答 0

回复:“我需要一个MANIFEST.in吗?

不,您不必使用MANIFEST.in。两者,distutils并且setuptools被包括在源分发包中提到的所有文件setup.py-的模块,包Python文件, README.txttest/test*.py。如果这是分发包中所需的全部内容,则不必使用MANIFEST.in

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

回复:里面应该有什么?

程序很简单:

  1. 确保在您中setup.py(包含setup参数)包含对程序运行至关重要的所有文件(模块,程序包,脚本…)

  2. 澄清一下,是否有要添加的文件或要排除的文件。如果都不需要,则无需使用MANIFEST.in

  3. 如果MANIFEST.in需要,请创建它。通常情况下,你添加有tests*/*.py文件,README.rst如果你不使用README.txtdocs如果有必要的文件,可能还有一些数据文件的测试套件。

例如:

include README.rst
include COPYING.txt

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

这些不同的包装系统何时会…

比较今天和2年前的情况-情况要好得多- setuptools是要走的路。您可以忽略一个事实,distutils它有点破损,并且是低级别的基础,setuptools因此setuptools请注意对您隐藏这些东西。

编辑:我使用的最后几个项目pbr用于构建分发包,其中三行setup.py,其余部分在setup.cfg和中requirements.txt。无需关心MANIFEST.in和其他奇怪的东西。即使该软件包值得更多文档。参见http://docs.openstack.org/developer/pbr/

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.

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

Re: What should be in it?

The procedure is simple:

  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 …)

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

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

For example:

include README.rst
include COPYING.txt

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

When will all these different package systems …

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: 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/


回答 1

旧问题,新答案:

不,您不需要MANIFEST.in。但是,要setuptools执行您(通常)的意思,您确实需要使用setuptools_scm,它MANIFEST.in在2个关键位置扮演角色:

  • 它确保在运行sdist命令时打包所有相关文件(其中所有相关文件都定义为“源代码控制下的所有文件”)
  • include_package_data用于将包数据包括为build或的一部分时bdist_wheel。(再次:在源代码控制下的文件)

历史上的理解MANIFEST.in是:当您没有源代码控制系统时,您需要其他机制来区分“源文件”和“碰巧在您的工作目录中的文件”。但是,您的项目处于源代码控制之下(正确吗?),因此不需要MANIFEST.in本文中的更多信息

Old question, new answer:

No, you don’t need MANIFEST.in. However, to get setuptools to do what you (usually) mean, you do need to use the setuptools_scm, which takes the role of MANIFEST.in in 2 key places:

  • It ensures all relevant files are packaged when running the sdist command (where all relevant files is defined as “all files under source control”)
  • When using include_package_data to include package data as part of the build or bdist_wheel. (again: files under source control)

The historical understanding of MANIFEST.in is: when you don’t have a source control system, you need some other mechanism to distinguish between “source files” and “files that happen to be in your working directory”. However, your project is under source control (right??) so there’s no need for MANIFEST.in. More info in this article.


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。