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

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.0
File Size Uploaded
setuptools_git_versioning-3.2.0.tar.gz 18.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for setuptools-git-versioning 3.2.0
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

3.2.0 This release

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.13.6

2 release files

1.13.4

2 release files

1.13.3

2 release files

1.13.2

2 release files

1.13.1

2 release files

1.13.0

1 release file

1.12.1

1 release file

1.12.0

1 release file

1.10.0

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.1

3 release files

1.8.0

3 release files

1.7.4

3 release files

1.7.3

3 release files

1.7.2

3 release files

1.7.1

3 release files

1.7.0

3 release files

1.6.1

3 release files

1.6.0

3 release files

1.5.0

3 release files

1.4.0

3 release files

1.3.6

3 release files

1.3.5

3 release files

1.3.4

3 release files

1.3.3

3 release files

1.3.2

3 release files

1.3.1

3 release files

1.3.0

3 release files

1.2.9

3 release files

1.2.8

3 release files

1.2.7

3 release files

1.2.6

3 release files

1.2.5

3 release files

1.2.4

3 release files

1.2.3

3 release files

1.2.2

3 release files

1.2.1

3 release files

1.2.0

3 release files

1.1.14

3 release files

1.1.13

3 release files

1.1.12

3 release files

1.1.11

3 release files

1.1.10

3 release files

1.1.9

3 release files

1.1.8

3 release files

1.1.7

3 release files

1.1.5

3 release files

1.1.4

3 release files

1.1.3

3 release files

1.1.2

3 release files

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