distlib

Low-level Python library implementing packaging standards for building interoperable tools.

Library
PyPI
v0.4.3
65stars
Python-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
65/100Good
Development Activity64
Maintenance68
Community52
Maturity56
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture83
Code Quality84
Innovation75
Learning Curve70

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.

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