Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Hatch for project management #384

Merged
merged 10 commits into from
Dec 14, 2022
Merged

Use Hatch for project management #384

merged 10 commits into from
Dec 14, 2022

Conversation

jorisroovers
Copy link
Owner

@jorisroovers jorisroovers commented Dec 1, 2022

Initial implementation of project management using hatch.

  • Adopted workflows for builds, script running, and versioning.
  • Updating contributor docs accordingly.
  • Removed all setuptools related files and all requirements files.

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

Required follow-up

  • Removing ./run_tests.sh
    • Potentially implementing a stats script that replaces ./run_tests.sh --stats, consider whether still wanted
    • Potentially implement a clean script that cleans up more directories that only dist (which is what hatch clean does)
  • Figuring out versioning in context of pushing dev builds to pypi on every commit. Potentially using hatch-vcs, but need to figure out if we can make that compatible with the need for gitlint to read the version from a file to display when doing gitlint --version
  • Looking into workspaces once implemented in hatch:
  • Cleanup of GHA checks.yaml, deduplicate between Linux and Windows. The CI script isn’t really the focus of this PR.

Questions

CC: @ofek

  • I love hatch - thanks for maintaining it! These are all just minor things.

  • 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? Just trying to learn :)

  • Why is the .gitignore included in the build? I’ve tried adding it to the excluded files and also tried setting ignore-vcs = true under [tool.hatch.build] but that didn’t work.

  • Is there a way to have a script that can run across different environments? AFAICT, there is not. Perhaps this will be supported by workspaces? Example:

    # the 'all' script runs various scripts from other environments
    [tool.hatch.envs.scripts]
    all = [
       "test:unit-tests",
       "test:format",
       "qa:integration-tests",
       "docs:build",
    ]
  • Maybe I missed it, but from the docs, it’s not entirely clear what Hatchling is, other than a dependency of Hatch, although there’s a few references to it here and there. From my 30 sec of digging it seems the be PEP517-compliant build system that’s part of Hatch? Perhaps a short Q/A can be added to the FAQ?

@jorisroovers jorisroovers added the development Issues that are not user-facing but related to gitlint development label Dec 1, 2022
@jorisroovers jorisroovers self-assigned this Dec 1, 2022
@jorisroovers jorisroovers marked this pull request as draft December 1, 2022 10:37
Much more to try out
Tring some things out in CI as well.
Trying to get the build output accurate.
This is workaround to do an editable install of gitlint-core:
See pypa/hatch#589

Also further refines a bunch of other CI and pyproject.toml items.
- Removed remaining requirements files
- Cleaned up pyproject.toml files
Cleanup of GHA config
Also includes some pyproject.toml tweaks
The package description is now using README.md which reduces the number
of descriptions to maintain.
@jorisroovers jorisroovers marked this pull request as ready for review December 12, 2022 10:47
@jorisroovers jorisroovers changed the title WIP: Hatch experiments Use Hatch for project management Dec 12, 2022
@ofek
Copy link

ofek commented Dec 13, 2022

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?

pypa/hatch@4974083

Copy link

@ofek ofek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🔥

.github/workflows/checks.yml Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
@jorisroovers
Copy link
Owner Author

jorisroovers commented Dec 14, 2022

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.

@jorisroovers jorisroovers merged commit ad534dc into main Dec 14, 2022
jorisroovers added a commit that referenced this pull request Dec 14, 2022
- Use hatch build builds and script running.
- Removes setuptools build files and requirements*.txt files.
- Updates contributor docs accordingly.
@jorisroovers jorisroovers deleted the hatch-experiments branch January 23, 2023 10:03
jorisroovers added a commit that referenced this pull request Mar 7, 2023
This release was primarily focussed on modernizing gitlint's build and test
tooling (details: #378).

General

    Python 3.6 no longer supported (EOL since 2021-12-23) (#379)
    This is the last release to support the sh library (used under-the-hood to
    execute git commands) by setting GITLINT_USE_SH_LIB=1. This is already
    disabled by default since v0.18.0.

Features

    Allow for a single commit in the --commits cmd-line param (#412)
    Gitlint now separates FILE_ENCODING (always UTF-8) from TERMINAL_ENCODING
    (terminal dependent), this should improve issues with unicode. Use
    gitlint --debug to inspect these values. (#424)

Bugfixes

    ignore-by-author-name crashes without --staged (#445)
    Various documentation fixes (#401, #433) - Thanks scop

Development

    Adopted hatch for project management (#384). This significantly improves
    the developer workflow, please read the updated CONTRIBUTING page.
    Adopted ruff for linting, replacing pylint (#404)
    Gitlint now publishes dev builds on every commit to main (#429)
    Gitlint now publishes a latest_dev docker image on every commit to
    main (#451) (#452)
    Dependencies updated
    Many improvements to the CI/CD worfklows
    Improve unit test coverage (#453)
    Integration test fixes on windows (#392, #397)
    Devcontainer improvements (#428)
    Removal of Dockerfile.dev (#390)
    Fix most integration tests on Windows
    Fix Windows unit tests (#383)
    Introduce a gate/check GHA job (#375)

Full Release details in CHANGELOG.md.
jorisroovers added a commit that referenced this pull request Mar 7, 2023
This release was primarily focussed on modernizing gitlint's build and test
tooling (details: #378).

General

    Python 3.6 no longer supported (EOL since 2021-12-23) (#379)
    This is the last release to support the sh library (used under-the-hood to
    execute git commands) by setting GITLINT_USE_SH_LIB=1. This is already
    disabled by default since v0.18.0.

Features

    Allow for a single commit in the --commits cmd-line param (#412)
    Gitlint now separates FILE_ENCODING (always UTF-8) from TERMINAL_ENCODING
    (terminal dependent), this should improve issues with unicode. Use
    gitlint --debug to inspect these values. (#424)

Bugfixes

    ignore-by-author-name crashes without --staged (#445)
    Various documentation fixes (#401, #433) - Thanks scop

Development

    Adopted hatch for project management (#384). This significantly improves
    the developer workflow, please read the updated CONTRIBUTING page.
    Adopted ruff for linting, replacing pylint (#404)
    Gitlint now publishes dev builds on every commit to main (#429)
    Gitlint now publishes a latest_dev docker image on every commit to
    main (#451) (#452)
    Dependencies updated
    Many improvements to the CI/CD worfklows
    Improve unit test coverage (#453)
    Integration test fixes on windows (#392, #397)
    Devcontainer improvements (#428)
    Removal of Dockerfile.dev (#390)
    Fix most integration tests on Windows
    Fix Windows unit tests (#383)
    Introduce a gate/check GHA job (#375)

Full Release details in CHANGELOG.md.
@jorisroovers jorisroovers added this to the 0.19.0 milestone Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Issues that are not user-facing but related to gitlint development
Projects
Status: 0.19.0
Development

Successfully merging this pull request may close these issues.

2 participants