Folders included in the tar.gz, not in the wheel, setuptools build

Question:

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.

Asked By: KevinYanesG

||

Answers:

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
Answered By: KevinYanesG
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.