setuptools如何确定要保留sdist / bdist的文件? [英] How does setuptools decide which files to keep for sdist/bdist?
问题描述
我正在研究一个使用 namespace_packages
和 find_packages()
的Python包,就像在setup.py中一样:
I'm working on a Python package that uses namespace_packages
and find_packages()
like so in setup.py:
from setuptools import setup, find_packages
setup(name="package",
version="1.3.3.7",
package=find_packages(),
namespace_packages=['package'], ...)
它不在源代码控制中,因为它是一堆上游组件。没有清单。
It isn't in source control because it is a bundle of upstream components. There is no MANIFEST.
当我运行 python setup.py sdist
时,我得到了大多数文件的压缩包。在 package /
目录下,但不包含任何不包含 .py
文件的目录。
When I run python setup.py sdist
I get a tarball of most of the files under the package/
directory but any directories that don't contain .py
files are left out.
setup.py
包含和排除的内置发行版的默认规则是什么?我通过添加 MANIFEST.in
和
What are the default rules for what setup.py
includes and excludes from built distributions? I've fixed my problem by adding a MANIFEST.in
with
recursive-include package *
,但是我想了解默认情况下setuptools和distutils在做什么。 / p>
but I would like to understand what setuptools and distutils are doing by default.
推荐答案
您需要添加package_data指令。例如,如果要包括扩展名为.txt或.rst的文件:
You need to add a package_data directive. For example, if you want to include files with .txt or .rst extensions:
from setuptools import setup, find_packages
setup(name="package",
version="1.3.3.7",
package=find_packages(),
include_package_data=True,
namespace_packages=['package'],
package_data = {
# If any package contains *.txt or *.rst files, include them:
'': ['*.txt', '*.rst']...
)
这篇关于setuptools如何确定要保留sdist / bdist的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!