Flexible Version Handling
verspec is a Python library for handling software versions and specifiers, adapted from the `packaging` package. It provides a flexible API for parsing, comparing, and working with version strings, supporting both 'loose' and 'Python' (PEP 440) version schemes. The current version is 0.1.0, released in November 2020. As an initial release, its release cadence is not yet established.
Warnings
- gotcha The library is explicitly marked as 'Alpha' (Development Status: 3 - Alpha on PyPI) and its documentation is currently 'Forthcoming!'. This indicates that the API surface might be unstable, and future releases (even minor ones) may introduce breaking changes or significant behavioral differences without explicit deprecation warnings.
- gotcha The library provides two distinct version schemes: `verspec.loose` (for a more liberal interpretation of versions) and `verspec.python` (for PEP 440 compliant versioning). Mixing these types or using `loose` where strict PEP 440 compliance is required (e.g., for package dependency resolution) can lead to unexpected or incorrect comparison results.
Install
-
pip install verspec
Imports
- loose.Version
from verspec import loose
- python.Version
from verspec import python
- loose.SpecifierSet
from verspec import loose
- python.SpecifierSet
from verspec import python
Quickstart
from verspec import loose, python
# Using the 'loose' version scheme
v_loose = loose.Version('1.0')
s_loose = loose.SpecifierSet('~=1.0')
assert v_loose in s_loose
print(f"Loose Version '{v_loose}' is in specifier '{s_loose}': {v_loose in s_loose}")
# Using the 'python' (PEP 440) version scheme
v_python = python.Version('1.0')
s_python = python.SpecifierSet('~=1.0')
assert v_python in s_python
print(f"Python Version '{v_python}' is in specifier '{s_python}': {v_python in s_python}")