Use Hatch for build backend and project management #71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR migrates the project management and build backend to Hatch, which is a standards-compliant PyPA-backed project. As part of this, all dependency and metadata for the project has been migrated to the new pyproject.toml format (PEP 518, PEP 621).
Project version is now managed in the new
zabbix_auto_config/__about__.py
file, which can be bumped withhatch version
. In the future we can also extend this functionality with the hatch-regex-commit plugin to create git tags and commits whenever the version is bumped.Why Hatch over setuptools?
Hatch makes virtual environment and dependency management easy. A single command (
hatch shell
) creates a virtual environment, installs all dependencies (both application and development dependencies), and then enters the virtual environment.Environments
Hatch provides the ability to add multiple development environments à la tox and nox without adding a bunch of boilerplate. Furthermore, different environments can be defined for different purposes, such as testing and documentation.
Scripts can be configured to run against a test matrix of different python versions and feature flags with just a few lines of configuration.
Scripts
Hatch provides the ability to define scripts that can be run against specific environments. Given the following configuration that defines an environment for building and serving documentation:
We can define Hatch scripts that lets us build and serve the documentation:
Which we can run like this:
Plugins
Hatch provides a plugin interface, which allows third party authors to extend the functionality of Hatch. The Hatch documentation lists some of these in the following categories:
Why not Poetry?
Poetry has repeatedly shown a lack of respect for PEP standards, and generally invent their own solutions when it comes to dependencies, environments, etc. Hatch handles separate environments and dependencies in a standards-compliant way, and enables the resulting pyproject.toml file to be parsed by any PEP 621-compliant metadata parser.
Also watch: why I will never use python-poetry