英文:
Folders included in the tar.gz, not in the wheel, setuptools build
问题
自动发现setuptools.build_meta
包括不应包含在tarball中的顶层文件夹。
我们试图使用python3 -m build
构建一个Python包,我们的项目采用src-layout,并使用setuptools
作为构建的后端。根据文档,自动发现应该能够确定项目结构并相应地构建tarball和wheel。
对于wheel构建,它按预期工作,即仅包含src/...
下的文件在包中。另一方面,在tarball构建中,还包括与src
处于同一层次结构的顶层文件夹,例如tests
和docs
文件夹,这些文件夹不应该被包括在内。有趣的是,只包括了docs
中的一些文件,而不是全部文件。
我们尝试在pyproject.toml
、setup.cfg
和MANIFEST.in
中明确排除tests
和docs
文件夹,按照各自的文档,但都没有帮助。
我们在pyproject.toml
中配置了构建后端,如下所示:
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
...
我们没有setup.py
,我们的setup.cfg
只包含flake8
规范。
我们使用的是setuptools-67.1.0
,我们尝试了Python版本3.8、3.9和3.10。我们在运行conda 3.8.13的Ubuntu 20.04和Debian 11上尝试了它。
可以在这里查看tarball和wheel。
英文:
The automatic discovery of setuptools.build_meta
includes top-level folders into the tarball that shouldn't be included.
We were trying to build a python package with python3 -m build
. Our project has a src-layout and we are using setuptools
as the backend for the build. According to the documentation, the automatic discovery should figure out the project structure and build the tarball and the wheel accordingly.
For the wheel build it works as expected, i.e. only the files under src/...
are included on the package. On the other hand, in the tarball build also top-level folders that are on the same hierarchical level as src
are included. For example, the tests
and the docs
folder, which shouldn't be included. Interestingly, only a few files from the docs
were included, not all of them.
We tried to explicitly exclude the tests
and docs
folder in the pyproject.toml
, the setup.cfg
and the MANIFEST.in
, following the respective documentations, but none of them helped.
We configured the build backend in the pyproject.toml
like so:
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
...
We don't have a setup.py
and our setup.cfg
only contains flake8
specifications.
We are using setuptools-67.1.0
, we tried python versions 3.8, 3.9 and 3.10. We tried it with an Ubuntu 20.04 and a Debian 11 running conda 3.8.13.
The tarball and the wheel can be seen here.
答案1
得分: 1
完整答案:https://github.com/pypa/setuptools/issues/3883#issuecomment-1494308302
摘要:
- 这些文件默认包含在sdist中。wheel包含的文件集较小,因此上述描述的行为是预期的。
- 如果要从sdist中排除例如
tests
和docs
文件夹,请将以下两行添加到您的MANIFEST.in文件中:
prune tests
prune docs
英文:
Full answer: https://github.com/pypa/setuptools/issues/3883#issuecomment-1494308302
Summary:
- These files are included by default in the sdist. The set of files included in a wheel is smaller. Thus, the behavior described above is expected.
- If you want to exclude e.g. the
tests
and thedocs
folder from the sdist, add these two lines to your MANIFEST.in:
prune tests
prune docs
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论