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
- Parameters
version_str – The input string to extract from
- Returns
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
- Parameters
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.
- Returns
The original string with the version number incremented