Skip to main content

Poetry plugin that automates version management and records Git information for Python projects.

Project description

Poetry Versions Plugin

Test Lint License

Overview

The Poetry Versions Plugin is a powerful extension for the Poetry dependency manager, designed to automate version management and record Git information for Python projects. This plugin simplifies the process of bumping version numbers and integrates seamlessly with Git to ensure that all changes are tracked effectively.

Features

  • Automated Version Management: Easily bump major, minor, or patch versions using the poetry version command.
  • Git Integration: Automatically records Git branch, commit, and status information within your project.
  • Customizable Workflow: Configure commit message formats, allow/disallow dirty repository states, and specify which files to update.
  • Release Process Automation: Provides a script to handle releases using git flow, ensuring a streamlined and consistent release process.

Compatibility

This plugin supports:

  • Poetry 1.2+ (tested with Poetry 1.2.0 through 1.8.x)
  • Poetry 2.0+ (tested with Poetry 2.0.0 through 2.1.x)

PEP 621 Support

Poetry 2.x projects using the PEP 621 [project] table format are fully supported. The plugin automatically detects and updates the version in the correct location, whether it's in:

  • [project].version (PEP 621 format, Poetry 2.x)
  • [tool.poetry].version (traditional format, Poetry 1.x and 2.x)

Installation

To install the Poetry Versions Plugin, add it to your Poetry project:

poetry add poetry-versions-plugin

Poetry will automatically recognize the plugin without needing additional configuration in your pyproject.toml.

Configuration

Configure the plugin in your pyproject.toml file under the [tool.versions.settings] section:

[tool.versions.settings]
allow_dirty = false
commit = true
commit_on = ["major", "minor", "patch"]
commit_message = "Bump version: {current_version} → {new_version}"
filename = [
    "poetry_versions_plugin/versions.py",
]

Main Configuration Options

allow_dirty: (default: false) If set to true, allows the version bumping even if the working directory has uncommitted changes. commit: (default: true) Automatically commit changes to the local git repository after a version bump. commit_on: Specifies which version types (major, minor, patch) trigger an automatic commit. commit_message: Format of the commit message for version bumps. filename: List of additional files to update with the new version information.

Usage

Bumping Versions

To bump the version of your project, use the poetry version command with the desired version type:

poetry version [major|minor|patch]

This command updates the version in your pyproject.toml, updates additional specified files, and commits changes if configured.

Release Process

The scripts.release:main script automates the release process using git flow. To execute a release:

poetry run release [major|minor|patch]

This script performs the following steps:

  1. Checks if you're on the develop branch.
  2. Verifies there are no uncommitted changes.
  3. Bumps the version number.
  4. Starts and finishes a git flow release.
  5. Publishes the package.

Customizing the Release Process with a Makefile

You can also customize the release process using a Makefile. Here is an example:

bump = patch
next-version = $(shell poetry version $(bump) -s --dry-run)
release:
	@echo "Creating a new release..."
	git flow release start $(next-version)
	poetry version $(bump)
	git flow release finish -m "publish"
	git push --all
	git push --tags

This Makefile example automates the version bumping and release process by leveraging git flow and Poetry commands.

Notes

The release script requires git flow to be installed and initialized in your repository. Ensure your repository is clean and on the correct branch before starting a release.

Testing

This project uses pytest for unit testing. To run tests:

poetry run pytest

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Contribution

We welcome contributions to the Poetry Versions Plugin! If you have suggestions, bug reports, or pull requests, please visit our GitHub repository.

Acknowledgments

Special thanks to the open-source community for their continuous support and contributions. Your feedback and contributions are what make projects like this possible!

Feel free to reach out via email for any additional questions or support.

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_versions_plugin-1.1.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

poetry_versions_plugin-1.1.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file poetry_versions_plugin-1.1.1.tar.gz.

File metadata

  • Download URL: poetry_versions_plugin-1.1.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.1 Darwin/25.2.0

File hashes

Hashes for poetry_versions_plugin-1.1.1.tar.gz
Algorithm Hash digest
SHA256 93d9b6021cf58bbc56d971f2544a4be8fc2a1f334dfd6ad7268e0b6b1f1a8b3d
MD5 3ea4ae922aeb527b88f6b9b5212368da
BLAKE2b-256 e023f8554a0ea968620184d2efa40fcac001cad1b4db6d8e1d8bddfc2cf2032d

See more details on using hashes here.

File details

Details for the file poetry_versions_plugin-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for poetry_versions_plugin-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 736bd26adcdfdabedbdb605493d92afdcca8670453ae26a4f21308b4555f94d0
MD5 16945e4935cef8ecb4ccb52a12cdc2f9
BLAKE2b-256 48bd4b7a919d5a98f4c73731b39774211450b4ff3392ef24295a0163e48aed94

See more details on using hashes here.

Supported by

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