Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
setuptools-git-versioning 3.1.0
setuptools-git-versioning 3.1.0
  • Comparison with other tools

How to

  • Install
  • Console command
  • CI configuration
  • Retrieving package version at runtime
  • Supporting git archive builds
  • Versioning schemas
    • Tag-based release (not recommended)
      • Release is a git tag
      • Post release
      • Dirty version
    • File-based release (recommended)
      • Read some file content as current version
      • Development releases (prereleases) from dev branch
      • Development releases from any branch
      • Development releases using only branch name
    • Callback-based release (advanced)
      • Execute some callback function to get current version
  • Config options
    • enabled
    • starting_version
    • template
    • dev_template
    • dirty_template
    • version_file
    • count_commits_from_version_file
    • version_callback
    • sort_by
    • branch_formatter
    • tag_formatter
    • tag_filter
  • Template substitutions
    • tag
    • ccount
    • sha
    • full_sha
    • branch
    • env
    • timestamp
  • Common issues
    • Every version built by CI is dirty
    • Wrong tag ordering/latest tag number detection
    • Sphinx usage

Develop

  • Changelog
    • 3.1.x
    • 3.0.x
    • 2.1.x
    • 2.0.x
    • 1.13.x
    • 1.12.x
    • 1.11.x
    • 1.10.x
    • 1.9.x
    • 1.8.x
    • 1.7.x
    • 1.6.x
    • 1.5.x
    • 1.4.x
    • 1.3.x
    • 1.2.x
    • 1.1.x
  • Contributing Guide

Project Links

  • Source Code
  • CI/CD
  • Issue Tracker
Back to top
View this page

File-based release (recommended)ΒΆ

By default, setuptools-git-versioning can be used only within:

  • git repo, which means a .git subfolder should exist in the repo root folder

  • branch with at least one tag

Otherwise it will be impossible to get project version based on the git repo commits, and setuptools-git-versioning will return version number 0.0.1 (or other value set up by starting_version).

But one or all of these requirements cannot be satisfied in the following cases:

  • Downloading source tarball without .git folder (#77).

  • Shallow repo clone without tags (#75).

  • Getting version number from a branch which does not contain any tags (Git-flow and its derivatives)

To avoid getting meaningless version number prefer using versioning schema described below.

  • Read some file content as current version
  • Development releases (prereleases) from dev branch
  • Development releases from any branch
  • Development releases using only branch name
Next
Read some file content as current version
Previous
Dirty version
Copyright © 2020-present, dolfinus
Made with Sphinx and @pradyunsg's Furo
Last updated on May 15, 2026