-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add a command to read and update (i.e., bump) the project version, e.g., uv version
#6298
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 |
Hope this helps!! (edit was for formatting) (added response to other question) |
No, we might also want to get the current version directly without resorting to TOML parsing or
This would be nice to have but there may be many cases where people still do a lot of manual things between bumping the version and actually making the release, e.g. bumping first, creating a commit, creating the changelog, then git-amending that changelog etc.
Not that I can think of.
We sometimes use it for other, more complex build scripts, or within CI runs.
No, and I would have expected it to be
Semver exclusively.
This is mostly a manual decision. However there are projects using conventional commits where you could infer this automatically based on the previous commit types (feature/fix/…).
We have some use cases where we have one project A's version be dependent on another project B's version, so if B gets released with a new version, sometimes A will also get a new version. So we might just skip some versions in between. |
Yes.
We usually bump the version from a manual CI job (GitLab CI), this creates a tagged commit which triggers a tag pipeline which does the build and release. If it is a library, then it is published to something like Artifactory. We usually also bump a few other files configured via templates in the
No
Version is not inspected from At runtime or in tests we read a
No but looks like a useful and natural interface. (Like
We use semver (
It is a manual action, as bump-my-version provides a way to bump each version part.
No |
Thanks for these quick responses! I want to add another question
|
No, we use git-based dynamic versioning via a hatch plugin (
Split commands would work better. I want to either get the current version, or get a bumped version string to externally create a new git tag, which then propagates back to dynamic version generation. Something like
No.
During CI (when triggered via a comment command to create a release), we get the bumped version string, create a git tag, then run the build that dynamically uses the git-derived version. Since it's on a tag, it is now exactly the bumped version string. For non-commit releases, it just reads the current version and posts a comment saying what development version is available for download.
No.
Semver, in the form
Manually set by a Git comment command (e.g.
No.
No. |
The only field I could think of could be the uv is part of our worker image to build the But |
We currently use a monorepo structure with one common library and 5 different applications that are using the common library. When we change the version in the common library we also update the version in all applications that use that library. Currently, we are using a manual approach with
No, we also need the current version sometimes in our CI environment. Currently, we grep it from init.py files.
For our workflow we would also need a way to bump the version to a dirty/dev release since in our pipelines we also run end2end tests before we merge a PR (currently every PR leads to a new version of a component). In the end2end tests we also install the applications from our internal pypi. But since the version is not yet released we create development drops for those tests. When the PR gets merged we then finally release the actual version.
Yes, as described in 2. Before we actually release a new version we currently replace the version in pyproject.toml and init.py in our CI with a
See 3. For creating a development drop.
No
Semver
Currently, it's a manual step. Developer creates a PR that already has the bumped version. But this leads to problems since when another PR got merged there are merge conflicts and the version needs to be bumped again. Currently, we use
Maybe for the
No, currently I don't see a use case in our workflow. |
No, we also need to get the version dynamically in CI and other checks. (
I don't think so, I think it is best when those concepts are separated and controlled differently.
We use version bumps manually at different stages of development.
No.
We use semver. I think the concepts are the same, though I think there will have to be a template of some sort to derive the calver version format.
It's a manual action, so it depends on the work that was done.
Very rarely. When this is the case it's almost always to align separate apps to have the same version on a major release.
Currently we don't, but I can see where reading |
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/
|
✅ 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: