Opinionated PEP 440 Python versioning for Git repos and submodules. Enforces CI/User authority and generates rich version.py files with deep metadata for auditability. Native Hatch & Setuptools support. Simple, predictable, and foolproof automation.
Project description
Simple, predictable, and opinionated versioning for Python projects.
Documentation | Roadmap | Issues | Discussions
Overview
GitVersioned is a PEP 440-compliant Python versioning tool for Git repositories. It leverages Git history and CI environments as the ultimate source of truth to provide predictable, automated release versioning with zero runtime dependencies.
Why GitVersioned?
GitVersioned combines strict PEP 440 compliance with extreme customizability, designed to drop cleanly into modern Python build systems.
- Ironclad Auditability & Metadata: Generates rich
version.pyfiles packed with Git hashes, branch names, and build context to ensure every artifact is fully traceable. - Predictability & Authority: Enforces CI-driven and user-defined authority. Supports dynamic version resolution from tags, branches, commits, local files, archives (e.g., GitHub ZIP downloads), or custom Python hooks.
- Native Integrations & CI/CD Ready: Offers out-of-the-box support for Hatch and Setuptools and plugs effortlessly into modern CI pipelines (e.g., GitHub Actions) without tangled configurations.
- Deep Customizability: Features 25+ configuration settings via
pyproject.toml,setup.cfg, or environment variables. Provides advanced ExStr templates and custom format strings for full control over metadata generation and release formatting. - Archive Fallback: Seamlessly resolves version data from GitHub ZIP downloads or source archives when the
.gitdirectory is missing. - Submodule Awareness: Intelligently handles versioning across complex Git submodule structures.
Ecosystem Comparison
| Tool | Versioning Logic & PEP 440 | Sourcing & Configuration | Auditability & Metadata | Integrations & DX |
|---|---|---|---|---|
GitVersioned |
Predictable & Robust. Enforces strict PEP 440 compliance with flow-based auto-incrementing logic. | Omni-Source. Dynamically resolves from Git, archives, env vars, files, or custom Python hooks. | Unmatched. Generates rich version.py files packed with Git, build, and host environment data. |
Superior. 2-line setup, zero runtime deps, and native Hatch/Setuptools support. |
setuptools-scm |
Heuristic. Relies on "guess-next-version" logic which can lead to unpredictable bumps. | VCS-First. Primarily Git/Hg tags; environment overrides are manual and difficult to manage. | Minimal. Outputs a simple version string with basic stdout build logging. | Standard. Industry default but requires build-time dependencies and is tied to Setuptools. |
versioneer |
Rigid. Uses basic tag-plus-distance logic with little room for customization. | VCS-Only. Hardcoded to read from repository tags and hashes. | None. Injects a hardcoded Python module; executes silently with no tracing. | Legacy. Requires vendoring ~2,000 lines of code directly into your repository. |
versioningit |
Manual. Highly configurable but places the burden of PEP 440 compliance on complex user regex/templates. | Modular. Supports many sources but requires extensive individual manual configuration. | Moderate. Customizable output via templates but lacks a unified, structured metadata model. | Complex. Steep learning curve and plugin-heavy architecture. |
hatch-vcs |
Basic. Inherits the standard "guess" logic from the broader SCM ecosystem. | Optimized. Tied tightly to Hatchling profiles and its specific environment. | Internal. Logging and metadata are strictly restricted to the Hatch ecosystem. | Niche. High ease of use for Hatch users, but inapplicable for other build backends. |
Quick Start
Installation & Configuration
GitVersioned is primarily used as a build plugin. The preferred pathway is to configure it in your pyproject.toml:
[build-system]
requires = ["hatchling", "gitversioned"]
build-backend = "hatchling.build"
[tool.hatch.version]
source = "gitversioned"
To ensure gitversioned can resolve the version when users download your repository as a ZIP file (e.g., from GitHub) where the .git directory is missing, configure Archive Support:
- Create a
.git_archival.txtfile in your repository root with the following format variables:commit_sha: $Format:%H$ short_sha: $Format:%h$ timestamp: $Format:%aI$ author_name: $Format:%an$ author_email: $Format:%ae$ ref_names: $Format:%D$ commit_message: $Format:%B$
- Enable variable substitution during archive creation by adding the following to your
.gitattributesfile:.git_archival.txt export-subst
For full installation options, Setuptools alternatives, and step-by-step onboarding, see the Getting Started guide.
Core Concepts
GitVersioned is built using modern Python tooling, enforcing strict code quality standards with Ruff and Mypy, and providing a robust Pydantic-driven settings architecture for configuration resolution.
Component Architecture
The repository is structured to separate documentation, application logic, and testing cleanly:
src/gitversioned/: The primary application source code. Contains core logic for Git interaction, version resolution, and template generation.plugins/: Native integrations for build backends like Hatchling (hatchling_plugin.py) and Setuptools (setuptools_plugin.py).
tests/: Comprehensive test suite ensuring reliability, organized intounit/,integration/, ande2e/.docs/: Source code for the MkDocs Material documentation site, including step-by-step guides, references, and getting started tutorials.examples/: Runnable reference projects demonstrating real-world configurations across various build systems and workflows..github/workflows/: Advanced CI/CD pipelines governing the project lifecycle, built around reusable workflow templates.
Advanced Usage
Please check the examples/ directory for advanced examples and configurations.
General
Contributing
We welcome contributions! Please see our Contributing Guide for more details. For development setup, check out DEVELOPING.md. Please ensure you follow our Code of Conduct in all interactions.
Support and Security
- For help and general questions, see SUPPORT.md.
- To report a security vulnerability, please refer to our Security Policy.
AI & LLM Tooling
This repository includes first-class support for agentic and LLM-assisted development workflows:
- AGENTS.md: Repository-specific instructions for AI coding agents (Codex, Copilot Workspace, Gemini, Claude, Cursor, and similar tools). Contains the authoritative guide for project structure, executable commands, code style, and critical constraints.
- llms.txt: A machine-readable index of the project's documentation, following the llms.txt specification. Served at
/llms.txton the documentation site to help LLMs quickly locate and consume relevant content.
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Citations
If you use this software in your research, please cite it using the following BibTeX entry:
@software{gitversioned,
author = {Mark Kurtz},
title = {gitversioned},
year = {2026},
url = {https://github.com/markurtz/git-versioned}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitversioned-0.1.2.tar.gz.
File metadata
- Download URL: gitversioned-0.1.2.tar.gz
- Upload date:
- Size: 155.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3aef1a37da9b25b6e8dc9b94d09fbda4179c054d2eca749efdc113c31309659a
|
|
| MD5 |
5ffb3e13f856be6499ea0bff15c55ed0
|
|
| BLAKE2b-256 |
ab27d616a90630cfe5349008be88a67aa459f4ab37484a8b846d0fd59a13ccf0
|
Provenance
The following attestation bundles were made for gitversioned-0.1.2.tar.gz:
Publisher:
release.yml on markurtz/git-versioned
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitversioned-0.1.2.tar.gz -
Subject digest:
3aef1a37da9b25b6e8dc9b94d09fbda4179c054d2eca749efdc113c31309659a - Sigstore transparency entry: 1541205224
- Sigstore integration time:
-
Permalink:
markurtz/git-versioned@ecfe50d7f5c2c8f1bac71a2a6921afb8b018e2db -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/markurtz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ecfe50d7f5c2c8f1bac71a2a6921afb8b018e2db -
Trigger Event:
push
-
Statement type:
File details
Details for the file gitversioned-0.1.2-py3-none-any.whl.
File metadata
- Download URL: gitversioned-0.1.2-py3-none-any.whl
- Upload date:
- Size: 40.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed074fd19e2b19f74520848f3a69b09bc1195c655c686666daf4df721a582720
|
|
| MD5 |
0051f7d14b2f6e093b171f4be156acf9
|
|
| BLAKE2b-256 |
e760ad2fb7bc3b75ceedb60b8dbb79454c20e5bf9ca4a67e193631fce5a9bb2d
|
Provenance
The following attestation bundles were made for gitversioned-0.1.2-py3-none-any.whl:
Publisher:
release.yml on markurtz/git-versioned
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitversioned-0.1.2-py3-none-any.whl -
Subject digest:
ed074fd19e2b19f74520848f3a69b09bc1195c655c686666daf4df721a582720 - Sigstore transparency entry: 1541205299
- Sigstore integration time:
-
Permalink:
markurtz/git-versioned@ecfe50d7f5c2c8f1bac71a2a6921afb8b018e2db -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/markurtz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ecfe50d7f5c2c8f1bac71a2a6921afb8b018e2db -
Trigger Event:
push
-
Statement type: