- cross-posted to:
- programming@programming.dev
- cross-posted to:
- programming@programming.dev
hatch has hardcoded awareness of Git and Mercurial and specifically searches for project-level .gitignore and .hgignore to read those files directly. But it doesn’t handle user-level or system-level config, so anything you have ignored from config outside of your project, like .env in my example, will not be ignored by hatch, and will wind up in your sdist.
ah that probably explains why I didn’t have this problem, same reason why I don’t like global gitignores
Even if you’re using git or hg for version control you’ll probably wind up with more in your sdist than you need: things like
uv.lock,Justfile, or the contents of yourtests/dir might not be harmful, but they bloat your sdist and don’t really belong there, and hatch will package them up with your source code unless you explicitly configure it not to.you just need
only-includehttps://hatch.pypa.io/1.13/config/build/#explicit-selection
it’s easier than changing build backends
and a lot of times
tests/(anddocs/) are included with source code in an sdist format - https://discuss.python.org/t/should-sdists-include-docs-and-tests/14578Interesting discussion, thanks for the link! I side with pf_moore there; when I think of distributing a library I think of shipping only the library code itself and none of the supporting files, although I can understand the argument to include things like
tests/anddocs/.That said, if you haven’t already tailored your project for hatch, configuring
only-includeis more work than switching to a build backend that just bundles source modules by default. With the right config hatch can do what you like, and I can understand existing users sticking with it, but for newbies I think it’s really risky to suggest a build backend that grabs everything it finds in the working directory and packages it up for PyPI. It’s just surprising and dangerous default behavior imo.
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?
Caution
If you use setuptools, please be aware that some features that predate standardisation efforts are now deprecated and only temporarily kept for compatibility.
In particular, do not use direct python setup.py invocations. On the other hand, configuring setuptools with a setup.py file is still fully supported, although it is recommended to use the modern [project] table in pyproject.toml (or setup.cfg) whenever possible and keep setup.py only if programmatic configuration is needed. See Is setup.py deprecated?.
Other examples of deprecated features you should not use include the setup_requires argument to setup() (use the [build-system] table in pyproject.toml instead), and the easy_install command (cf. pip vs easy_install).
https://packaging.python.org/en/latest/guides/tool-recommendations/
it’s just easier to have a modern hassle-free setup with the other tools
Thank you. That seems quite problematic. I would expect the build backend only to include what I tell it to. IIRC pyproject has a field to tell which packages exist in the project and I’d expect only that to be included + what was specified e.g resources like images.
the article doesn’t mention the many ways you can define what (not) to include that hatch offers.
The problem is the default. It’s seemingly opt-out, not opt-in. That leads to experiences like these.
There is no way for xyz to be either included or excluded from a package cuz everyone should be running
python -m buildand checking the tarball and.whlbefore even considering a commit or a release.So although the OP chose hitch that doesn’t change the workflow of manually checking the tarball.
I use setuptools, wreck (requirements management), and drain-swamp (choose versioning by either “tag” or “current” rather than specifying exact semantic version). What i use has no bearing on the opinion above.
“modern” means you are a little bitch. I’m very tired of that term. A function with multiple return statements is considered “modern”. Whereas i see that as wrong. So now that “modern” word is being thrown around for packaging?! Please stop using that term. It’s a cope for not being able to code your own build backend (drain-swamp), frame stack free locals inspection (logging-strict), and requirements management (wreck)!
Use whatever you are familiar with without peer pressuring others.



