Skip to main content

bump-py-version

This is a simple and opinionated python tool to bump the of a python package.

  1. The script will check for any changes in the current git repository and abort if there are any.

  2. If there are no changes, it will check for a version field in pyproject.toml. If the project.version exist it is altered to the specified version. Other options are specified below.

  3. The script commits and pushes the changes.

  4. Then a new tag is created using the new version specified to the script.

  5. Finally the script pushes the new tag to the remote repository.

Installation

Install the latest version from PyPI with uv:

uv tool install bump-py-version

Configuration

You may also bump the python version __version__ in e.g. __init__.py file (or similar) using a pyproject.toml setting like the following:

[tool.bump_version]
version_file = "bump_py_version/__init__.py"

You may configure the script to alter text files (e.g. README.md) by setting the section tool.bump_version.replace_patterns in the pyproject.toml file. Example:

[tool.bump_version.replace_patterns.pipx]
file = "README.md"
search = "<!-- LATEST-VERSION-UV -->"
replace = "\tuv tool install bump-py-version=={version}\n"

The above will cause the line below the search string to be replaced with the replace string. Then it is easy to show the latest version of the package in a README.md file.

Updating uv.lock

To update uv.lock as part of each version bump, enable:

[tool.bump_version]
uv_lock = true

This runs uv lock after updating the version files and before staging changes, so the lockfile is included in the release commit and tag. It does not request dependency upgrades. If the lockfile does not exist, uv lock creates it.

uv must be installed and available on PATH. The command checks these prerequisites before modifying files and rejects an ignored uv.lock, explaining that it must be removed from .gitignore or the applicable Git ignore rules. An existing, untracked lockfile must be committed before bumping, just like any other non-ignored untracked file.

If uv lock fails, the command stops before committing, pushing, or tagging; local edits remain available for inspection. The setting defaults to false, which preserves the existing behavior without running uv.

Usage example

Example:

bump-py-version v1.2.3

License

MIT © Dennis Iversen

Metadata

Release files for bump-py-version 2.1.2

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

Source distribution (sdist)

Source distribution for bump-py-version 2.1.2
File Size Uploaded
bump_py_version-2.1.2.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bump-py-version 2.1.2
File Interpreter ABI Platform
bump_py_version-2.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / bump_py_version-2.1.2.tar.gz

Download URL bump_py_version-2.1.2.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ed5048d36a1878a144c46e4a0b2dad65a078fdc03896ab84053e96e583979158
BLAKE2b-256 checksum
How to use checksums
cbbf93df1f14b1deb0c88a212f6612e97f70a5811e84cc4e5e2a51b889eabc6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / bump_py_version-2.1.2-py3-none-any.whl

Download URL bump_py_version-2.1.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a9b44758bb8608edb192d7c023e486f0f36eda7f09dd7502731acdeab57c070
BLAKE2b-256 checksum
How to use checksums
bef589a008190790b9af8c2c9ef1234c28d9f09032056ce0345b59d5ca5c4c7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

2.1.2 This release

2 release files

2.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