distlib
Low-level Python library implementing packaging standards for building interoperable tools.
Repository Health
Technical Analysis
Distlib is a low-level library, maintained by the Python Packaging Authority (PyPA), that implements many of the packaging and distribution standards defined in Python PEPs. It provides the building blocks — distribution metadata, version specifiers, wheel handling, dependency graphs, index interaction, and script installation — that third-party packaging tools can reuse to achieve interoperability.
Rather than being a user-facing installer, distlib is designed to be embedded in other tools. It powers packaging infrastructure across the ecosystem (for example, pip vendors distlib for its script-launcher generation), and offers well-tested implementations of standards like PEP 440 versions, PEP 508 markers, PEP 427 wheels, and PEP 376 installed-distribution databases.
What You Get
- PEP 440 version specifiers plus legacy and semantic version support
- PEP 508 environment marker evaluation
- Wheel building and installation (PEP 427) via distlib.wheel
- Distribution metadata handling across multiple metadata PEPs
- Locators for finding distributions on PyPI, directories, and other sources
- Native Windows executable launchers for installed scripts
Common Use Cases
- Building a custom package installer or resolver on top of standard metadata
- Parsing and comparing Python version specifiers in tooling
- Generating cross-platform script wrappers, including Windows launchers
- Reading wheel contents and installed-distribution databases programmatically
Under The Hood
Architecture - Distlib is organized as a set of focused submodules under distlib/, each mapping to a packaging concern: database.py (PEP 376 installed distributions and dependency graphs), metadata.py (metadata PEPs), version.py (PEP 440 and legacy/semantic versions), markers.py (PEP 508), wheel.py (PEP 427 wheels), locators.py (distribution discovery), scripts.py (script installation with shebang rewriting), resources.py, and util.py. Bundled prebuilt launcher executables (t32/t64/w32/w64) provide native Windows script wrappers.
Tech Stack - Predominantly pure Python (~97%) with a small amount of C for the Windows launcher executables. It has no required third-party runtime dependencies, is built with a standard pyproject.toml, and is tested across many Python versions using tox.
Code Quality - The project is mature and heavily tested, with a large tests/ suite exercising wheels, versions, metadata, locators, and edge-case archives (including deliberately malformed inputs). Modules are cohesive and the codebase has evolved conservatively to preserve backward compatibility for the tools that depend on it.
API Design - The API is class-and-function oriented per submodule (e.g. Wheel, DistributionPath, NormalizedVersion, Locator), giving tool authors direct, composable access to individual packaging primitives. It is intentionally low-level rather than opinionated, trading beginner ergonomics for precise, standards-faithful control.
Used by 2 apps in this directory
OSV.dev
Security
Google's open-source vulnerability database that maps CVEs to exact package versions across 50+ ecosystems with a public API and data dumps.
Quickwit
Search · Monitoring
Cloud-native search engine for logs and traces, delivering sub-second search directly on S3, GCS, or Azure Blob storage at a fraction of Elasticsearch's cost.