VCS Versioning

1.1.1 · active · verified Wed Apr 01

vcs-versioning is a Python library that provides core version inference logic based on Version Control System (VCS) metadata. It serves as a foundational component for build backends like setuptools-scm, enabling projects to automatically derive their package version from Git tags, branches, and commit information. The library is currently at version 1.1.1 and follows an active release cadence, often in conjunction with its primary consumer, setuptools-scm.

Warnings

Install

Imports

Quickstart

This snippet demonstrates how to directly use `vcs_versioning.get_version` to infer a project's version from its VCS metadata. It attempts to find the version for the current directory, providing a fallback for environments without a detected VCS.

import os
from vcs_versioning import get_version

# To demonstrate, this will try to get the version of the current directory.
# For a real project, run this inside a Git repository.
# The fallback_version is provided to make it runnable outside a VCS context.
try:
    project_version = get_version(root=".", fallback_version="0.0.0+unknown.version")
    print(f"Project version: {project_version}")
except Exception as e:
    print(f"Could not determine project version: {e}")

view raw JSON →