setuptools-git-versioning
Use git repo data (latest tag, current commit hash, etc) for building a version number according to PEP 440.
Features:
Can be installed & configured through both setup.py and PEP 518’s pyproject.toml
Does not require to change source code of the project
Tag-, file-, and callback-based versioning schemas are supported
Templates for tag, dev and dirty versions are separated
Templates support a lot of substitutions including git and environment information
Well-documented
See comparison between setuptools-git-versioning and other tools.
Limitations:
Currently the only supported VCS is Git
Only Git v2 is supported
Setuptools and build backends supporting dynamic-metadata (e.g. scikit-build-core 1.0+) are supported.
Currently does not support automatic exporting of package version to a file for runtime use (but you can use setuptools-git-versioning > file redirect instead)
Documentation
See https://setuptools-git-versioning.readthedocs.io/en/stable/
Install
pyproject.toml
Just add setuptools-git-versioning to build-sytem section of your pyproject.toml, add a section tool.setuptools-git-versioning with config options, and mark the project version as dynamic.
[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"]
And check the package version generated (see command help):
$ python -m setuptools_git_versioning
0.0.1
# or
$ setuptools-git-versioning
0.0.1
When add a git tag:
$ git add .
$ git commit -m "Test tagged"
$ git tag 1.2.3
And now version is based on git tag:
$ setuptools-git-versioning
1.2.3
$ echo 1 > uncommitted.change
$ git add .
$ setuptools-git-versioning
1.2.3.post0+git.d2bc6516.dirty
$ git commit -m "Test committed"
$ setuptools-git-versioning
1.2.3.post1+git.d452190b
setup.py
Just add setuptools-git-versioning to setup_requires argument of setuptools.setup function call, and then add new argument setuptools_git_versioning with config options:
import setuptools
setuptools.setup(
...,
setuptools_git_versioning={
"enabled": True,
},
setup_requires=["setuptools-git-versioning>=3.0,<4"],
)
Commands are the same as above, plus python -m setup.py returns the same version.
dynamic-metadata
For build backends supporting dynamic-metadata 0.4+, select the registered provider in [[tool.dynamic-metadata]]. For example, with scikit-build-core 1.0+:
[build-system]
requires = [ "scikit-build-core>=1.0", "dynamic-metadata>=0.4", "setuptools-git-versioning>=3.2,<4", ]
build-backend = "scikit_build_core.build"
[project]
name = "mypackage"
dynamic = ["version"]
[[tool.dynamic-metadata]]
provider = "setuptools_git_versioning.dynamic_metadata"
[tool.setuptools-git-versioning]
enabled = true
The provider sets only version and reads options from [tool.setuptools-git-versioning]. Inline settings in [[tool.dynamic-metadata]] are not supported. The provider itself has no runtime dependency on dynamic-metadata.
Metadata
Release files for setuptools-git-versioning 3.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| setuptools_git_versioning-3.2.0.tar.gz | 18.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| setuptools_git_versioning-3.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.4 kB
Release files / setuptools_git_versioning-3.2.0.tar.gz
| Download URL | setuptools_git_versioning-3.2.0.tar.gz |
|---|---|
| Size | 18.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27aa1ad0409b632ee49947ea592cc27e16fbb2a1605cc22efeb7c353fd790b31
|
|
BLAKE2b-256 checksum How to use checksums |
66b4a6d4757f1687aac56e74dc4952878c7c9dcd02a5c3256a5020b205e236e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.
Transparency logRelease files / setuptools_git_versioning-3.2.0-py3-none-any.whl
| Download URL | setuptools_git_versioning-3.2.0-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
99ba418d3e5b790ffd6347c89c8c9da92d917b73f5a918e4eb10622358ae9c48
|
|
BLAKE2b-256 checksum How to use checksums |
588376facb877924e2feebbeb86727234ebbdafbbe6932ccea37e2be3a0aa901
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.
Transparency log