Hatch-vcs is a Hatch plugin that enables project versioning using your preferred Version Control System (VCS), such as Git or Mercurial. It integrates with Hatch's build system to dynamically determine the package version based on VCS tags. The current version is 0.5.0, and it maintains an active release cadence, frequently updating to support new Python versions and Hatchling features.
pip install hatch hatch-vcsVerified import paths — ran on the pinned version, not inferred.
This configuration in `pyproject.toml` sets up `hatch-vcs` to derive your package's version from Git tags. It also specifies a `_version.py` file to be generated at build time, ensuring a static version is available in your distribution. The `project.dynamic` field should include `"version"` to enable dynamic versioning.
Upgrade Python to >=3.9 or use `hatch-vcs<0.5.0`. Python 3.7 support was dropped in v0.4.0 and Python 2 in v0.3.0.
For dynamic version updates in editable installs, a hybrid approach (e.g., falling back to `importlib.metadata` or setting the `MYPROJECT_HATCH_VCS_RUNTIME_VERSION` environment variable and ensuring `hatch-vcs` is available at runtime) is recommended.
Upgrade to `hatch-vcs` version 0.5.0 or newer to avoid these warnings.
Upgrade to `hatch-vcs` version 0.4.0 or newer to prevent this warning.
Ensure Python scripts are syntactically valid and contain only Python code. Do not embed or directly execute configuration file syntax (like TOML) within Python scripts. If reading configuration, use appropriate libraries (e.g., `tomllib` or `toml`).
Ensure that your `pyproject.toml` file is correctly structured under the `[build-system]` table and is being parsed by a compatible build tool (like `pip` or `hatch`) and not directly executed as Python code within a script or an incompatible environment.