Skip to main content

Poetry plugin to update __version__ in __init__ file and other files containing version strings

Project description

Logo

The poetry version command only updates version in pyproject.toml file. This plugin updates version in other files when poetry version <version> command is executed.

Build Status Coverage Status Python Versions PyPI version Licence

Getting Started

Prerequisites

  • python = ^3.8

  • poetry = ^1.2.0

Install

Install the plugin by poetry plugin command.

poetry self add poetry-bumpversion

Configure version replacements

Say you have __version__ variable set at your_package/__init__.py file

__version__ = "0.1.0" # It MUST match the version in pyproject.toml file

Add the following to your pyproject.toml file.

[tool.poetry_bumpversion.file."your_package/__init__.py"]
# Duplicate the line above to add more files

Now run poetry version patch --dry-run, if your output looks somewhat like below you are all set (dry-run does not update any file).

Bumping version from 0.5.0 to 0.5.1
poetry-bumpversion: processed file: your_package/__init__.py

If dry-run output looks fine you can run version update command without dry-run flag to check if version in both pyproject.toml and your_package/__init__.py file has been updated.

Advanced Usage

You can define search and replace terms to be more precise

[tool.poetry_bumpversion.file."your_package/__init__.py"]
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'

You can define replacements if you have same search/replace patterns across multiple files.

[[tool.poetry_bumpversion.replacements]]
files = ["your_package/__init__.py", "your_package/version.py"]
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'

[[tool.poetry_bumpversion.replacements]]
files = ["README.md"]
search = 'version: {current_version}'
replace = 'version: {new_version}'

Usage with Github Workflow

This plugin can be used to bump version automatically during publishing to PyPI using a GitHub workflow. When a release tag is created the workflow will use that tag name e.g 2.0.1 to update versions in every files, build the package and publish to PyPI. This is how this plugin is deployed to PyPI.

To get started you can copy the deploy workflow code from this repo to your repo and set it up.

License

This project is licensed under MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poetry_bumpversion-0.3.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

poetry_bumpversion-0.3.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file poetry_bumpversion-0.3.2.tar.gz.

File metadata

  • Download URL: poetry_bumpversion-0.3.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for poetry_bumpversion-0.3.2.tar.gz
Algorithm Hash digest
SHA256 6a8d6917d5a56b74d8edfc29badf1500b1f50aa43538d36b17495b41355a8b7a
MD5 5516a134088a0ff3b540b0d9b56c989a
BLAKE2b-256 0f5ccec670e30fe224109e4abfa9977311b0881b963f13ebd55a88aec5c71338

See more details on using hashes here.

File details

Details for the file poetry_bumpversion-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for poetry_bumpversion-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 df51b3c27330820ad036e83b6ab6db083dcaeb13bab3f320b781c69a38773f81
MD5 d916278119adb2ac09b86519e5fc3118
BLAKE2b-256 dd980f269412debe2c92b6362c6193bc4fb29b7cb39fef0ea42d47e8ff3ae8b4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page