Skip to content

Instantly share code, notes, and snippets.

@eggplants
Created March 31, 2025 23:22
Show Gist options
  • Save eggplants/aa348e1543a283e991e971f9cd3bbc90 to your computer and use it in GitHub Desktop.
Save eggplants/aa348e1543a283e991e971f9cd3bbc90 to your computer and use it in GitHub Desktop.
Variation of `tool.hatch.version` in Hatch configuration

Variation of tool.hatch.version in Hatch configuration

Created at: 2025-04-01

Hatch official

[tool.hatch.version]
source = "regex"
# required
path = "src/pkg/__init__.py"
# optional
pattern = "__version__ = ['\"](?P<version>[^'\"]+)['\"]"
[tool.hatch.version]
source = "code"
# required
path = "src/pkg/__init__.py"
# optional
expression = "__version__"
search-paths = ["src"]
[tool.hatch.version]
source = "env"
# required
variable = "VERSION"

Hatch unofficial

[tool.hatch.version]
source = "uv-dynamic-versioning"

vcs (hatch-vcs)

[tool.hatch.version]
source = "vcs"
# optional
tag-pattern = '(?P<version>\d+(?:\.\d+){0,2}[^+]*)(?:\+.*)?$'
raw-options = { version_scheme = "release-branch-semver" }
fallback-version = "0.0.0"
[tool.hatch.version]
source = "versioningit"
# optional
default-version = "0.0.0+unknown"

[tool.hatch.version.format]  # optional
distance = "{next_version}.dev{distance}+{vcs}{rev}"
dirty = "{version}+dirty"
distance-dirty = "{next_version}.dev{distance}+{vcs}{rev}.dirty"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment