I'm currently using code similar to this
# Returns PKG-INFO in "email format", meaning it looks a little like this:
# Name: some_python_module
# Version: 1.2.3
dist = pkg_resources.get_distribution('some_python_module')
pkginfo = dist.get_metadata(dist.PKG_INFO)
d = dict(line.split(': ', 1) for line in pkginfo.split('\n') if ': ' in line)
print(d['Name'])
I'm wondering if there is a "clean" way to do this key lookup for a Distribution object?
Note I am using custom properties here so doing dist.project_name
or dist.version
are not enough in my particular case.