astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
26.86k stars 782 forks source link

What is the recommended way to manage package's version #9126

Open maxkoretskyi opened 5 days ago

maxkoretskyi commented 5 days ago

I'm using pyproject.toml to define package metadata:

[build-system]
requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta"

[project]
name = "myp"
requires-python = ">=3.11"
version = "0.19.1b4"      <--------------------------------------------- <here>
...

I can put the package's version (in this case 0.19.1b4) directly into the pyproject.toml, but are there more sophisticated scenarios supported by uv?

Something like this maybe

[project]
dynamic = ["version"]

[tool.setuptools.dynamic]
version = { attr = "mylib.__version__" }

or perhaps there's a built-in tooling for version management.

zanieb commented 5 days ago

A dynamic version is problematic with our design, for discussion see #7533

Dynamic metadata in general isn't recommended. It adds a great deal of complexity to the packaging ecosystem. I'd recommend just using a static version, that's what we do here in this project. There's an issue at https://github.com/astral-sh/uv/issues/6298 tracking addition of a command to update the version programatically. Lots more context and discussion there.

maxkoretskyi commented 5 days ago

great, thanks for the links, I'll explore