Metadata#

A data representation for core metadata.

Reference#

class packaging.metadata.DynamicField[source]#

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.

class packaging.metadata.Metadata(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)[source]#

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.

Parameters
  • name (str) – Name.

  • version (packaging.version.Version) – Version (note that this is different than Metadata-Version).

  • platforms (Iterable[str]) – Platform.

  • summary (str) – Summary.

  • description (str) – Description.

  • keywords (Iterable[str]) – Keywords.

  • home_page (str) – Home-Page.

  • author (str) – Author.

  • author_emails (Iterable[tuple[str | None, str]]) – Author-Email where the two-item tuple represents the name and email of the author, respectively.

  • license (str) – License.

  • supported_platforms (Iterable[str]) – Supported-Platform.

  • download_url (str) – Download-URL.

  • classifiers (Iterable[str]) – Classifier.

  • maintainer (str) – Maintainer.

  • maintainer_emails (Iterable[tuple[str | None, str]]) – Maintainer-Email, where the two-item tuple represents the name and email of the maintainer, respectively.

  • requires_dists (Iterable[packaging.requirements.Requirement]) – Requires-Dist.

  • requires_python (packaging.specifiers.SpecifierSet) – Requires-Python.

  • requires_externals (Iterable[str]) – Requires-External.

  • project_urls (tuple[str, str]) – Project-URL.

  • provides_dists (Iterable[str]) – Provides-Dist.

  • obsoletes_dists (Iterable[str]) – Obsoletes-Dist.

  • description_content_type (str) – Description-Content-Type.

  • provides_extras (Iterable[packaging.utils.NormalizedName]) – Provides-Extra.

  • dynamic_fields (Iterable[DynamicField]) – Dynamic.

Attributes not directly corresponding to a parameter are:

display_name#

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.

canonical_name#

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.