Skip to main content

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`
    

    Install the package using the default uv workflow. Example:

    • git clone git@github.com:royw/version_bumper.git
    • cd version_bumper
    • task switch-to-uv
    • task init
    • task make

    You can still switch to poetry, hatch, or setuptools later with the corresponding task switch-to-* command.

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

Metadata

Release files for version-bumper 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for version-bumper 0.1.3
File Size Uploaded
version_bumper-0.1.3.tar.gz 79.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for version-bumper 0.1.3
File Interpreter ABI Platform
version_bumper-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 105.7 kB

Release files / version_bumper-0.1.3.tar.gz

Download URL version_bumper-0.1.3.tar.gz
Size 79.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3aab29da7b8c0b1d4dc93bdd1c775badf3e3614858582207e08c8379751933fb
BLAKE2b-256 checksum
How to use checksums
397746c9f8a0d59e58f5fc6c8d18b76f4957fc71a6d6a438d168030a1e9a66df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / version_bumper-0.1.3-py3-none-any.whl

Download URL version_bumper-0.1.3-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
272fc4a2a17c160397a78c5724a51f3471d2f9ee8e170f19d9266b8ba2d12526
BLAKE2b-256 checksum
How to use checksums
f23ef529bb8c9fe7c0c364ca1a95a3bf66843707bb296bc4038948f749bcf8e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page