{"id":7848,"library":"verlib2","title":"verlib2","description":"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.","status":"active","version":"0.3.2","language":"python","source_language":"en","source_url":"https://github.com/pyveci/verlib2","tags":["versioning","PEP 386","PEP 440","distutils","packaging"],"install":[{"cmd":"pip install verlib2","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary `Version` class in `verlib2` is the PEP 440 implementation, mirroring `packaging.version.Version` to avoid the `packaging` dependency.","wrong":"from packaging.version import Version","symbol":"Version","correct":"from verlib2 import Version"},{"note":"`distutils.version` was removed in Python 3.12. `verlib2` bundles its functionality to ensure compatibility.","wrong":"from distutils.version import LooseVersion","symbol":"LooseVersion","correct":"from verlib2.distutils.version import LooseVersion"},{"note":"`distutils.version` was removed in Python 3.12. `verlib2` bundles its functionality to ensure compatibility.","wrong":"from distutils.version import StrictVersion","symbol":"StrictVersion","correct":"from verlib2.distutils.version import StrictVersion"}],"quickstart":{"code":"from verlib2 import Version\nfrom verlib2.distutils.version import LooseVersion, StrictVersion\n\n# Using PEP 440 (packaging.version) style\nv1 = Version(\"1.0.dev456\")\nv2 = Version(\"1!1.2.rev33+123456\")\n\nassert v1 < v2\nassert Version(\"1.0\") == Version(\"1.0.0\")\n\n# Using PEP 386 (distutils.version) style\nlv1 = LooseVersion(\"1.2.3b1\")\nlv2 = LooseVersion(\"1.2.3\")\n\nassert lv1 < lv2\nassert LooseVersion(\"1.0\") != LooseVersion(\"1.0.0\") # Different behavior than PEP 440\n\ntry:\n    sv = StrictVersion(\"1.2.3.4\") # StrictVersion does not allow arbitrary suffixes\nexcept ValueError as e:\n    print(f\"StrictVersion error: {e}\")","lang":"python","description":"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."},"warnings":[{"fix":"Migrate `from distutils.version import LooseVersion` to `from verlib2.distutils.version import LooseVersion` (and similarly for `StrictVersion`).","message":"Direct imports from `distutils.version` will fail in Python 3.12 and later, as `distutils` was removed from the standard library.","severity":"breaking","affected_versions":"Python >=3.12"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'3.12':62 '386':19,74 '440':23,76 'activ':65 'bundl':11 'cadenc':71 'depend':39 'distutil':52,77 'distutils.version':17,50 'function':31 'implement':15 'librari':6,36,59 'maintain':66 'offer':29 'packag':35,78 'packaging.version':21 'pars':14 'pep':18,22,73,75 'primari':25 'project':46 'provid':8,42 'purpos':26 'python':5,57,61 'releas':70 'reli':48 'remov':54 'requir':33 'solut':44 'specif':16 'standalon':10 'standard':58 'steadi':69 'verlib2':1,2 'version':13,72 'without':32","created_at":"2026-04-16T14:15:59.704714+00:00","updated_at":"2026-04-16T14:15:59.704714+00:00","problems":[{"fix":"Replace `from distutils.version import ...` with `from verlib2.distutils.version import ...`.","cause":"Attempting to import `distutils.version` in Python 3.12 or newer where `distutils` has been removed from the standard library.","error":"ModuleNotFoundError: No module named 'distutils.version'"},{"fix":"Ensure all values being compared are instances of `verlib2.Version` (or `LooseVersion`/`StrictVersion`). For example, `Version('1.0') < Version('2.0')`.","cause":"Attempting to compare a `verlib2.Version` object directly with a string. Version objects must be compared with other Version objects.","error":"TypeError: '<' not supported between instances of 'Version' and 'str'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.3.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/pyveci/verlib2","docs":null,"changelog":null,"pypi":"https://pypi.org/project/verlib2/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}