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 scikit-build-core build backends are supported (no Poetry & others)
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.
scikit-build-core
If your project uses the scikit-build-core build backend, add setuptools-git-versioning to build-system.requires, mark the version field as dynamic, register the dynamic-metadata provider, and configure options under the usual [tool.setuptools-git-versioning] section:
[build-system]
requires = [ "scikit-build-core", "setuptools-git-versioning>=3.0,<4", ]
build-backend = "scikit_build_core.build"
[project]
name = "mypackage"
dynamic = ["version"]
[tool.scikit-build.metadata.version]
provider = "setuptools_git_versioning.scikit_metadata"
[tool.setuptools-git-versioning]
enabled = true
All options under [tool.setuptools-git-versioning] work exactly as the for setuptools backend. Inline configuration under [tool.scikit-build.metadata.version] is not supported.
Release files for setuptools-git-versioning 3.1.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.1.0.tar.gz | 17.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| setuptools_git_versioning-3.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.8 kB
Release files / setuptools_git_versioning-3.1.0.tar.gz
| Download URL | setuptools_git_versioning-3.1.0.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
612dfcf184addac9e1c2216f4f229724b2390e5bf613fb925ae80b84f2529172
|
|
BLAKE2b-256 checksum How to use checksums |
538cd315ac297c004cf15b506eb53d6b0b29e18eadfc44fde7b9b971a41f3206
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 15, 2026.
Transparency logRelease files / setuptools_git_versioning-3.1.0-py3-none-any.whl
| Download URL | setuptools_git_versioning-3.1.0-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a68f3fd58a2a5e86b0792435cfa9d8e569ab60ee5e4c29228c09da9b637bf18
|
|
BLAKE2b-256 checksum How to use checksums |
e35adf537a48d60fcb23c2e76bf0192a1d812f6f540e6cae698e402a3bbc27f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 15, 2026.
Transparency log