I recently built a Python library for the first time in a while, and to make it available in PyPI I followed the official Python packaging guide. But it turns out there’s some rough edges in the suggested tools.
Namely, the build backend hatch puts all the files in the project directory into the built sdist, except from some files it chooses to exclude, which led to a gitignored file as well as VCS metadata getting packaged and uploaded to PyPI. This really surprised me, and I think most Python users new to packaging would be better served by choosing a conservative build backend like uv_build, which puts only the Python source modules and some specific project-level files into the sdist.
i think the conservative choice would be to use
setuptoolsas build backend.It’s the conservative choice, which is maybe not ideal for new projects as it predates many PEPs. Hatch, uv, poetry, pdm, are probably all better modern choices.
how so?
https://packaging.python.org/en/latest/guides/tool-recommendations/
it’s just easier to have a modern hassle-free setup with the other tools