Metadata#

A data representation for core metadata.

Reference#

class packaging.metadata.DynamicField#

An enum.Enum representing fields which can be listed in the Dynamic field of core metadata.

Every valid field is a name on this enum, upper-cased with any - replaced with _. Each value is the field name lower-cased (- are kept). For example, the Home-page field has a name of HOME_PAGE and a value of home-page.

PLATFORM = 'platform'#
SUMMARY = 'summary'#
DESCRIPTION = 'description'#
KEYWORDS = 'keywords'#
HOME_PAGE = 'home-page'#
AUTHOR = 'author'#
AUTHOR_EMAIL = 'author-email'#
LICENSE = 'license'#
SUPPORTED_PLATFORM = 'supported-platform'#
DOWNLOAD_URL = 'download-url'#
CLASSIFIER = 'classifier'#
MAINTAINER = 'maintainer'#
MAINTAINER_EMAIL = 'maintainer-email'#
REQUIRES_DIST = 'requires-dist'#
REQUIRES_PYTHON = 'requires-python'#
REQUIRES_EXTERNAL = 'requires-external'#
PROJECT_URL = 'project-url'#
PROVIDES_DIST = 'provides-dist'#
OBSOLETES_DIST = 'obsoletes-dist'#
DESCRIPTION_CONTENT_TYPE = 'description-content-type'#
PROVIDES_EXTRA = 'provides-extra'#
class packaging.metadata.Metadata#

A class representing the Core Metadata for a project.

Every potential metadata field except for Metadata-Version is represented by a parameter to the class’ constructor. The required metadata can be passed in positionally or via keyword, while all optional metadata can only be passed in via keyword.

Every parameter has a matching attribute on instances, except for name (see display_name and canonical_name). Any parameter that accepts an Iterable is represented as a list on the corresponding attribute.

__init__(name, version, *, platforms=None, summary=None, description=None, keywords=None, home_page=None, author=None, author_emails=None, license=None, supported_platforms=None, download_url=None, classifiers=None, maintainer=None, maintainer_emails=None, requires_dists=None, requires_python=None, requires_externals=None, project_urls=None, provides_dists=None, obsoletes_dists=None, description_content_type=None, provides_extras=None, dynamic_fields=None)#

Initialize a Metadata object.

The parameters all correspond to fields in Core Metadata.

Parameters
Return type

None

version: Version#
platforms: List[str]#
summary: str#
description: str#
keywords: List[str]#
home_page: str#
author: str#
author_emails: List[Tuple[Optional[str], str]]#
license: str#
supported_platforms: List[str]#
download_url: str#
classifiers: List[str]#
maintainer: str#
maintainer_emails: List[Tuple[Optional[str], str]]#
requires_dists: List[Requirement]#
requires_python: SpecifierSet#
requires_externals: List[str]#
project_urls: List[Tuple[str, str]]#
provides_dists: List[str]#
obsoletes_dists: List[str]#
description_content_type: str#
provides_extras: List[NormalizedName]#
dynamic_fields: List[DynamicField]#
property display_name: str#

The project name to be displayed to users (i.e. not normalized). Initially set based on the name parameter.

Setting this attribute will also update canonical_name.

property canonical_name: NormalizedName#

The normalized project name as per packaging.utils.canonicalize_name().

The attribute is read-only and automatically calculated based on the value of display_name.