Skip to main content

setuptools-git-versioning

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 pre-commit.ci

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for setuptools-git-versioning 3.2.1
File Size Uploaded Provenance Actions
setuptools_git_versioning-3.2.1.tar.gz 18.4 kB With provenance Details for setuptools_git_versioning-3.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for setuptools-git-versioning 3.2.1
File Interpreter ABI Platform Actions
setuptools_git_versioning-3.2.1-py3-none-any.whl Python 3 none any Details for setuptools_git_versioning-3.2.1-py3-none-any.whl

Total release size: 38.8 kB

Release files / setuptools_git_versioning-3.2.1.tar.gz

Download URL setuptools_git_versioning-3.2.1.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8cccd352642ed6435da35b8edaf56a2f764f061ef2edaf3ae6602806acc7105f
BLAKE2b-256 checksum
How to use checksums
0dfa6b0ecd6808b751b754c1f92d496b5525d5ff30057bde2c1bd610921a7638
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / setuptools_git_versioning-3.2.1-py3-none-any.whl

Download URL setuptools_git_versioning-3.2.1-py3-none-any.whl
Size 20.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b0c8becb835bf11716fcd0f44868da1ec7fc544585944a0ba667cba74511513
BLAKE2b-256 checksum
How to use checksums
ee62039797a26c87452f26ffcbcea7548b370d9ac22901c656f7fc43a4fff4ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Security for setuptools-git-versioning 3.2.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for setuptools_git_versioning-3.2.1.tar.gz

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 Nov 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.2.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page