-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add a command to read and update (i.e., bump) the project version, e.g., uv version
#6298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Would maintaining version identifiers outside of Or, even better, support a dynamic version like hatch does with a [project]
dynamic = ["version"]
[tool.hatch.version]
path = "src/package/__init__.py" |
It's most convenient to me to have https://github.com/mtkennerly/poetry-dynamic-versioning I would love to have this functionality. |
Would also love to see this... I'm currently using poetry-version-plugin in versioned projects and want to switch them to uv |
Also very interested in this feature. This kind of read/update version command seems very common (not only Poetry but npm, etc) and it'd make migration to uv from other tools that much more straightforward.
@JonZeolla I've used PDM's dynamic versioning in the past (which is essentially the same as the Hatch example you provide) but have found it kind of annoying in practice. IMO it's preferable to have the version in pyproject.toml be the source of truth. That version can be exposed in the Python package using [tool.poetry]
name = "my-package"
version = "1,2,3" # my_package/__init__.py
from importlib.metadata import version
__version__ = version("my_package") |
Personally I also like the idea of basing the version on the current git tag when using together with CI/CD. |
Covering what bump-my-version (and previously bumpversion) do would cover that (including customizing the git tag and commit message format) An interesting addition would be to have a way to trigger a custom An even better but probably too opinionated option could be to add a CHANGELOG management system (like changie) but it might be out of scope of uv? |
For others who need this. uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION I'm using it like this in github action. VERSION=$(uvx dunamai from any --no-metadata --style pep440)
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION
uv build |
Consider how My workflow looks like this: # Show current version
poetry version
# Bump version
poetry version minor
# Add a git tag with a matching version to what's in pyproject.toml
git tag "v$(poetry version -s)" Poetry tries to be clever to avoid needing an option to specify whether you are auto-bumping or manually setting a version:
This assumes that no-one will ever want to use one of those strings as a version, but that seems like a reasonably safe assumption. |
With hatch even when you have the |
Using |
I'd love to see something like this as well - I currently use |
As a workaround, I use this in my project:
|
Exactly what I did, I just wasn't comfortable w/ it |
No we need this throughout different stages of development.
No, as we bump versions on applications that aren't packages and therefore don't need to be built or published.
Yes, for unique github releases and tracking what version of code broke anything.
We use the package version when creating releases. We don't use uv's version for anything.
Dependent on if we are doing a breaking change or not.
To set unique dev versions per developer during development. |
Yes
I would prefer a way to let me tag a release, and let that tag trigger a github action that would build (for multiple OS / arch / python) and publish (throug Trusted Publisher workflow)
No
I need both the current and updated ones to generate a commit which update the version number, date, and diff link in the changelog. I would not have to bake a script for that if uv provided hooks like cargo-release
No,
Yes, yes (different projects). eg., given pyproject
breaking changes / new features / any other reason
No
No |
No
No
Just for my personal knowledge.
Rarely, as others have said
Both. Calver I personally would want it to bump to the current date as yyyy.mm.dd but I’m sure there’s many ways to do this.
Major: breaking changes / minor: new features / patch: anything else.
Sometimes but I would just set it manually
No |
This is what my current process looks like with Poetry. poetry version # show current version from pyproject.toml (includes project name)
poetry version minor # bump minor version in pyproject.toml
git tag "v$(poetry version -s)" # add git tag with current version from pyproject.toml (-s flag shows only the version number)
I may be biased as an existing Poetry user, but I think they get the API pretty right for poetry version. |
A few suggestions/additions:
This could give commands like:
The commands are a bit longer though (but those can easily be aliased). |
We've got a PR up for an interface/implementation we're reasonably happy with: #12349 We might still make |
Honest feedback: it’s pretty verbose command wise. I would love the uv version sugar as my 2 cents of feedback. I personally like just uv bump as well. Thanks for adding this! Very appreciative. |
We're not particularly settled between |
I get it. I do think |
I feel that
|
|
I think that there would be unnecessary confusion by having a subcommand named I think it makes a lot of sense to have a I would be very excited about being able to type |
One more vote for shorter being better. As the uv command I will probably use the most, I'd much rather type
|
The command syntax is not as important as the feature, setting aliases is quite easy for those who need them. And for my use-cases, it will be used in CI hence typing the command is not a question. And the coherence with Cargo is interesting too: https://doc.rust-lang.org/cargo/commands/cargo-metadata.html Having more automations around that command would be awesome (optional/configurable |
In case you’re unfamiliar, or if it’s been a while and you’ve forgotten, run this in your terminal: python3 -c "import this" I tend to concur with all of it, especially the last line. The In the same manner as In the case of The Concepts overview page gives a good list of what might be desirable to capture as command namespaces:
|
I didn’t have experience with
instead of using a git tag as the single version source, which, in my opinion, has certain advantages? |
I'd say: Because projects are not always shared as Git repositories (in particular the actual Python distributions), and not everyone might use Git. The pyproject.toml file should be a single source of truth for the project and its metadata. |
If I'm reading the current PR correctly, it looks like it won't be able to read the dynamic version generated by a plugin? That's a bit unfortunate, since I'm not entirely sure how to extract that bit of information without using external tools that could get out of sync with the project file (e.g. If the |
Just a thought based on https://pypi.org/project/bumpver/
|
…edits (#12349) This is a reimplementation of #7248 with a new CLI interface. The old `uv version` is now `uv self version` (also it has gained a `--short` flag for parity). The new `uv version` is now an interface for getting/setting the project version. To give a modicum of support for migration, if `uv version` is run and we fail to find/read a `pyproject.toml` we will fallback to `uv self version`. `uv version --project .` prevents this fallback from being allowed. The new API of `uv version` is as follows: * pass nothing to read the project version * pass a version to set the project version * `--bump major|minor|patch` to semver-bump the project version * `--dry-run` to show the result but not apply it * `--short` to have the final printout contain only the final version * `--output-format json` to get the final printout as json ``` $ uv version myfast 0.1.0 $ uv version --bump major --dry-run myfast 0.1.0 => 1.0.0 $ uv version 1.2.3 --dry-run myfast 0.1.0 => 1.2.3 $ uv version 1.2.3 myfast 0.1.0 => 1.2.3 $ uv version --short 1.2.3 $ uv version --output-format json { "package_name": "myfast", "version": "1.2.3", "commit_info": null } ``` Fixes #6298
…edits (#12349) This is a reimplementation of #7248 with a new CLI interface. The old `uv version` is now `uv self version` (also it has gained a `--short` flag for parity). The new `uv version` is now an interface for getting/setting the project version. To give a modicum of support for migration, if `uv version` is run and we fail to find/read a `pyproject.toml` we will fallback to `uv self version`. `uv version --project .` prevents this fallback from being allowed. The new API of `uv version` is as follows: * pass nothing to read the project version * pass a version to set the project version * `--bump major|minor|patch` to semver-bump the project version * `--dry-run` to show the result but not apply it * `--short` to have the final printout contain only the final version * `--output-format json` to get the final printout as json ``` $ uv version myfast 0.1.0 $ uv version --bump major --dry-run myfast 0.1.0 => 1.0.0 $ uv version 1.2.3 --dry-run myfast 0.1.0 => 1.2.3 $ uv version 1.2.3 myfast 0.1.0 => 1.2.3 $ uv version --short 1.2.3 $ uv version --output-format json { "package_name": "myfast", "version": "1.2.3", "commit_info": null } ``` Fixes #6298
since #12349 got merged, what's the new standard way to handle version bumps in github action? |
I believe what you posted is, as of 0.7.1, equivalent to |
✅ Both Rye and Poetry have this, and it's quite useful both...
pyproject.toml
file serve as the single source of truth for a project's version, easily accessible (viauv
) in CI workflows, etc.🛑 The latter is where my personal interests lie: I have a CI workflow that tags and deploys releases when the version is bumped, currently using Poetry for it. I don't really want to pull in an additional tool to parse the project specs, so it's currently keeping me from considering migrating to
uv
.📜 My proposal is replacing the current functionality of the
version
subcommand with this, sinceuv
's version can already be accessed via the-V | --version
option, and other project management currently exist as "root" subcommands.ℹ️ I'm willing to give this one a go myself if maintainers greenlight the proposal.
The text was updated successfully, but these errors were encountered: