在tar.gz中包含的文件夹,不在wheel或setuptools构建中。

huangapple go评论61阅读模式
英文:

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处于同一层次结构的顶层文件夹,例如testsdocs文件夹,这些文件夹不应该被包括在内。有趣的是,只包括了docs中的一些文件,而不是全部文件。

我们尝试在pyproject.tomlsetup.cfgMANIFEST.in中明确排除testsdocs文件夹,按照各自的文档,但都没有帮助。

我们在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中排除例如testsdocs文件夹,请将以下两行添加到您的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 the docs folder from the sdist, add these two lines to your MANIFEST.in:
prune tests
prune docs

huangapple
  • 本文由 发表于 2023年2月7日 01:52:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75364863.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定