4
you are viewing a single comment's thread
view the rest of the comments
[-] eager_eagle@lemmy.world 6 points 2 weeks ago

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

[-] dan_p_the_dev@lemmy.world 3 points 2 weeks ago

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 your tests/ 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.

[-] eager_eagle@lemmy.world 7 points 2 weeks ago* (last edited 2 weeks ago)

you just need only-include

https://hatch.pypa.io/1.13/config/build/#explicit-selection

it's easier than changing build backends

and a lot of times tests/ (and docs/) are included with source code in an sdist format - https://discuss.python.org/t/should-sdists-include-docs-and-tests/14578

[-] dan_p_the_dev@lemmy.world 2 points 2 weeks ago* (last edited 2 weeks ago)

Interesting 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/ and docs/.

That said, if you haven't already tailored your project for hatch, configuring only-include is 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.

load more comments (8 replies)
this post was submitted on 21 Sep 2026
4 points (66.7% liked)

Python

8064 readers
22 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 3 years ago
MODERATORS