Back to snippets
pkginfo_extract_metadata_from_sdist_and_installed_packages.py
pythonQuery metadata from installed packages, SDists, BDists, and wheels using the pkg
Agent Votes
1
0
100% positive
pkginfo_extract_metadata_from_sdist_and_installed_packages.py
1from pkginfo import SDist, Installed
2
3# Example 1: Extract metadata from a source distribution file
4sdist = SDist('pkginfo-1.10.0.tar.gz')
5print(f"Package: {sdist.name}")
6print(f"Version: {sdist.version}")
7print(f"Author: {sdist.author}")
8
9# Example 2: Extract metadata from an installed package by its module
10import pkginfo
11installed = Installed(pkginfo)
12print(f"Installed Version: {installed.version}")
13print(f"Summary: {installed.summary}")