python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.47k stars 2.27k forks source link

poetry version bumps with --version-file options #8130

Open dazza-codes opened 1 year ago

dazza-codes commented 1 year ago

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.
shengchenyang commented 11 months ago

I also hope to add the function of synchronously updating the version parameter in pyproject.toml and the specified file path.

bildcode commented 3 months ago

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)