Poetry has the version
command to increment a package version. Does uv package manager has anything similar?
Currently uv
package manager does not have a built-in command to bump package versions like poetry's version
command. You can manually edit pyproject.toml
or automate it with a script.
For example:
import toml
from typing import Literal
def bump_version(file_path: str, part: Literal["major", "minor", "patch"] = "patch") -> None:
with open(file_path, "r") as f:
pyproject = toml.load(f)
version = pyproject["tool"]["poetry"]["version"]
major, minor, patch = map(int, version.split("."))
if part == "major":
major += 1
minor = 0
patch = 0
elif part == "minor":
minor += 1
patch = 0
elif part == "patch":
patch += 1
else:
raise ValueError("Invalid part value. Choose 'major', 'minor', or 'patch'.")
pyproject["tool"]["poetry"]["version"] = f"{major}.{minor}.{patch}"
with open(file_path, "w") as f:
toml.dump(pyproject, f)
print(f"Version bumped to {major}.{minor}.{patch}")