从 setuptools 包中排除顶级目录 [英] Excluding a top-level directory from a setuptools package
问题描述
我正在尝试使用 setuptools 将 Python 项目放入 tarball.问题是 setuptools 似乎不喜欢源树最初设置的方式(不是我,我必须添加).我真正想要分发的所有内容都在顶级目录中,而不是像 setuptools 文档所说的那样位于子目录中.
I'm trying to put a Python project into a tarball using setuptools. The problem is that setuptools doesn't appear to like the way that the source tree was originally setup (not by me, I must add). Everything that I actually want to distribute is in the top-level directory, rather than in a subdirectory like the setuptools docs talk about.
树有一个目录,tests
,我不想在发布的包中包含它.但是,使用 exclude_package_data
似乎实际上并没有做任何排除,我想弄清楚我做错了什么.
The tree has a directory, tests
, that I don't want to have in the released package. However, using exclude_package_data
doesn't seem to actually do any excluding, and I'd like to work out what I've done wrong.
我的 setup.py
看起来像这样,在相关部分:
My setup.py
looks like this, in relevant part:
setup(
name="project",
packages=[''],
include_package_data=True,
exclude_package_data={'': ['tests']},
test_suite='nose.collector',
)
推荐答案
我们使用以下约定从包中排除测试".
We use the following convention to exclude 'tests' from packages.
setup(
name="project",
packages=find_packages(exclude=("tests",)),
include_package_data=True,
test_suite='nose.collector',
)
我们还使用 MANIFEST.in 来更好地控制 include_package_data=True
的作用.
We also use MANIFEST.in to better control what include_package_data=True
does.
这篇关于从 setuptools 包中排除顶级目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!