setuptools-git-versioning

3.0.1 · active · verified Sat Apr 11

setuptools-git-versioning is a Python library that automatically infers package versions from Git repository data, adhering to PEP 440. It allows configuration via `pyproject.toml` or `setup.py`/`setup.cfg` and supports tag-, file-, and callback-based versioning schemas with flexible templating. The library is actively maintained, with frequent patch releases and occasional major version bumps introducing breaking changes.

Warnings

Install

Imports

Quickstart

Configure `setuptools-git-versioning` in your `pyproject.toml` to dynamically set your package's version based on Git tags and repository state. Ensure `setuptools-git-versioning` is in `build-system.requires` and `project.dynamic = ["version"]` is set.

[build-system]
requires = ["setuptools>=41", "wheel", "setuptools-git-versioning>=3.0,<4"]
build-backend = "setuptools.build_meta"

[project]
name = "my_package"
dynamic = ["version"]

[tool.setuptools-git-versioning]
enabled = true
# Optional: Customize version format
# template = "{tag}.post{ccount}+{gitsha}"
# dev_template = "{tag}.dev{ccount}+{gitsha}"
# dirty_template = "{tag}.dirty{ccount}+{gitsha}"

view raw JSON →