Registry / devops / pkginfo

pkginfo

JSON →
library1.12.1.2pypypi✓ verified 24d ago

pkginfo is a Python library providing an API for querying metadata from Python package distributions. It can extract information from source distributions (sdists), binary distributions (bdists, including wheels), and installed packages by inspecting PKG-INFO, EGG-INFO, or dist-info files/directories. The library is actively maintained, with version 1.12.1.2 released in February 2025, and maintains a consistent release cadence.

pip install pkginfo
INSTALL
IMPORT
SIG · PKGINFO
P
pkginfo
devopspythonv1.12.1.2
Install
1.7s avg
Import
71ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.12.1.2 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.076s · 18.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.066s · 19MB
16MB installed
● package 16MB
Code
Verified usage

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

SDist
from pkginfo import SDist
BDist
from pkginfo import BDist
Wheel
from pkginfo import Wheel
Installed
from pkginfo import Installed
Develop
from pkginfo import Develop

This quickstart demonstrates how to extract metadata from different package distribution types. It shows how to initialize `SDist`, `Wheel`, and `Installed` objects with appropriate paths or package names, and then access common metadata attributes like `name`, `version`, and `metadata_version`.

import os from pkginfo import SDist, Wheel, Installed # Example for a source distribution (sdist) # Assuming 'example_package-1.0.tar.gz' exists in the current directory # For a real-world use, replace with an actual sdist path sdist_path = 'path/to/your/package-1.0.tar.gz' if os.path.exists(sdist_path): sdist_info = SDist(sdist_path) print(f"SDist Name: {sdist_info.name}, Version: {sdist_info.version}, Metadata-Version: {sdist_info.metadata_version}") else: print(f"SDist example skipped: {sdist_path} not found. Please provide a valid sdist file.") # Example for a wheel distribution # Assuming 'example_package-1.0-py3-none-any.whl' exists wheel_path = 'path/to/your/package-1.0-py3-none-any.whl' if os.path.exists(wheel_path): wheel_info = Wheel(wheel_path) print(f"Wheel Name: {wheel_info.name}, Version: {wheel_info.version}, Metadata-Version: {wheel_info.metadata_version}") else: print(f"Wheel example skipped: {wheel_path} not found. Please provide a valid wheel file.") # Example for an installed package (e.g., 'pip') try: installed_info = Installed('pip') print(f"Installed Name: {installed_info.name}, Version: {installed_info.version}, Metadata-Version: {installed_info.metadata_version}") except Exception as e: print(f"Could not get info for 'pip' (maybe not installed or metadata not found): {e}")
Debug
Known issues
breakingOlder versions of `pkginfo` (specifically pre-1.10.0) may not correctly parse or fully support newer PEP metadata versions (e.g., Metadata-Version 2.3 and higher) used by modern Python packages, leading to errors or incomplete information.
fix
Upgrade to `pkginfo` version 1.10.0 or newer: `pip install --upgrade pkginfo`.
affects: <1.10.0
breakingSupport for Python 2.7 was officially dropped in version 1.90. Users on Python 2.7 will encounter compatibility issues.
fix
Migrate your project to Python 3.8 or newer, which is the minimum supported version.
affects: >=1.90
gotchaThe `pkginfo2` fork was created to address concerns regarding the original `pkginfo`'s historical potential for 'arbitrary imports and eval' when parsing package metadata. While `pkginfo` has evolved, users with stringent security requirements or those processing untrusted package metadata should be aware of this historical context and consider their threat model.
fix
Ensure you are using the latest `pkginfo` version. For critical security contexts, carefully audit the package parsing mechanisms or consider sandboxing the operation.
affects: All versions (historical design concern)
gotchaWhen using `pkginfo.Installed` to query an installed package, the package's `.egg-info` or `.dist-info` metadata directory must be discoverable (e.g., located inside the package or adjacent to it). If metadata is not in a standard location, `pkginfo` may fail to find it.
fix
Verify that the target installed package has its metadata (`.egg-info` or `.dist-info`) in a standard, discoverable location relative to the package files.
affects: All versions
gotchaWhen using `pkginfo.SDist` or `pkginfo.Wheel` to process distribution files, the provided path must point to an actual, existing sdist or wheel file respectively. If the file does not exist at the specified path, `pkginfo` will not be able to process it, typically resulting in a `FileNotFoundError` or similar indication of missing input.
fix
Ensure the path provided to `pkginfo.SDist` or `pkginfo.Wheel` is correct and that the target distribution file exists at that location before attempting to parse it.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pkginfo'
The `pkginfo` library is not installed in the Python environment where the code is being executed.
fix
Install the `pkginfo` library using pip: `pip install pkginfo`
KeyError: 'No metadata except PKG-INFO is available'
This error typically occurs when a tool (like pip or setuptools, which may internally use or rely on similar metadata parsing logic as `pkginfo`) attempts to read package metadata, but only finds a basic `PKG-INFO` file without additional expected metadata, or the metadata is malformed/incomplete.
fix
Ensure the package being analyzed has correctly generated metadata files. If you are building a package, verify `setup.py` or `pyproject.toml` correctly defines metadata. If consuming, try updating the package or the tools used for installation/inspection (e.g., `pip install --upgrade setuptools pip`).
pkginfo: ERROR: pkginfo file is corrupt or missing.
The `pkginfo` library or a related utility failed to locate or parse the `PKG-INFO` file within a distribution, indicating the file is either absent, unreadable, or contains syntax errors.
fix
Verify the integrity and presence of the `PKG-INFO` file within the distribution. This might involve inspecting the `.egg-info` or `.dist-info` directory, or the contents of an sdist/wheel archive. If you created the package, ensure your build process correctly generates this file.
Upgrade
Version history
1.12.1.2latest on PyPI · released Feb 19, 2025
Audit
Dependencies
packagingoptionalImplicitly used or relied upon for modern package metadata specification handling, especially for metadata versions 2.1+.
Agent activity
9 hits · last 30 days
node
8
Resources
pkginfo — pip install pkginfo · libregistry