parver: Parse and Manipulate Version Numbers

0.5 · active · verified Thu Apr 09

parver is a Python package designed for robust parsing and manipulation of PEP 440 compliant version numbers. It provides a `Version` class to represent versions and methods for common operations like bumping development or release segments, checking pre-release status, and normalization. The library is currently at version 0.5 and maintains a stable, active development status.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to parse a version string into a `Version` object, access its components, and perform common manipulations such as bumping development or release segments, and normalizing the version format.

from parver import Version

# Parse a version string
v = Version.parse('1.3.0.dev1')
print(f"Original version: {v}")

# Access parts of the version
print(f"Major: {v.major}, Minor: {v.minor}, Patch: {v.patch}")
print(f"Is pre-release: {v.is_prerelease}")
print(f"Development part: {v.dev}")

# Bump the development version
v_dev = v.bump_dev()
print(f"Bumped dev version: {v_dev}")

# Bump a release segment (e.g., patch, which is index 2)
v_patch = Version.parse('1.2.3').bump_release(index=2)
print(f"Bumped patch version: {v_patch}")

# Normalize a version
v_norm = Version.parse('v1.2.alpha-3').normalize()
print(f"Normalized version: {v_norm}")

view raw JSON →