packaging-legacy

Support for legacy Python packaging APIs removed from packaging.

Library
PyPI
v23.0.post0
4stars
Apache-2.0 OR BSD-2-Clause

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
20/100Needs Attention
Development Activity0
Maintenance20
Community8
Maturity52
Momentum0

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture74
Code Quality80
Innovation65
Learning Curve88

packaging-legacy is a small Python library that preserves “legacy” packaging functionality that has been deprecated and removed from the upstream pypa/packaging library. Its centerpiece is LegacyVersion and a version.parse function that can handle version strings which are not valid PEP 440 versions.

When pypa/packaging removed LegacyVersion, tools that still needed to parse and compare old, non-conformant version strings lost that capability. packaging-legacy fills the gap with a drop-in replacement — you simply import parse and LegacyVersion from packaging_legacy.version instead — so package indexes, mirrors, and analysis tools can keep working with historical releases.

What You Get

  • A LegacyVersion class compatible with packaging’s version object model
  • A parse function that returns a Version for PEP 440 strings or a LegacyVersion otherwise
  • A drop-in import path to replace the removed packaging.version.LegacyVersion
  • Full type annotations with a py.typed marker

Common Use Cases

  • Parsing and comparing historical, non-PEP 440 package version strings
  • Maintaining package index or mirror tooling that must handle legacy releases
  • Migrating code that depended on packaging.version.LegacyVersion after its removal

Under The Hood

Architecture - The whole library is a single module, packaging_legacy/version.py. It imports the current packaging.version internals (_BaseVersion, InvalidVersion, and the standard parse) and defines a parse wrapper that delegates to the PEP 440 parser, catching InvalidVersion to construct a LegacyVersion instead. LegacyVersion subclasses _BaseVersion and builds a comparison key via a _legacy_cmpkey routine so legacy versions remain orderable.

Tech Stack - Pure Python built with a modern pyproject.toml. Its only real dependency is the upstream packaging library, whose base classes it extends. nox is used for task automation.

Code Quality - The code is fully typed with a py.typed marker and kept intentionally minimal. A tests/ directory exercises the parsing and comparison behavior, mirroring the semantics of the code that was removed upstream to ensure faithful compatibility.

API Design - The API is a deliberate one-to-one mirror of the removed upstream surface: the same parse and LegacyVersion names in a version module, so adoption is a single import-path change. This makes the learning curve near-zero for anyone who used the original packaging.version APIs.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search