Poetry 有 version 命令来增加包版本。 uv包管理器有类似的人吗?
目前
uv
包管理器没有像 poerty 的 version
命令那样的内置命令来更改包版本。您可以手动pyproject.toml
或使用脚本自动化
例如:
import toml
def bump_version(file_path, part="patch"):
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
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}")
希望这有帮助。