Skip to main content

Use git repo data for building a version number according PEP-440

Project description

Project Status: Active – The project has reached a stable, usable state and is being actively developed. PyPI PyPI License PyPI Python Version ReadTheDocs Build Coverage

Use git repo data (latest tag, current commit hash, etc) for building a version number according PEP 440.


  • Can be installed & configured through both 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.


  • Currently the only supported VCS is Git

  • Only Git v2 is supported

  • Only Setuptools build backend is 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)



Contribution Guide




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.

requires = [ "setuptools>=41", "wheel", "setuptools-git-versioning>=2.0,<3", ]
build-backend = "setuptools.build_meta"

enabled = true

dynamic = ["version"]

And check the package version generated (see command help):

$ python -m setuptools_git_versioning

# or

$ setuptools-git-versioning

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

        "enabled": True,

And check the package version generated (see command help):

$ python --version

# or

$ python -m setuptools_git_versioning

# or

$ setuptools-git-versioning

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

setuptools-git-versioning-2.0.0.tar.gz (10.6 kB view hashes)

Uploaded Source

Built Distribution

setuptools_git_versioning-2.0.0-py3-none-any.whl (10.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page