{"id":554,"library":"pkginfo","title":"pkginfo","description":"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.","status":"active","version":"1.12.1.2","language":"python","source_language":"en","source_url":"https://github.com/pypa/pkginfo","tags":["package management","metadata","sdist","bdist","wheel","distribution","packaging"],"install":[{"cmd":"pip install pkginfo","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Implicitly used or relied upon for modern package metadata specification handling, especially for metadata versions 2.1+.","package":"packaging","optional":true}],"imports":[{"symbol":"SDist","correct":"from pkginfo import SDist"},{"symbol":"BDist","correct":"from pkginfo import BDist"},{"symbol":"Wheel","correct":"from pkginfo import Wheel"},{"symbol":"Installed","correct":"from pkginfo import Installed"},{"symbol":"Develop","correct":"from pkginfo import Develop"}],"quickstart":{"code":"import os\nfrom pkginfo import SDist, Wheel, Installed\n\n# Example for a source distribution (sdist)\n# Assuming 'example_package-1.0.tar.gz' exists in the current directory\n# For a real-world use, replace with an actual sdist path\nsdist_path = 'path/to/your/package-1.0.tar.gz'\nif os.path.exists(sdist_path):\n    sdist_info = SDist(sdist_path)\n    print(f\"SDist Name: {sdist_info.name}, Version: {sdist_info.version}, Metadata-Version: {sdist_info.metadata_version}\")\nelse:\n    print(f\"SDist example skipped: {sdist_path} not found. Please provide a valid sdist file.\")\n\n# Example for a wheel distribution\n# Assuming 'example_package-1.0-py3-none-any.whl' exists\nwheel_path = 'path/to/your/package-1.0-py3-none-any.whl'\nif os.path.exists(wheel_path):\n    wheel_info = Wheel(wheel_path)\n    print(f\"Wheel Name: {wheel_info.name}, Version: {wheel_info.version}, Metadata-Version: {wheel_info.metadata_version}\")\nelse:\n    print(f\"Wheel example skipped: {wheel_path} not found. Please provide a valid wheel file.\")\n\n# Example for an installed package (e.g., 'pip')\ntry:\n    installed_info = Installed('pip')\n    print(f\"Installed Name: {installed_info.name}, Version: {installed_info.version}, Metadata-Version: {installed_info.metadata_version}\")\nexcept Exception as e:\n    print(f\"Could not get info for 'pip' (maybe not installed or metadata not found): {e}\")","lang":"python","description":"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`."},"warnings":[{"fix":"Upgrade to `pkginfo` version 1.10.0 or newer: `pip install --upgrade pkginfo`.","message":"Older 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.","severity":"breaking","affected_versions":"<1.10.0"},{"fix":"Migrate your project to Python 3.8 or newer, which is the minimum supported version.","message":"Support for Python 2.7 was officially dropped in version 1.90. Users on Python 2.7 will encounter compatibility issues.","severity":"breaking","affected_versions":">=1.90"},{"fix":"Ensure you are using the latest `pkginfo` version. For critical security contexts, carefully audit the package parsing mechanisms or consider sandboxing the operation.","message":"The `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.","severity":"gotcha","affected_versions":"All versions (historical design concern)"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T15:03:51.153Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Install the `pkginfo` library using pip: `pip install pkginfo`","cause":"The `pkginfo` library is not installed in the Python environment where the code is being executed.","error":"ModuleNotFoundError: No module named 'pkginfo'"},{"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`).","cause":"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.","error":"KeyError: 'No metadata except PKG-INFO is available'"},{"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.","cause":"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.","error":"pkginfo: ERROR: pkginfo file is corrupt or missing."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":3.2,"disk_size":"18.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":3.2,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":3.4,"disk_size":"20.0M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.15,"mem_mb":3.4,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":3.3,"disk_size":"11.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.09,"mem_mb":3.3,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":2.8,"disk_size":"11.5M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2.6,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":3.3,"disk_size":"17.6M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.11,"mem_mb":3.3,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}