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 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)

Source distribution for setuptools-git-versioning 3.1.0
File Size Uploaded
setuptools_git_versioning-3.1.0.tar.gz 17.4 kB Details

Built distribution (wheel)

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

Release 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

Release history Release notifications | RSS feed

This release

3.1.0 This release

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