Registry / serialization / dist-meta

dist-meta

JSON →
library0.9.0pypypi✓ verified 86d ago

dist-meta is a Python library (current version 0.9.0) designed to parse and create Python distribution metadata, primarily interacting with `dist-info/METADATA` files. It provides tools for reading distribution information, entry points, and `RECORD` files. Releases are made irregularly as features are added or issues resolved.

pip install dist-meta
INSTALL
IMPORT
SIG · DIST-META
D
dist-meta
serializationpythonv0.9.0
Install
1.9s avg
Import
178ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.0 · 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.103.920 runs
installs and imports cleanly · install 0.0s · import 0.188s · 20MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.9s · import 0.168s · 21MB
18MB installed
● package 18MB
Code
Verified usage

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

loads
from dist_meta.metadata import loads
get_distribution
from dist_meta.distributions import get_distribution
EntryPoint
from dist_meta.entry_points import EntryPoint

This quickstart demonstrates how to parse a Python distribution's metadata string using `dist_meta.metadata.loads`. This is useful for programmatically inspecting package information.

from dist_meta.metadata import loads metadata_content = '''\ Metadata-Version: 2.1 Name: my-example-package Version: 1.2.3 Summary: A simple example Python package. Author: Example Developer Author-Email: dev@example.com Requires-Python: >=3.6.1 ''') parsed_metadata = loads(metadata_content) print(f"Package Name: {parsed_metadata['Name']}") print(f"Package Version: {parsed_metadata['Version']}") print(f"Requires Python: {parsed_metadata['Requires-Python']}")
Debug
Known issues
gotchaWhen parsing metadata, ensure the input string or file adheres to the Python Core Metadata Specifications (e.g., PEP 643 for Metadata-Version 2.2+ or earlier PEPs). Incorrectly formatted or incomplete metadata may lead to parsing errors or missing fields.
fix
Refer to the official Python packaging specifications for the metadata version you are working with. Validate metadata structure and required fields before parsing.
affects: All versions
gotchaThe `loads()` function is for parsing a string, while `load()` is for parsing a file-like object. Using a file path directly with `loads()` or string content with `load()` will result in `TypeError` or `AttributeError`.
fix
For string content, use `dist_meta.metadata.loads()`. For file paths or file objects, open the file and pass the content to `loads()` or the file object to `load()` respectively.
affects: All versions
Errors
Common errors & fixes
dist_meta.metadata.MissingFieldError: 'Name'
The input metadata string or file is missing a required field, such as 'Name' or 'Version', which are mandatory in Python distribution metadata.
fix
Ensure all mandatory fields (e.g., `Metadata-Version`, `Name`, `Version`) are present and correctly formatted in the metadata string or file being parsed.
AttributeError: 'str' object has no attribute 'read'
Attempted to pass a string containing metadata directly to `dist_meta.metadata.load()`, which expects a file-like object with a `read()` method.
fix
Use `from dist_meta.metadata import loads` and pass the metadata as a string to the `loads()` function. Alternatively, if you intend to read from a file, open the file and pass the file object to `load()`.
Upgrade
Version history
0.9.0latest on PyPI · released Feb 12, 2025
Audit
Dependencies
domdf-python-toolsrequiredUtility library required for core functionality.
handy-archivesrequiredArchival utilities for distribution processing.
Agent activity
8 hits · last 30 days
node
8
Resources
dist-meta — pip install dist-meta · libregistry