{"id":24241,"library":"pkginfo2","title":"pkginfo2","description":"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.","status":"active","version":"30.1.0","language":"python","source_language":"en","source_url":"https://github.com/aboutcode-org/pkginfo2","tags":["metadata","packaging","sdist","bdist","wheel","installed-packages"],"install":[{"cmd":"pip install pkginfo2","lang":"bash","label":"Latest from PyPI"}],"dependencies":[],"imports":[{"note":"Old library is pkginfo, not pkginfo2","wrong":"from pkginfo import get_metadata","symbol":"get_metadata","correct":"from pkginfo2 import get_metadata"},{"note":"No common wrong import known","symbol":"UnpackedSDist","correct":"from pkginfo2 import UnpackedSDist"}],"quickstart":{"code":"from pkginfo2 import get_metadata\n\n# Get metadata from a source distribution\nmetadata = get_metadata('pkginfo2-30.1.0.tar.gz')\nprint(metadata.name, metadata.version)\n\n# Get metadata from an installed package\nfrom pkginfo2.installed import Installed\ninst = Installed('pkginfo2')\nprint(inst.name, inst.version)\n\n# Use environment variable for a file path\nimport os\npath = os.environ.get('PKGINFO2_FILE', 'pkginfo2-30.1.0.tar.gz')\nmetadata = get_metadata(path)\nprint(metadata.name, metadata.version)","lang":"python","description":"Demonstrates reading metadata from a file and installed package."},"warnings":[{"fix":"Replace 'from pkginfo import ...' with 'from pkginfo2 import ...'","message":"pkginfo2 is a separate fork; do not mix imports with the original pkginfo. The API is similar but not identical.","severity":"breaking","affected_versions":"all"},{"fix":"Check for None before accessing attributes:\nmetadata = get_metadata('pkg.whl')\nif metadata is None:\n    raise ValueError('Could not read metadata')","message":"get_metadata() with a .whl file may return None if the wheel is not a valid zip or lacks METADATA file.","severity":"gotcha","affected_versions":">=30.0.0"},{"fix":"Upgrade to Python 3.10 or later.","message":"Python 3.10+ only. Older Python versions are not supported.","severity":"breaking","affected_versions":"30.0.0+"}],"env_vars":null,"search_vec":"'-04':26 '2025':25 '30.1.0':23 'aboutcode.org':29 'arbitrari':17 'avoid':16 'bdist':6,33 'current':21 'eval':20 'fork':12 'import':18 'instal':8,36 'installed-packag':35 'maintain':27 'metadata':3,30 'packag':9,31,37 'pkginfo':14 'pkginfo2':1 'queri':2 'releas':24 'safer':11 'sdist':5,32 'version':22 'wheel':34","created_at":"2026-05-01T08:12:01.905979+00:00","updated_at":"2026-05-01T08:12:01.905979+00:00","problems":[{"fix":"Install pkginfo2: pip install pkginfo2","cause":"Attempting to use old pkginfo package under the name pkginfo2.","error":"ModuleNotFoundError: No module named 'pkginfo'"},{"fix":"Check return value: metadata = get_metadata('file.whl'); if metadata is None: handle error","cause":"get_metadata() returned None for a .whl file without METADATA.","error":"AttributeError: 'NoneType' object has no attribute 'name'"},{"fix":"Upgrade to latest: pip install --upgrade pkginfo2","cause":"Old version of pkginfo2 (<30.0.0) may not include get_metadata.","error":"ImportError: cannot import name 'get_metadata' from 'pkginfo2'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"30.1.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/aboutcode-org/pkginfo2","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pkginfo2/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}