pkg-about library
pkg-about provides unified access to Python package metadata at runtime. It's designed to fetch information like version, summary, author, and license for installed packages, abstracting away differences between `pkg_resources` and `importlib.metadata`. The current version is 2.3.0, and it generally follows a release cadence driven by new features or bug fixes, typically every few months.
Common errors
-
pkg_about.exceptions.PackageNotFoundError: No package found with name 'my-non-existent-lib'
cause The specified package name does not correspond to an installed Python package on the system, or there's a typo in the name.fixDouble-check the package name's spelling. Ensure the package is actually installed in the environment where the code is running by using `pip list`. -
AttributeError: 'About' object has no attribute 'version'
cause This error often indicates that you are trying to access an attribute that doesn't exist on the `About` object, or you are using an older pattern for `pkg-about` (e.g., from v1.x.x) that is incompatible with v2.x.x, or the underlying metadata is missing that specific field.fixEnsure you are using `get_about()` (for v2.x.x) and accessing standard attributes like `.name`, `.version`, `.summary`, etc. Consult the `About` object's available attributes (e.g., by `dir(about_obj)` or documentation) if you're looking for less common fields.
Warnings
- breaking Major refactor in version 2.0.0 changed the primary entry point for accessing package metadata. Direct instantiation or attribute access patterns from v1.x.x versions are no longer valid.
- gotcha The library explicitly requires Python >=3.10.0 and <4.0.0. Attempting to use it on older Python versions (e.g., 3.9 or earlier) will result in installation failure or runtime errors.
- gotcha Attempts to retrieve metadata for a non-existent or misspelled package name will raise a `PackageNotFoundError`. This can happen even if the package is installed but has a different internal name than assumed.
Install
-
pip install pkg-about
Imports
- get_about
from pkg_about.about import About
from pkg_about import get_about
Quickstart
from pkg_about import get_about
# Get metadata for pkg-about itself
about_pkg = get_about('pkg-about')
print(f"Package Name: {about_pkg.name}")
print(f"Version: {about_pkg.version}")
print(f"Summary: {about_pkg.summary}")
print(f"Author: {about_pkg.author}")
print(f"License: {about_pkg.license}")