version Module

Various helper functions for analyzing and manipulating PEP 440 version numbers, meant to augment the packaging.version module.

extract_version(version_str: str)Tuple[Optional[packaging.version.Version], int, int]

Extracts a PEP 440 version object from a string which may have other text


version_str – The input string to extract from


A tuple of (version, start, end), where start and end are the span of the version in the original string

increment_version(version_str: str, rel_seg: Optional[int] = None, pre_seg: Optional[str] = None)str

Increment the PEP 440 version number in a string

  • version_str – The input string to manipulate

  • rel_seg – Which segment of the “release” value to increment, if any

  • pre_seg – Which kind of prerelease to use, if any. An empty string clears the prerelease field.


The original string with the version number incremented

join_version(epoch, release, pre, post, dev, local)str

Join multiple segments of a PEP 440 version

is_release(version_str: str)bool

Check if a version string is a release version


version_str – the input string to check


True if the input contains a released PEP 440 version, or False if a prerelease version or no version is found