Skip to main content

Python package version utility to bump a version by parts.

Project description

Version Bumper

PyPI - Version PyPI - Python Version


Table of Contents

Overview

Oh, no! Not another version bump utility!

version_bumper is a PyPA Version compliant bumper that can bump (increment by 1) any part of the version and supports pyproject.toml's project.version and tool.poetry.version key/value pairs.

What this means is:

  • version_bumper fully complies with the version definition in the Python Packaging Authority's (PyPA) (https://www.pypa.io/) Python Packaging User Guide Version specifiers specification (originally PEP440).

  • version_bumper manages the version(s) in the pyproject.toml file.

    • Poetry uses the key/value pair tool.poetry.version (expecting this to change when version 2 is released)
    • other tools use the current PyPA standard key/value pair project.version
    • project.version is required to exist.
    • if tool.poetry.version exists, then it will be updated when project.version is updated.
    • if tool.poetry.version does not exist, then version_bumper will NOT create it.
  • version_bumper lets you set or bump individual parts of the version as well as setting or getting the full version.

  • version_bumper supports input and output in json, text (for bash scripts), or human-readable console.

  • version_bumper has a full suite (100% coverage) of tests that serve as both examples and validation.

Usage

Let's demonstrate what version_bumper can do.

➤ version_bumper
usage: Version Bumper [-h] [--config FILE] [--save-config] [--save-config-as FILE] [-v] [--longhelp] [--loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--debug] [--quiet] [--logfile LOGFILE]
                      {bump,version,set,get,release} ...
Version Bumper: error: A command argument (set, get, bump, release, version) or an informational option (--help, --longhelp, --version) is required

OK, so we have to give it a command or an informational option. I'll leave the informational options as an exercise for the reader.

Valid help commands are:

➤ version_bumper --help
➤ version_bumper set --help
➤ version_bumper get --help
...

Let's get the version(s):

➤ version_bumper get
project.version: 0.1.1
tool.poetry.version: 0.1.1

and as json:

➤ version_bumper get --json
{"project.version": "0.1.1", "tool.poetry.version": "0.1.1"}

and as text:

➤ version_bumper get --text
0.1.1
0.1.1

For getting the version in a bash script, you probably want to specify which version and get just a single value:

➤ PROJECT_VERSION=$(version_bumper get --text --project)
➤ echo $PROJECT_VERSION
0.1.1

Setting the version(s) in the pyproject is simple:

➤ version_bumper version "1.2.3a4+54321" --json
{"version": "1.2.3a4+54321"}

Setting the prerelease part of the version without change any other part:

➤ version_bumper set a 5 --json
{"version": "1.2.3a5+54321"}

Now let's say we want to bump the pre-release (a5):

➤ version_bumper bump a --json
{"version": "1.2.3a6"}

Notice bumping clears everything to the right, unless you are bumping the epoch:

➤ version_bumper bump epoch
version: 1!1.2.3a6

The set command can optional clear everything to the right:

➤ version_bumper bump dev
version: 1!1.2.3a6.dev1
➤ version_bumper set local "foo0123"
version: 1!1.2.3a6.dev1+foo0123
➤ version_bumper set minor 4
version: 1!1.4.3a6.dev1+foo0123
➤ version_bumper set minor 5 --clear-right
version: 1!1.5.0

Let's set the epoch back to 0:

➤ version_bumper set epoch 0
version: 1.5.0

And now make it a release candidate:

➤ version_bumper bump rc --json
{"version": "1.5.0rc1"}

Finally let's make it the release version:

➤ version_bumper release --json
{"version": "1.5.0"}

Please see the unit tests in tests/ directory for more examples.

Installation

PyPI Installation

pip install version_bumper

Development Installation

Development Prerequisites

  • Install the task manager: Task

  • Optionally install pyenv-installer

    • Install dependent pythons, example:

      pyenv local 3.11.9 3.12.3

    Note you may need to install some libraries for the pythons to compile cleanly. For example on ubuntu (note I prefer nala over apt):

    sudo nala install tk-dev libbz2-dev libreadline-dev libsqlite3-dev lzma-dev python3-tk libreadline-dev

  • Recommended to upgrade pip to latest.

  • Optionally install Poetry

  • Optionally install Hatch

  • Optionally install setuptools

Install the package using your favorite dev tool. Examples:

  • git clone git@github.com:royw/version_bumper.git
  • cd version_bumper
  • task init
  • task build

Note, task init will run git init ., git add the initial project files, and do a git commit. If you are using another VCS, please first edit the init task in the Taskfile.yaml file.

See the Developer README for detailed information on the development environment.

License

version_bumper is distributed under the terms of the MIT license.

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

version_bumper-0.1.1.tar.gz (144.6 kB view details)

Uploaded Source

Built Distribution

version_bumper-0.1.1-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file version_bumper-0.1.1.tar.gz.

File metadata

  • Download URL: version_bumper-0.1.1.tar.gz
  • Upload date:
  • Size: 144.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for version_bumper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 baef9cf10b6c7eb291424661a620800480bb3cd1ece01e3207ef2b42799a63a2
MD5 aa6331fbd823711752fa960ae6dd9f7e
BLAKE2b-256 fb0cbe5097c278b3a7a046a958cca3b696113f17bd3fa1e071bc22972ea87c88

See more details on using hashes here.

File details

Details for the file version_bumper-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for version_bumper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b5a6e1f18cfbe27e3a6d4f5c2d379d391f05c4b2dfa182f4eb4702f660fde2b
MD5 e1aad9cfb63ee06cb6548cf0151b1ef1
BLAKE2b-256 3fe8bf92e9d866621c40c73225c5e1f77f7da39bf0b5ef60f098db5c00c4f6ed

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page