jorisroovers / gitlint

Linting for your git commit messages
http://jorisroovers.github.io/gitlint
MIT License
806 stars 99 forks source link

Use Hatch for project management #384

Closed jorisroovers closed 1 year ago

jorisroovers commented 1 year ago

Initial implementation of project management using hatch.

@ofek: Appreciate if you can give this a quick review, but understand if you don't have time!

Required follow-up

Questions

CC: @ofek

ofek commented 1 year ago

I noticed the gitlint-core packages have the dash replaced with underscore, e.g.: gitlint_core-0.19.0.dev2.tar.gz . AFAIK, setuptools keeps the dash. Is this just a build-tool implementation detail or is there some PEP or other rationale I’m not aware of?

https://peps.python.org/pep-0625/ though you can disable strict-naming e.g. https://hatch.pypa.io/latest/plugins/builder/wheel/#options

Why is the .gitignore included in the build?

https://hatch.pypa.io/latest/plugins/builder/sdist/#default-file-selection

so building from sdist is reproducible

Is there a way to have a script that can run across different environments?

not yet

Maybe I missed it, but from the docs, it’s not entirely clear what Hatchling is [...] Perhaps a short Q/A can be added to the FAQ?

https://github.com/pypa/hatch/commit/497408385f54e2f99a06a4cb61c3e604f0185deb

jorisroovers commented 1 year ago

For my own future reference:

I noticed the gitlint-core packages have the dash replaced with underscore, e.g.: gitlint_core-0.19.0.dev2.tar.gz . AFAIK, setuptools keeps the dash. Is this just a build-tool implementation detail or is there some PEP or other rationale I’m not aware of?

https://peps.python.org/pep-0625/ though you can disable strict-naming e.g. https://hatch.pypa.io/latest/plugins/builder/wheel/#options

From PEP-625 I found https://packaging.python.org/en/latest/specifications/binary-distribution-format/ which specifies:

In distribution names, any run of -. characters (HYPHEN-MINUS, LOW LINE and FULL STOP) should be replaced with (LOW LINE), and uppercase characters should be replaced with corresponding lowercase ones. This is equivalent to PEP 503 normalisation followed by replacing - with _.


Why is the .gitignore included in the build?

https://hatch.pypa.io/latest/plugins/builder/sdist/#default-file-selection

so building from sdist is reproducible

Had to read carefully, but think I figured it out. The build docs mention:

By default, Hatch will respect the first .gitignore or .hgignore file found in your project's root directory or parent directories. Set ignore-vcs to true to disable this behavior:

So if the builds needs to be reproducible from sdist, hatch needs to know which files to ignore in the sdist tarball. When building the sdist tarball using hatch itself, I don't think any of the git ignored files would still be included in the tarball since hatch would've already respected the .gitignore file, but I reckon that could've been overridden by specifying a specific include clause in the sdist build config.