Registry / serialization / verlib2

verlib2

JSON →
library0.3.2pypypi✓ verified 86d ago

verlib2 is a Python library that provides a standalone bundle of version parsing implementations, specifically `distutils.version` (PEP 386) and `packaging.version` (PEP 440). Its primary purpose is to offer these functionalities without requiring the `packaging` library as a dependency, and to provide a solution for projects that relied on `distutils.version` after `distutils` was removed from the Python standard library in Python 3.12. It is actively maintained with a steady release cadence.

pip install verlib2
INSTALL
IMPORT
SIG · VERLIB2
V
verlib2
serializationpythonv0.3.2
Install
1.7s avg
Import
117ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.123s · 17.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.7s · import 0.111s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Version
from verlib2 import Version
from packaging.version import Version
The primary `Version` class in `verlib2` is the PEP 440 implementation, mirroring `packaging.version.Version` to avoid the `packaging` dependency.
LooseVersion
from verlib2.distutils.version import LooseVersion
from distutils.version import LooseVersion
`distutils.version` was removed in Python 3.12. `verlib2` bundles its functionality to ensure compatibility.
StrictVersion
from verlib2.distutils.version import StrictVersion
from distutils.version import StrictVersion
`distutils.version` was removed in Python 3.12. `verlib2` bundles its functionality to ensure compatibility.

This quickstart demonstrates how to import and use both the PEP 440-compliant `Version` class and the PEP 386-compliant `LooseVersion` and `StrictVersion` classes for version comparison and parsing. It highlights the differences in parsing rules between the two standards, particularly regarding development suffixes and strictness.

from verlib2 import Version from verlib2.distutils.version import LooseVersion, StrictVersion # Using PEP 440 (packaging.version) style v1 = Version("1.0.dev456") v2 = Version("1!1.2.rev33+123456") assert v1 < v2 assert Version("1.0") == Version("1.0.0") # Using PEP 386 (distutils.version) style lv1 = LooseVersion("1.2.3b1") lv2 = LooseVersion("1.2.3") assert lv1 < lv2 assert LooseVersion("1.0") != LooseVersion("1.0.0") # Different behavior than PEP 440 try: sv = StrictVersion("1.2.3.4") # StrictVersion does not allow arbitrary suffixes except ValueError as e: print(f"StrictVersion error: {e}")
Debug
Known issues
breakingDirect imports from `distutils.version` will fail in Python 3.12 and later, as `distutils` was removed from the standard library.
fix
Migrate `from distutils.version import LooseVersion` to `from verlib2.distutils.version import LooseVersion` (and similarly for `StrictVersion`).
affects: Python >=3.12
gotchaThe default `verlib2.Version` class implements PEP 440, which has different parsing and comparison rules than PEP 386 (implemented by `LooseVersion` and `StrictVersion`). For instance, PEP 440 treats `1.0` and `1.0.0` as equal, while PEP 386's `LooseVersion` considers them different.
fix
Carefully choose the appropriate version class (`Version` for PEP 440, `LooseVersion` or `StrictVersion` for PEP 386) based on the specific versioning standard your project requires.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'distutils.version'
Attempting to import `distutils.version` in Python 3.12 or newer where `distutils` has been removed from the standard library.
fix
Replace `from distutils.version import ...` with `from verlib2.distutils.version import ...`.
TypeError: '<' not supported between instances of 'Version' and 'str'
Attempting to compare a `verlib2.Version` object directly with a string. Version objects must be compared with other Version objects.
fix
Ensure all values being compared are instances of `verlib2.Version` (or `LooseVersion`/`StrictVersion`). For example, `Version('1.0') < Version('2.0')`.
Upgrade
Version history
0.3.2latest on PyPI · released Mar 31, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
21
Amazon
1
OpenAI (training)
1
Resources
verlib2 — pip install verlib2 · libregistry