packvers

raw JSON →
21.5 verified Fri May 01 auth: no python

Core utilities for Python package versioning. A fork of `packaging` version 21.3 that reintroduces `LegacyVersion` and supports PEP 440 / legacy comparison. Latest version 21.5, requires Python >=3.6.

pip install packvers
error from packvers.version import LegacyVersion ImportError: cannot import name 'LegacyVersion' from 'packvers.version'
cause You may have an older version of `packvers` that doesn't include `LegacyVersion`, or you accidentally installed `packaging` instead.
fix
Upgrade to packvers>=21.5 with pip install --upgrade packvers and ensure packaging is not installed.
error from packaging.version import LegacyVersion ImportError: cannot import name 'LegacyVersion' from 'packaging.version'
cause `LegacyVersion` was removed from `packaging` in version 21.0.
fix
Use packvers.version.LegacyVersion instead, or downgrade packaging to 20.9.
error AttributeError: module 'packaging' has no attribute 'version'
cause You may have accidentally installed `packver` (wrong name) or the import path is incorrect.
fix
Uninstall conflicting packages and install packvers via pip install packvers.
gotcha `packvers.version.LegacyVersion` is available in this fork but not in `packaging>=21.3`. If you accidentally import from `packaging` expecting `LegacyVersion`, you'll get an `ImportError`.
fix Use `from packvers.version import LegacyVersion` for legacy version support.
deprecated `packvers` is a fork of an older version of `packaging`. It may not receive updates aligning with newer PEP standards. Consider using `packaging` directly unless you specifically need `LegacyVersion`.
fix If you don't need legacy version support, switch to `packaging`.
gotcha Installing both `packaging` and `packvers` can cause dependency conflicts or namespace shadows if used together. Ensure only one is installed.
fix Use a virtual environment and install only the required library.

Basic usage: parse and compare versions, including legacy format.

from packvers.version import Version, LegacyVersion
from packvers.specifiers import SpecifierSet

v = Version('1.2.3')
print(v)  # 1.2.3
print(SpecifierSet('>=1.0').contains(v))  # True

# Legacy version support
lv = LegacyVersion('1.2.3a')
print(lv)  # 1.2.3a