Skip to main content

PEP 440 version manager

Project description

NewVersion - PEP 440 version manager

PyPI - newversion PyPI - Python Version PyPI - Downloads Docs

PyPI - Python Version Coverage

Features

Installation

python -m pip install newversion

Usage

CLI

newversion            # 0.0.0
newversion bump major # 1.0.0

# get package version from pyproject.toml, setup.cfg or setup.py
newversion -p # 1.2.3
newversion -p bump # 1.2.4
newversion -p bump pre # 1.2.4rc1
newversion -p get minor  # 2


# bump minor version and update package version
newversion -p --save bump minor

echo "1.2.3rc1" | newversion bump micro   # 1.2.3
echo "1.2.3rc1" | newversion bump minor   # 1.3.0
echo "1.2.3rc1" | newversion bump major   # 2.0.0
echo "1.2.3rc1" | newversion bump pre     # 1.2.3rc2
echo "1.2.3rc1" | newversion bump rc      # 1.2.3rc2
echo "1.2.3rc1" | newversion bump alpha   # 1.2.4a1

echo "1.2.3rc1" | newversion set micro 5  # 1.2.5rc1
echo "1.2.3rc1" | newversion set minor 5  # 1.5.3rc1
echo "1.2.3rc1" | newversion set major 5  # 5.2.3rc1
echo "1.2.3rc1" | newversion set pre 5    # 1.2.3rc5
echo "1.2.3rc1" | newversion set rc 5     # 1.2.3rc5
echo "1.2.3rc1" | newversion set alpha 5  # 1.2.3a5

echo "1.2.3rc1" | newversion get micro    # 1
echo "1.2.3rc1" | newversion get minor    # 2
echo "1.2.3rc1" | newversion get major    # 3
echo "1.2.3rc1" | newversion get pre      # rc1
echo "1.2.3rc1" | newversion get rc       # 1
echo "1.2.3rc1" | newversion get alpha    # 0

echo "1.2.3rc1" | newversion stable # 1.2.3

echo "1.2.3rc1" | newversion is_stable       # error!
echo "1.2.3" | newversion is_stable          # 1.2.3
echo "1.2.3" | newversion is_stable && echo "Stable!" # Stable!

echo "1.2.3rc1" | newversion gt "1.2.3"   # error!
echo "1.2.3rc1" | newversion lte "1.2.3"  # "1.2.3rc1"

Python library

from newversion import Version

version = Version("1.2.3")
next_version = version.bump_minor() # Version("1.3.0")

# bump version same way as SemVer
version.dumps() # "1.2.3"
version.bump_micro().dumps() # "1.2.4"
version.bump_minor().dumps() # "1.3.0"
version.bump_major().dumps() # "2.0.0"

# create and bump pre-releases
version.bump_prerelease().dumps() # "1.2.4rc1"
version.bump_prerelease(bump_release="minor").dumps() # "1.3.0rc1"
version.bump_prerelease("alpha").dumps() # "1.2.4a1"
Version("1.2.3b4").bump_prerelease().dumps() # "1.2.3b5"
version.bump_micro().replace(dev=1234).dumps() # "1.2.4.dev1234"

# and post-releases
version.bump_postrelease().dumps() # "1.2.3.post1"
Version("1.2.3.post3").bump_postrelease(2).dumps() # "1.2.3.post5"

# easily check if this is a pre- or dev release or a stable version
Version("1.2.3").is_stable # True
Version("1.2.3a6").is_stable # False
Version("1.2.3.post3").is_stable # True
Version("1.2.3.post3").get_stable().dumps() # "1.2.3"

Versioning

newversion version follows PEP 440.

Latest changes

Full changelog can be found in Releases.

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

newversion-3.0.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

newversion-3.0.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file newversion-3.0.0.tar.gz.

File metadata

  • Download URL: newversion-3.0.0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.30

File hashes

Hashes for newversion-3.0.0.tar.gz
Algorithm Hash digest
SHA256 a50cd0d63e413b9952b86c39abb28a1e2fc98d75ff9367f81b8800d0fbee117f
MD5 84ed17a35eed024686f0e5f38b771e26
BLAKE2b-256 8e6f6fb104afd7794dde04d9f81d99df42e8fb7e593f55ca72fa7f03c15a0c34

See more details on using hashes here.

File details

Details for the file newversion-3.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for newversion-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28749031e18664e439b5b5394989e75ca9503a20992c2fb268309beec0195290
MD5 505ba735320e277263c20a5e85a676ff
BLAKE2b-256 1ba24cf715a07ae933127eb76e353ca97a98416492c3c9f2230590d697ab4a5e

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