poetry version bumps with --version-file options
- [x] I have searched the issues of this repo and believe that this is not a duplicate.
- [x] I have searched the FAQ and general documentation and believe that my question is not already covered.
Feature Request
The poetry version command has nice bump commands to update the sem-ver value in pyproject.toml. Can it be configured to also update a version.py file in the root of the project? Or adding an additional CLI option e.g.
poetry version patch \
--version-file ./my_package_root/version.py
--version-file VERSION.md \
--version-file README.md
That would be a great addition to allow projects the flexibility to use any version file (or files, if the CLI option can be used multiple times).
For reference, this is the current command help as of poetry 1.5.x
❯ poetry version --help
Description:
Shows the version of the project or bumps it when a valid bump rule is provided.
Usage:
version [options] [--] [<version>]
Arguments:
version The version number or the rule to update the version.
Options:
-s, --short Output the version number only
--dry-run Do not update pyproject.toml file
-h, --help Display help for the given command. When no command is given display help for the list command.
-q, --quiet Do not output any message.
-V, --version Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
-n, --no-interaction Do not ask any interactive question.
--no-plugins Disables plugins.
--no-cache Disables Poetry source caches.
-C, --directory=DIRECTORY The working directory for the Poetry command (defaults to the current working directory).
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
Help:
The version command shows the current version of the project or bumps the version of
the project and writes the new version back to pyproject.toml if a valid
bump rule is provided.
The new version should ideally be a valid semver string or a valid bump rule:
patch, minor, major, prepatch, preminor, premajor, prerelease.
I also hope to add the function of synchronously updating the version parameter in pyproject.toml and the specified file path.
There is a the poetry-bumpversion plugin, offering the requested feature.
I would agree this would be awesome to have as core function. (I wondered as well when I first came across beautiful poetry)
If you need the version number in your running python scripts, use importlib.metadata to get the version. For anything outside of python files the mentioned plugin seems to be the right choice.
you may check out poetry hook bump from
lightweight version only bumps version strings from pyproject.toml into specified files.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.