python-peps/pep-0345.txt

541 lines
15 KiB
Plaintext
Raw Normal View History

PEP: 345
2005-05-23 09:08:09 -04:00
Title: Metadata for Python Software Packages 1.2
Version: $Revision$
Last-Modified: $Date$
2007-06-20 20:48:29 -04:00
Author: Richard Jones <richard@python.org>
Discussions-To: Distutils SIG
Status: Draft
Type: Standards Track
Content-Type: text/x-rst
Created: 28-Apr-2005
Python-Version: 2.5
Post-History:
Replaces: 314
Abstract
========
This PEP describes a mechanism for adding metadata to Python packages.
It includes specifics of the field names, and their semantics and
usage.
This document specifies version 1.2 of the metadata format.
Version 1.0 is specified in PEP 241.
Version 1.1 is specified in PEP 314.
Version 1.2 of the metadata format adds a number of optional fields
designed to make third-party packaging of Python Software easier.
2009-10-20 03:59:46 -04:00
These fields are "Requires-Python", "Requires-External", "Requires-Dist",
"Provides-Dist", and "Obsoletes-Dist". This version also changes the
"Platform" field. Three new fields were also added: "Maintainer",
"Maintainer-email" and "Project-URL".
Last, this new version also adds `environment markers`.
Fields
======
This section specifies the names and semantics of each of the
supported metadata fields.
Fields marked with "(Multiple use)" may be specified multiple
times in a single PKG-INFO file. Other fields may only occur
once in a PKG-INFO file. Fields marked with "(optional)" are
not required to appear in a valid PKG-INFO file; all other
fields must be present.
Metadata-Version
2009-12-22 19:10:25 -05:00
::::::::::::::::
Version of the file format; "1.2" is the only legal value.
2009-12-22 19:10:25 -05:00
Example::
Metadata-Version: 1.2
Name
2009-12-22 19:10:25 -05:00
::::
The name of the package.
Example::
2009-12-22 19:10:25 -05:00
Name: BeagleVote
Version
2009-12-22 19:10:25 -05:00
:::::::
2009-12-22 19:10:25 -05:00
A string containing the package's version number. This
field must be in the format specified in `PEP 386`_.
Example::
Version: 1.0a2
Platform (multiple use)
2009-12-22 19:10:25 -05:00
:::::::::::::::::::::::
A Platform specification describing an operating system supported by
the package which is not listed in the "Operating System" Trove classifiers.
See "Classifier" below.
Examples::
2009-12-22 19:10:25 -05:00
Platform: ObscureUnix
Platform: RareDOS
Supported-Platform (multiple use)
2009-12-22 19:10:25 -05:00
:::::::::::::::::::::::::::::::::
Binary distributions containing a PKG-INFO file will use the
Supported-Platform field in their metadata to specify the OS and
CPU for which the binary package was compiled. The semantics of
the Supported-Platform field are not specified in this PEP.
Example::
2009-12-22 19:10:25 -05:00
Supported-Platform: RedHat 7.2
Supported-Platform: i386-win32-2791
Summary
2009-12-22 19:10:25 -05:00
:::::::
2009-12-22 19:10:25 -05:00
A one-line summary of what the package does.
Example::
Summary: A module for collecting votes from beagles.
Description (optional)
2009-12-22 19:10:25 -05:00
::::::::::::::::::::::
A longer description of the package that can run to several
paragraphs. Software that deals with metadata should not assume
any maximum size for this field, though people shouldn't include
their instruction manual as the description.
2009-12-22 19:10:25 -05:00
The contents of this field can be written using reStructuredText
markup [1]_. For programs that work with the metadata, supporting
markup is optional; programs can also display the contents of the
field as-is. This means that authors should be conservative in
the markup they use.
2009-12-22 19:10:25 -05:00
Example::
Description: This module collects votes from beagles
in order to determine their electoral wishes.
Do *not* try to use this module with basset hounds;
it makes them grumpy.
Keywords (optional)
2009-12-22 19:10:25 -05:00
:::::::::::::::::::
A list of additional keywords to be used to assist searching
for the package in a larger catalog.
2009-12-22 19:10:25 -05:00
Example::
Keywords: dog puppy voting election
Home-page (optional)
2009-12-22 19:10:25 -05:00
::::::::::::::::::::
A string containing the URL for the package's home page.
2009-12-22 19:10:25 -05:00
Example::
Home-page: http://www.example.com/~cschultz/bvote/
Download-URL
2009-12-22 19:10:25 -05:00
::::::::::::
A string containing the URL from which this version of the package
can be downloaded. (This means that the URL can't be something like
".../package-latest.tgz", but instead must be ".../package-0.45.tgz".)
Author (optional)
2009-12-22 19:10:25 -05:00
:::::::::::::::::
2009-12-22 19:10:25 -05:00
A string containing the author's name at a minimum; additional
contact information may be provided.
Example::
Author: C. Schultz, Universal Features Syndicate,
Los Angeles, CA <cschultz@peanuts.example.com>
Author-email
2009-12-22 19:10:25 -05:00
::::::::::::
A string containing the author's e-mail address. It can contain
a name and e-mail address in the legal forms for a RFC-822
``From:`` header. It's not optional because cataloging systems
can use the e-mail portion of this field as a unique key
representing the author. A catalog might provide authors the
ability to store their GPG key, personal home page, and other
additional metadata *about the author*, and optionally the
ability to associate several e-mail addresses with the same
person. Author-related metadata fields are not covered by this
PEP.
2009-12-22 19:10:25 -05:00
Example::
Author-email: "C. Schultz" <cschultz@example.com>
2009-10-20 03:59:46 -04:00
Maintainer (optional)
2009-12-22 19:10:25 -05:00
:::::::::::::::::::::
A string containing the maintainer's name at a minimum; additional
contact information may be provided.
Note that this field is intended for use when a package is being
maintained by someone other than the original author: it should be
omitted if it is identical to ``Author``.
2009-12-22 19:10:25 -05:00
Example::
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
Maintainer: C. Schultz, Universal Features Syndicate,
Los Angeles, CA <cschultz@peanuts.example.com>
2009-10-20 03:59:46 -04:00
Maintainer-email (optional)
2009-12-22 19:10:25 -05:00
:::::::::::::::::::::::::::
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
A string containing the maintainer's e-mail address. It can contain
a name and e-mail address in the legal forms for a RFC-822
``From:`` header.
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
Note that this field is intended for use when a package is being
maintained by someone other than the original author: it should be
omitted if it is identical to ``Author-email``.
Example::
Maintainer-email: "C. Schultz" <cschultz@example.com>
2009-10-20 03:59:46 -04:00
License (optional)
2009-12-22 19:10:25 -05:00
::::::::::::::::::
Text indicating the license covering the package where the license
is not a selection from the "License" Trove classifiers. See
"Classifier" below. This field may also be used to specify a
particular version of a licencse which is named via the ``Classifier``
field, or to indicate a variation or exception to such a license.
Examples::
2009-12-22 19:10:25 -05:00
License: This software may only be obtained by sending the
author a postcard, and then the user promises not
to redistribute it.
2009-12-22 19:10:25 -05:00
License: GPL version 3, excluding DRM provisions
2009-10-20 03:59:46 -04:00
Classifier (multiple use)
2009-12-22 19:10:25 -05:00
:::::::::::::::::::::::::
Each entry is a string giving a single classification value
for the package. Classifiers are described in PEP 301 [2].
Examples::
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console (Text Based)
2009-10-20 03:59:46 -04:00
Requires-Dist (multiple use)
2009-12-22 19:10:25 -05:00
::::::::::::::::::::::::::::
Each entry contains a string naming some other distutils
project required by this package.
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
The format of a requirement string is identical to that of a
distutils project name (e.g., as found in the ``Name:`` field.
optionally followed by a version declaration within parentheses.
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
The distutils project names should correspond to names as found
on the `Python Package Index`_.
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
A version declaration is a series of conditional operators and
version numbers, separated by commas. Conditional operators
must be one of "<", ">", "<=", ">=", "==", and "!=". Version
numbers must be in the format specified in `PEP 386`_.
If no operator is provided with a version, the "==" operator
is used by default.
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
Any number of conditional operators can be specified, e.g.
the string ">1.0, !=1.3.4, <2.0" is a legal version declaration.
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
Examples::
Requires-Dist: pkginfo
Requires-Dist: PasteDeploy
Requires-Dist: zope.interface (>3.5.0)
2009-10-20 03:59:46 -04:00
Provides-Dist (multiple use)
2009-12-22 19:10:25 -05:00
::::::::::::::::::::::::::::
Each entry contains a string naming a distutlis project which
is contained within this distribution. This field *must* include
the project identified in the ``Name`` field.
A distribution may provide additional names, e.g. to indicate that
multiple projects have been bundled together. For instance, source
distributions of the ``ZODB`` project have historically included
the ``transaction`` project, which is now available as a separate
distribution. Installing such a source distribution satisfies
requirements for both ``ZODB`` and ``transaction``.
A distribution may also provide a "virtual" project name, which does
not correspond to any separately-distributed project: such a name
might be used to indicate an abstract capability which could be supplied
by one of multiple projects. E.g., multiple projects might supply
RDBMS bindings for use by a given ORM: each project might declare
that it provides ``ORM-bindings``, allowing other projects to depend
only on having at most one of them installed.
A version declaration may be supplied (without a comparison
operator); the distribution's version number will be implied if none
is specified. Version numbers must be in the format specified in
`PEP 386`_.
Examples::
Provides-Dist: OtherPackage
Provides-Dist: AnotherPackage (3.4)
Provides-Dist: virtual_package
2009-10-20 03:59:46 -04:00
Obsoletes-Dist (multiple use)
2009-12-22 19:10:25 -05:00
:::::::::::::::::::::::::::::
Each entry contains a string describing a distutils project which
this package renders obsolete, meaning that the two packages
should not be installed at the same time.
2009-12-22 19:10:25 -05:00
Version declarations can be supplied. Version numbers must be in the
format specified in `PEP 386`_.
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
The most common use of this field will be in case a project name
changes, e.g. Gorgon 2.3 gets subsumed into Torqued Python 1.0.
When you install Torqued Python, the Gorgon distribution should be
removed.
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
Examples::
Obsoletes-Dist: Gorgon
Obsoletes-Dist: OtherPackage (<3.0)
2009-10-20 03:59:46 -04:00
Requires-Python
2009-12-22 19:10:25 -05:00
:::::::::::::::
This field specifies the Python version(s) that the package is
guaranteed to be compatible with. The format of the field is a
series of conditional operators and version numbers, separated
by commas. Conditional operators must be one of "<", ">", "<=",
">=", "==", and "!=". If no operator is provided with a version,
the "==" operator is used by default.
Version numbers must be in the format specified in `PEP 386`_.
2009-10-20 03:59:46 -04:00
2009-12-22 19:10:25 -05:00
Any number of conditional operators can be specified, e.g.
the string ">1.0, !=1.3.4, <2.0" is a legal version declaration.
2009-12-22 19:10:25 -05:00
Examples::
2009-12-22 19:10:25 -05:00
Requires-Python: >2.1
Requires-Python: >=2.3.4
Requires-Python: 2.5, 2.6
Requires-External (multiple use)
2009-12-22 19:10:25 -05:00
::::::::::::::::::::::::::::::::
2009-12-22 19:10:25 -05:00
Each entry contains a string describing some dependency in the
system that the package is to be used. This field is intended to
serve as a hint to downstream package maintainers, and has no
semantics which are meaningful to the ``distutils`` package.
2009-12-22 19:10:25 -05:00
The format of a requirement string is a name of an external
dependency, optionally followed by a version declaration within
parentheses.
2009-12-22 19:10:25 -05:00
A version declaration is a series of conditional operators and
version numbers, separated by commas. Conditional operators
must be one of "<", ">", "<=", ">=", "==", and "!=". If no
operator is provided with a version, the "==" operator is used by default.
2009-12-22 19:10:25 -05:00
Because they refer to non-Python software releases, version numbers
for this field are **not** required to conform to the format
specified in `PEP 386`_: they should correspond to the
version scheme used by the external dependency.
2009-12-22 19:10:25 -05:00
Any number of conditional operators can be specified, e.g.
the string ">1.0, !=1.3.4, <2.0" is a legal version declaration.
2009-12-22 19:10:25 -05:00
Notice that there's is no particular rule on the strings to be used.
2009-12-22 19:10:25 -05:00
Examples::
Requires-External: C
Requires-External: libpng (>=1.5)
2009-12-22 19:10:25 -05:00
Project-URL (multiple-use)
::::::::::::::::::::::::::
2009-12-22 19:10:25 -05:00
A string containing a browsable URL for the project and a label for it,
separated by a comma.
2009-12-22 19:10:25 -05:00
Example::
2009-12-22 19:10:25 -05:00
Bug Tracker, http://bitbucket.org/tarek/distribute/issues/
2009-12-22 19:10:25 -05:00
The label is a free text limited to 32 signs.
2009-10-20 03:59:46 -04:00
Version Specifiers
==================
The specification for distribution version specifiers has been moved to
`PEP 386`_.
2009-11-14 18:55:17 -05:00
Environment markers
===================
An **environment marker** is a marker that can be added at the end of a
field after a semi-colon (';'), to add a condition about the execution
environment.
Here are some example of fields using such markers::
Requires-Dist: pywin32 > 1.0; sys.platform == 'win32'
2009-11-14 18:55:17 -05:00
Obsoletes-Dist: pywin31; sys.platform == 'win32'
Requires-Dist: foo; os.machine == 'i386'
Requires-Dist: bar; python_version == '2.4' or python_version == '2.5'
Requires-External: libxslt; 'linux' in sys.platform
These markers are using a micro-language that can be interpreted using a
2009-11-14 18:55:17 -05:00
function ``interpret_marker`` provided in the ``distutils.util`` module
in the stdlib::
2009-12-21 06:26:17 -05:00
>>> from distutils.util import interpret_marker
2009-11-14 18:55:17 -05:00
>>> interpret_marker("sys.platform == 'win32'")
True
Depending if the execution environment meets the requirements, the function
2009-11-14 18:55:17 -05:00
will return True or False.
The micro-language behind this is the simplest possible: it compares only
strings, with the ``==`` and ``in`` operators (and their opposites), and
with the ability to combine expressions. It makes it also easy to understand
to non-pythoneers.
The pseudo-grammar is ::
EXPR [in|==|!=|not in] EXPR [or|and] ...
where ``EXPR`` belongs to any of those:
- python_version = '%s.%s' % (sys.version_info[0], sys.version_info[1])
- python_full_version = sys.version.split()[0]
2009-11-14 18:55:17 -05:00
- os.name = os.name
- sys.platform = sys.platform
- platform.version = platform.version()
- platform.machine = platform.machine()
- a free string, like ``2.4``, or ``win32``
Notice that ``in`` is restricted to strings, meaning that it is not possible
to use other sequences like tuples or lists on the right side.
The fields that benefit from this marker are:
- Requires-Python
- Requires-External
- Requires-Dist
- Provides-Dist
- Obsoletes-Dist
- Classifier
2009-10-20 03:59:46 -04:00
Summary of Differences From PEP 314
===================================
* Metadata-Version is now 1.2.
2009-11-14 18:55:17 -05:00
* Added the environment markers.
2009-10-20 03:59:46 -04:00
* Added fields:
- Maintainer
- Maintainer-email
- Requires-Python
- Requires-External
- Requires-Dist
- Provides-Dist
- Obsoletes-Dist
- Project-URL
2009-10-20 03:59:46 -04:00
* Deprecated fields:
- Requires (in favor of Requires-Dist)
- Provides (in favor of Provides-Dist)
- Obsoletes (in favor of Obsoletes-Dist)
References
==========
This document specifies version 1.2 of the metadata format.
Version 1.0 is specified in PEP 241.
Version 1.1 is specified in PEP 314.
.. [1] reStructuredText markup:
http://docutils.sourceforge.net/
2009-10-20 03:59:46 -04:00
.. _`Python Package Index`: http://pypi.python.org/pypi/
.. _`PEP 386`: http://www.python.org/dev/peps/pep-0386
Copyright
=========
This document has been placed in the public domain.
Acknowledgements
================
Fred Drake, Anthony Baxter and Matthias Klose have all contributed to
the ideas presented in this PEP.
Tres Seaver, Jim Fulton, Marc-André Lemburg, Tarek Ziadé and other people at
2009-11-14 18:55:17 -05:00
the Distutils-SIG have contributed to the new updated version.
..
Local Variables:
mode: indented-text
indent-tabs-mode: nil
sentence-end-double-space: t
fill-column: 70
End: