If I have built a python package employing distutils.core
, e.g. via
setup(
ext_package="foo",
author="me",
version="1.0",
description="foo package",
packages=["foo",],
)
where does all the metadata go (what is it intended for?) and how can I access it from within python. Specifically, how can I access the author information from the python console after doing something like
>>> import foo
One way to access the metadata is to use pip:
import pip
package = [pckg for pckg in pip.get_installed_distributions()
if pckg.project_name == 'package_name'][0]
# package var will contain some metadata: version, project_name and others.
or pkg_resources
from pkg_resources import get_distribution
pkg = get_distribution('package_name') # also contains a metadata