Registry / serialization / packaging-legacy

packaging-legacy

JSON →
library23.0.post0pypypi✓ verified 93d ago

Packaging-legacy is a Python library, currently at version 23.0.post0, that provides support for 'legacy' Python packaging functionality. It restores features, primarily related to version parsing, that were removed from the official `packaging` library. Its main utility is the `packaging_legacy.version.parse` function, which can handle version strings that the modern `packaging` library would deem invalid. The library has an infrequent release cadence, with only two releases to date, both in late 2023.

pip install packaging-legacy
INSTALL
IMPORT
SIG · PACKAGING-LEGACY
P
packaging-legacy
serializationpythonv23.0.post0
Install
1.7s avg
Import
25ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v23.0.post0 · 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.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.026s · 18.6MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 1.7s · import 0.025s · 19MB
17MB installed
● package 17MB
Code
Verified usage

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

parse
✓ from packaging_legacy.version import parse
✗ from packaging.version import parse
Use 'packaging_legacy' for parsing older, non-PEP 440 compliant version strings that the modern 'packaging' library rejects. The original 'packaging.version.parse' no longer returns 'LegacyVersion' for invalid inputs.
LegacyVersion
✓ from packaging_legacy.version import LegacyVersion
✗ from packaging.version import LegacyVersion
'LegacyVersion' was removed from the 'packaging' library in version 22.0. This import is specifically for interacting with that legacy type.

This quickstart demonstrates how to parse a 'legacy' version string using `packaging_legacy.version.parse`. It highlights that such a version will be represented by a `LegacyVersion` object, which is distinct from the standard `Version` object used for PEP 440 compliant versions. The example also implicitly contrasts this behavior with the modern `packaging` library, which would raise an `InvalidVersion` error for such a string.

from packaging_legacy.version import parse, LegacyVersion # Example of parsing a legacy version string legacy_version_string = "1.0.0.alpha0" version = parse(legacy_version_string) print(f"Parsed version: {version}") print(f"Is it a LegacyVersion? {isinstance(version, LegacyVersion)}") # Compare with a standard version standard_version = parse("1.0.0a0") print(f"Comparing {version} and {standard_version}: {version == standard_version}") # The modern 'packaging' library would raise InvalidVersion for '1.0.0.alpha0' # To demonstrate, one would typically use a try-except block here # import packaging.version # try: # packaging.version.parse("1.0.0.alpha0") # except packaging.version.InvalidVersion as e: # print(f"Modern packaging error: {e}")
Debug
Known issues
breakingThe original 'packaging' library (pypa/packaging) removed support for 'LegacyVersion' and modified 'packaging.version.parse' to raise 'InvalidVersion' for non-PEP 440 compliant strings. This library, 'packaging-legacy', was created to provide a compatible API for those still needing to parse such versions.
fix
If you rely on parsing non-PEP 440 compliant version strings (e.g., '1.0.0.alpha0') and expect a 'LegacyVersion' object, switch your imports from 'packaging' to 'packaging_legacy' for version parsing. Keep 'packaging' for modern version handling.
affects: packaging>=22.0
gotchaConfusion between 'packaging' and 'packaging-legacy' is common. Using 'from packaging.version import parse' will *not* yield a 'LegacyVersion' object for non-standard versions; it will raise an error.
fix
Always use `from packaging_legacy.version import parse` when you specifically need to handle legacy version formats. For all other standard version parsing, continue to use `from packaging.version import parse` from the main `packaging` library.
affects: All versions of packaging>=22.0 and packaging-legacy
Errors
Common errors & fixes
packaging.version.InvalidVersion: Invalid version: '1.0.0.alpha0'
You are attempting to parse a non-PEP 440 compliant version string using the modern `packaging` library (version 22.0 or higher), which no longer supports 'LegacyVersion' fallback.
fix
If this is an intentional legacy version string, use `from packaging_legacy.version import parse` instead: `from packaging_legacy.version import parse; version = parse('1.0.0.alpha0')`.
ModuleNotFoundError: No module named 'packaging.version.LegacyVersion'
The `LegacyVersion` class was removed from the `packaging` library in version 22.0. Your code is trying to import it from the main `packaging` package.
fix
To access `LegacyVersion`, import it from `packaging_legacy`: `from packaging_legacy.version import LegacyVersion`.
Upgrade
Version history
23.0.post0latest on PyPI · released Nov 28, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Resources
packaging-legacy — pip install packaging-legacy · libregistry