setuptools-git-versioning
Use git repo data for building a version number according to PEP-440
What it is and what it does
setuptools-git-versioning is a setuptools plugin that derives your package's version number directly from your git repository state at build time. Instead of hardcoding a version string in setup.py or pyproject.toml, it reads git tags, commit hashes, and dirty status to generate a PEP 440-compliant version automatically. This eliminates the need to manually bump version strings before releases and keeps your version source-of-truth in git tags.
The plugin integrates into the build process via setuptools' build backend or scikit-build-core, supporting both pyproject.toml and setup.py configuration. It offers tag-based, file-based, and callback-based versioning schemas with customizable templates for tagged, development, and dirty-state versions. Configuration is minimal—typically just enabling the plugin and marking version as dynamic—and it requires only git v2 and setuptools to be available.
Use it for:
- Automatically version releases by creating git tags without editing version strings in source files.
- Generate development versions with commit hashes for pre-release builds and CI/CD pipelines.
- Mark builds from uncommitted changes with a 'dirty' suffix to distinguish development snapshots from clean releases.
- Maintain a single source of truth for versioning in git history rather than scattered version strings across the codebase.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automatically generates PEP 440-compliant version numbers for Python packages based on git repository state (tags, commits, dirty status) during the build process.
Yes, if you use setuptools or scikit-build-core and want to eliminate manual version management. The package is actively maintained, has no known vulnerabilities, low install friction, and a permissive license. The main constraint is that it requires a git repository and Git v2; if your build process does not have git available or you use a different build backend (Poetry, etc.), it will not work.
Install
setuptools-git-versioning on PyPI
pip
pip install setuptools-git-versioninguv
uv add setuptools-git-versioningpoetry
poetry add setuptools-git-versioningInstalling setuptools-git-versioning
Before you install
Low friction installation with a pure-wheel distribution. Actively maintained as of 2026-05-15 with recent commits. Three lightweight runtime dependencies (packaging, setuptools, tomli) that are commonly already present in build environments.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal restrictions.
Quickstart
# In pyproject.toml:
[build-system]
requires = ["setuptools>=41", "wheel", "setuptools-git-versioning>=3.0,<4"]
build-backend = "setuptools.build_meta"
[tool.setuptools-git-versioning]
enabled = true
[project]
dynamic = ["version"]
# Then run:
$ setuptools-git-versioning
# Output: 0.0.1 (or version based on git tag)
Requires a Git repository and Git v2 to be present; only works with setuptools or scikit-build-core build backends, not Poetry or others.
Verify before relying
- Whether the package handles shallow clones or sparse checkouts correctly.
- Performance impact when called repeatedly during complex multi-stage builds.
- Compatibility with monorepo setups where multiple packages share a single git root.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — packaging, setuptools, tomli |
| Maintenance | actively maintained — 91 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,571,890/month — #3,749 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: setuptools_git_versioning-3.1.0-py3-none-any.whl
Keywords: setuptools, git, versioning, pep-440
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
setupmetaReduces boilerplate in setup.py by…
permissive · top 5,000 on PyPI
setuptools-scmAutomatically extracts and manages Python…
permissive · top 1,000 on PyPI
versioningitAutomatically determines your Python package's…
permissive · top 5,000 on PyPI
looseversionProvides a drop-in replacement for the…
permissive · top 5,000 on PyPI
update_checkerChecks whether a whitelisted Python package has…
permissive · top 5,000 on PyPI
charm-refresh-build-versionWrites charm version information into…
unclear · top 15,000 on PyPI
setuptools-scm-git-archiveA setuptools_scm plugin that extracts version…
permissive · top 5,000 on PyPI
IncrementalIncremental is a CalVer version manager that…
permissive · top 5,000 on PyPI
setuptools-gitA setuptools plugin that automatically includes…
permissive · top 15,000 on PyPI
versioneer-518Automates version management in…
permissive · top 15,000 on PyPI