Registry / data / pkginfo2

pkginfo2

JSON →
library30.1.0pypypi✓ verified 90d ago

Query metadata from sdists, bdists, and installed packages. A safer fork of pkginfo that avoids arbitrary imports and eval. Current version 30.1.0, released 2025-04. Maintained by AboutCode.org.

pip install pkginfo2
INSTALL
IMPORT
SIG · PKGINFO2
P
pkginfo2
datapythonv30.1.0
Install
1.6s avg
Import
71ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v30.1.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.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.074s · 17.9MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.068s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

get_metadata
✓ from pkginfo2 import get_metadata
✗ from pkginfo import get_metadata
Old library is pkginfo, not pkginfo2
UnpackedSDist
✓ from pkginfo2 import UnpackedSDist
No common wrong import known

Demonstrates reading metadata from a file and installed package.

from pkginfo2 import get_metadata # Get metadata from a source distribution metadata = get_metadata('pkginfo2-30.1.0.tar.gz') print(metadata.name, metadata.version) # Get metadata from an installed package from pkginfo2.installed import Installed inst = Installed('pkginfo2') print(inst.name, inst.version) # Use environment variable for a file path import os path = os.environ.get('PKGINFO2_FILE', 'pkginfo2-30.1.0.tar.gz') metadata = get_metadata(path) print(metadata.name, metadata.version)
Debug
Known issues
breakingpkginfo2 is a separate fork; do not mix imports with the original pkginfo. The API is similar but not identical.
fix
Replace 'from pkginfo import ...' with 'from pkginfo2 import ...'
affects: all
gotchaget_metadata() with a .whl file may return None if the wheel is not a valid zip or lacks METADATA file.
fix
Check for None before accessing attributes:
metadata = get_metadata('pkg.whl')
if metadata is None:
    raise ValueError('Could not read metadata')
affects: >=30.0.0
breakingPython 3.10+ only. Older Python versions are not supported.
fix
Upgrade to Python 3.10 or later.
affects: 30.0.0+
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pkginfo'
Attempting to use old pkginfo package under the name pkginfo2.
fix
Install pkginfo2: pip install pkginfo2
AttributeError: 'NoneType' object has no attribute 'name'
get_metadata() returned None for a .whl file without METADATA.
fix
Check return value: metadata = get_metadata('file.whl'); if metadata is None: handle error
ImportError: cannot import name 'get_metadata' from 'pkginfo2'
Old version of pkginfo2 (<30.0.0) may not include get_metadata.
fix
Upgrade to latest: pip install --upgrade pkginfo2
Upgrade
Version history
30.1.0latest on PyPI · released Oct 27, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
pkginfo2 — pip install pkginfo2 · libregistry