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.
Full answer: https://github.com/pypa/setuptools/issues/3883#issuecomment-1494308302
Summary:
tests
and the docs
folder from the sdist, add these two lines to your MANIFEST.in:prune tests
prune docs