Skip to article frontmatterSkip to article content

How Do I Use __version__ with hatchling?

First, set the version to be dynamic and remove the version field:

pyproject.toml
[project]
dynamic = ["version"]
# version = "1.0.0"

Then tell hatchling about the version source:

pyproject.toml
[tool.hatch.version]
source = "regex"
path = "src/arrow_to_knee/__init__.py"

Now add __version__ to __init__.py