Thinly scoped and opinionated tool that computes a version number from git tags and trailers
Project description
Opinionated version numbering CLIs, and library
This project aims at easing the burden of computing and managing a project's
version numbers by leveraging git
tags and commit trailers.
simple-git-versioning
provides two CLIs: semver2
and pep440
, one for each
supported versioning sheme of the same name: SemVer2
and
PEP440
.
Integration with setuptools
is supported.
Snippets to expose your project's version number programatically are provided in
the Libraries
section.
Installation
With pip
:
pip install simple-git-versioning
Usage
By default, pep440
and semver2
will compute a version number of the form
X.Y.Z
. Every project starts at 0.0.0
on their initial commit, and each
commit after that increments the number Z
by one, unless they include a
Version-Bump
trailer (case-insensitive) with a value of:
major
:X
is incremented;minor
:Y
is incremented;patch
:Z
is incremented (same as the default).
Each tool then provides the ability to switch to a pre-release mode; or
post-release, and/or dev release, etc. in the case of pep440
.
CLIs
All CLIs provide comprehensive help messages, available via the --help
option.
Libraries
Libraries that wish to expose their version number programatically may do so by including the following snippet:
from importlib.metadata import version
from versioning.pep440 import Project
try:
__version__ = version("simple-git-versioning")
except PackageNotFoundError:
# package is not installed
with _Project(path=Path(__file__).parent) as project:
try:
__version__ = str(project.version())
except NoVersion:
__version__ = str(project.release(dev=0))
setuptools
If you use setuptools
as a build backend for your project, you can configure
your project to use simple-git-versioning
to derive a build's version
automatically as follows:
In your pyproject.toml
:
- declare
version
as a dynamic metadata field; - add
simple-git-versioning
to your project'sbuild-system.requires
; - enable the
setuptools
integration in yourpyproject.toml
, and pick the versioning scheme you wish to apply.
[project]
name = ...
dynamic = ["version"]
[build-system]
requires = ["setuptools>=63", "simple-git-versioning"]
build-backend = "setuptools.build_meta"
[tool.simple-git-versioning]
setuptools = "pep440" # or "semver2"
I recommend checking out
setuptools-scm
andsetuptools-pipfile
, two othersetuptools
extensions I find greatly helpful.
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
Hashes for simple-git-versioning-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f599675e7a84e741e8071eb86d1758183450d3afd119fde50a60f43bb862b651 |
|
MD5 | d6625feb32544d4b06e04b2cfbf17dcf |
|
BLAKE2b-256 | 172c9e565e0748336f1fa254b3c197773af55fcc3754d70b7404a3df1438f98b |
Hashes for simple_git_versioning-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb52f8e3fbadea55aa5ae52351eb56fadeb3e37d4ff54c0312e55b77643fbc5b |
|
MD5 | 3f2813faa65bf2537a4529de7d13a554 |
|
BLAKE2b-256 | 86c30ab2889c025b0dc596e40d3569a11b9a29222850518c89cdb71361b58c4e |