Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I bump the Python package version using uv?

Poetry has the version command to increment a package version. Does the uv package manager have anything similar?

like image 290
neves Avatar asked Mar 04 '26 22:03

neves


2 Answers

This feature has been introduced with the release of uv 0.7.0. Especially, uv version now can be used to inspect and bump a project's version.

Show current version.

$ uv version
stack-example 1.2.3

Bump patch / minor / major version.

$ uv version --bump patch
stack-example 1.2.3 => 1.2.4
$ uv version --bump minor
stack-example 1.2.4 => 1.3.0
$ uv version --bump major
stack-example 1.3.0 => 2.0.0

Show version of uv itself (previously by running uv version).

$ uv self version
uv 0.7.1 (90f46f89a 2025-04-30)
like image 94
Hericks Avatar answered Mar 07 '26 12:03

Hericks


EDIT: Since uv 0.7.0 there is a uv version command, explained above.


I do this:

# Replace with your version
VERSION="0.5.0"
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION

If you need to retrieve:

uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version

Works in a Dockerfile, makefile, etc.

If you need to bump the version by using specifiers like patch, minor, or major:

v=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)

# Bump patch version
part="patch"
uvx --from bump2version bumpversion --allow-dirty --current-version "$v" "$part" pyproject.toml
like image 32
McAbra Avatar answered Mar 07 '26 12:03

McAbra