一个简单易用的 Python 版本管理工具,类似 npm version
Project description
Bump Version
[English | 中文说明]
A simple and easy-to-use Python version management tool, similar to npm version.
Features
- 🚀 Easy to use - CLI interface similar to npm version
- 📦 Multi-file support - Supports
__init__.py,version.py,setup.py,pyproject.toml - 🏷️ Semantic versioning - Full semver support
- 🔄 Pre-release support - Supports alpha, beta, rc, etc.
- 🐙 Git integration - Auto commit, tag, and push
- 🔧 Flexible config - Custom version file and commit message
Installation
pip install python-bump-version
Quick Start
Basic Usage
# Bump patch version (1.0.0 -> 1.0.1)
bump patch
# Bump minor version (1.0.0 -> 1.1.0)
bump minor
# Bump major version (1.0.0 -> 2.0.0)
bump major
Pre-release Versions
# Create prepatch version (1.0.0 -> 1.0.1-0)
bump prepatch
# Create preminor version (1.0.0 -> 1.1.0-0)
bump preminor
# Create premajor version (1.0.0 -> 2.0.0-0)
bump premajor
# Increment prerelease (1.0.1-0 -> 1.0.1-1)
bump prerelease
Git Integration
# Auto push to remote
bump patch --push
# Custom commit message
bump minor --message "feat: add new feature"
# Dry run (preview only)
bump major --dry-run
Custom Version File
# Use custom version file
bump patch --file custom_version.py
# Use pyproject.toml
bump minor --file pyproject.toml
Version Types
| Command | Description | Example |
|---|---|---|
patch |
Patch version | 1.0.0 → 1.0.1 |
minor |
Minor version | 1.0.0 → 1.1.0 |
major |
Major version | 1.0.0 → 2.0.0 |
prepatch |
Prepatch version | 1.0.0 → 1.0.1-0 |
preminor |
Preminor version | 1.0.0 → 1.1.0-0 |
premajor |
Premajor version | 1.0.0 → 2.0.0-0 |
prerelease |
Prerelease bump | 1.0.1-0 → 1.0.1-1 |
Supported File Formats
Python Files
# __init__.py or version.py
__version__ = "1.0.0"
# setup.py
version = "1.0.0"
pyproject.toml
[project]
version = "1.0.0"
[tool.bump-version]
version = "1.0.0"
Library Usage
from version_manager import VersionManager
# Basic usage
vm = VersionManager()
new_version = vm.bump('patch')
print(f"New version: {new_version}")
# Custom version file
vm = VersionManager('custom_version.py')
vm.bump('minor')
# Validate version
is_valid = vm.validate('1.0.0') # True
is_valid = vm.validate('invalid') # False
CLI Options
usage: bump [-h] [--file FILE] [--push] [--message MESSAGE] \
[--dry-run] [--verbose] \
{patch,minor,major,prepatch,preminor,premajor,prerelease}
Bump Version - A simple and easy-to-use version management tool
positional arguments:
{patch,minor,major,prepatch,preminor,premajor,prerelease}
Version type
optional arguments:
-h, --help Show this help message and exit
--file FILE, -f FILE Version file path (auto-detect by default)
--push, -p Auto push to remote
--message MESSAGE, -m MESSAGE
Custom commit message
--dry-run Show what would be done, but don't actually do it
--verbose, -v Show verbose output
Development
Install Dev Dependencies
pip install -e ".[dev]"
Run Tests
pytest
Code Formatting
black src tests
isort src tests
Type Checking
mypy src
Contributing
Pull requests and issues are welcome!
License
MIT License
Related Projects
- npm version - Node.js version management
- semver - Semantic Versioning
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python_bump_version-0.1.1.tar.gz
(11.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_bump_version-0.1.1.tar.gz.
File metadata
- Download URL: python_bump_version-0.1.1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82d534dc00ddc747e6ce9c733980edbb3a6051acc535c849e0e16ca11f050951
|
|
| MD5 |
00a0a548d55a390ac6ccefb7490878ab
|
|
| BLAKE2b-256 |
9e4b17a03a4afc9f3783dbf116b383edac3b81b64dcc5bd1b9f796d8278995f5
|
File details
Details for the file python_bump_version-0.1.1-py3-none-any.whl.
File metadata
- Download URL: python_bump_version-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91ed07bea1fa8cd47656064837d8a79e3a3773930668663e3de0e029e95d2246
|
|
| MD5 |
a54c28a2e4a3f9ad098c0300315c0bf5
|
|
| BLAKE2b-256 |
b5e0869006fb4038341eb7d289ea77789240c72b70a808c543a73c77b53d887b
|