python项目需要MANIFEST.in吗,里面应该有什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24727709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Do python projects need a MANIFEST.in, and what should be in it?
提问by Neil Walker
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
“Python 分发”指南(位于 python-distribute.org,但注册已失效)告诉我要包含doc/txt
文件,并且.py
文件被排除在MANIFEST.in
文件中
The sourcedist documentationtells 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
该sourcedist文档告诉我只有sdist用途MANIFEST.in
,并只包括文件指定和包含.py
文件。它还告诉我使用:python setup.py sdist --manifest-only
生成一个MANIFEST
,但是python告诉我这不存在
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.....)
我很欣赏这些来自不同版本的 python 并且分发系统一团糟,但假设我使用的是 python 3 和setuptools
(包括分发但现在称为 setuptools 的新版本,而不是旧的 setuptools,它已弃用仅用于分发工具重新分配并分发重命名为 setuptools .....)
and I'm following the 'standard' folder structure and setup.py
file,
我遵循“标准”文件夹结构和setup.py
文件,
- Do I need a
MANIFEST.in
? - What should be in it ?
- When will all these different package systems and methods be made into one single simple process ?
- 我需要
MANIFEST.in
吗? - 里面应该有什么?
- 什么时候将所有这些不同的包装系统和方法整合到一个简单的过程中?
采纳答案by Jan Vlcinsky
Re: "Do I need a MANIFEST.in?
回复:“我需要 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
. 两者,distutils
并且setuptools
被包括在源分发包中提到的所有文件setup.py
-的模块,包Python文件,
README.txt
和test/test*.py
。如果这是您希望在分发包中拥有的全部内容,则不必使用MANIFEST.in
.
If you want to manipulate (add or remove) default files to include, you have to use MANIFEST.in
.
如果要操作(添加或删除)要包含的默认文件,则必须使用MANIFEST.in
.
Re: What should be in it?
回复:里面应该有什么?
The procedure is simple:
程序很简单:
Make sure, in your
setup.py
you include (by means ofsetup
arguments) all the files you feel important for the program to run (modules, packages, scripts ...)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
.If
MANIFEST.in
is needed, create it. Usually, you add theretests*/*.py
files,README.rst
if you do not useREADME.txt
,docs
files and possibly some data files for test suite, if necessary.
确保在你的文件中
setup.py
包含(通过setup
参数)你认为对程序运行很重要的所有文件(模块、包、脚本......)澄清,如果有一些文件要添加或一些文件要排除。如果两者都不需要,则不需要使用
MANIFEST.in
.如果
MANIFEST.in
需要,创建它。通常,您会在那里添加tests*/*.py
文件,README.rst
如果您不使用README.txt
,docs
文件和可能的测试套件的一些数据文件,如有必要。
For example:
例如:
include README.rst
include COPYING.txt
To test it, run python setup.py sdist
, and examine the tarball created under dist/
.
要测试它,请运行python setup.py sdist
并检查在 下创建的 tarball 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.
比较今天和两年前的情况——情况要好得多——setuptools
是要走的路。你可以忽略这个事实,distutils
它有点破碎并且是低级别的基础,setuptools
因为setuptools
应该照顾向你隐藏这些东西。
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/
编辑:我pbr
用于构建具有三行的分发包的最后几个项目setup.py
,其余在setup.cfg
和 中requirements.txt
。无需关心MANIFEST.in
和其他奇怪的东西。即使这个包应该得到更多的文档。请参阅http://docs.openstack.org/developer/pbr/
回答by Klaas van Schelven
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:
不,你不需要MANIFEST.in
。但是,要setuptools
完成您(通常)的意思,您确实需要使用setuptools_scm
,它MANIFEST.in
在两个关键位置发挥作用:
- 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 thebuild
orbdist_wheel
. (again: files under source control)
- 它确保在运行
sdist
命令时打包所有相关文件(其中所有相关文件被定义为“源代码控制下的所有文件”) - 当
include_package_data
用于将包数据包含为build
or 的一部分时bdist_wheel
。(再次:源代码控制下的文件)
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.
历史上的理解MANIFEST.in
是:当你没有源代码控制系统时,你需要一些其他的机制来区分“源文件”和“碰巧在你工作目录中的文件”。但是,您的项目受源代码控制(对吗??),因此不需要MANIFEST.in
. 这篇文章中有更多信息。