experimental/cuda-ubi9/: hatch-vcs-0.4.0 metadata and description

Simple index

Hatch plugin for versioning with your preferred VCS

author_email Ofek Lev <oss@ofek.dev>
  • Development Status :: 4 - Beta
  • Programming Language :: Python
  • Programming Language :: Python :: 3.8
  • Programming Language :: Python :: 3.9
  • Programming Language :: Python :: 3.10
  • Programming Language :: Python :: 3.11
  • Programming Language :: Python :: 3.12
  • Programming Language :: Python :: Implementation :: CPython
  • Programming Language :: Python :: Implementation :: PyPy
description_content_type text/markdown
keywords git,hatch,mercurial,plugin,scm,vcs,version
license MIT
  • Funding, https://github.com/sponsors/ofek
  • History, https://github.com/ofek/hatch-vcs/blob/master/HISTORY.md
  • Issues, https://github.com/ofek/hatch-vcs/issues
  • Source, https://github.com/ofek/hatch-vcs
  • hatchling>=1.1.0
  • setuptools-scm>=6.4.0
requires_python >=3.8
File Tox results History
8 KB
Python Wheel


CI/CD CI - Test CD - Build
Package PyPI - Version PyPI - Python Version
Meta Hatch project code style - black types - Mypy License - MIT GitHub Sponsors

This provides a plugin for Hatch that uses your preferred version control system (like Git) to determine project versions.

Table of Contents

Global dependency

Ensure hatch-vcs is defined within the build-system.requires field in your pyproject.toml file.

requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

Version source

The version source plugin name is vcs.

Version source options

Option Type Default Description
tag-pattern str see code A regular expression used to extract the version part from VCS tags. The pattern needs to contain either a single match group, or a group named version, that captures the actual version information.
fallback-version str The version that will be used if no other method for detecting the version is successful. If not specified, unsuccessful version detection will raise an error.
raw-options dict A table of setuptools-scm parameters that will override any of the options listed above. The write_to and write_to_template parameters are ignored.

Version source environment variables

Build hook

The build hook plugin name is vcs.

Building or installing when the latest tag is v1.2.3 will generate the file

Build hook options

Option Type Default Description
version-file str REQUIRED The relative path to the file that gets updated with the current version.
template str The template used to overwrite the version-file. See the code for the default template for each file extension.

Editable installs

The version file is only updated upon install or build. Thus the version number in an editable install (Hatch's dev mode) will be incorrect if the version changes and the project is not rebuilt. An unsupported workaround for keeping the version number up-to-date can be found at hatch-vcs-footgun-example.

Metadata hook

Note: only Git is supported

The metadata hook plugin is for inserting VCS data (currently the commit hash) into metadata fields other than version. Its name is vcs.

Metadata hook options


The urls option is equivalent to project.urls except that each URL supports context formatting with the following fields:

Be sure to add urls to project.dynamic:


Migration tips

If you are migrating from setuptools, you may want access to the version without performing a full build.

By default, python -m setuptools_scm will display the version and perform any side-effects like writing to a file. hatch separates these functions.

Display version

hatch version will print the version to the terminal without modifying the source directory.

$ hatch version

Write version to file

If version-file is defined, you can write it to the source directory with the build command, using the --hooks-only flag to modify the source tree but skip creation of sdists or wheels.

$ hatch build --hooks-only
$ cat package/_version.py
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '23.0.0.dev17+g462372ba'
__version_tuple__ = version_tuple = (23, 0, 0, 'dev17', 'g462372ba')


hatch-vcs is distributed under the terms of the MIT license.