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 linked directly to the documentation I read, and that’s how I wound up using hatch in the first place. Did you read my article…? Reading the official Python documentation is what led to me uploading my
.jjfolder and a gitignored.envfile to PyPI and writing this post. And writing the post was not a waste of time.That’s fine. I’m sure there are other build backends that work similarly to uv_build and only grab what’s needed to distribute your library. The point isn’t that everyone needs to use uv_build, the point is that hatch has surprising and imo dangerous default behavior.
You see, I’ve actually read your article, you even linked to the hatchling site yourself. It takes little effort. Demonstration