[Distutils] complete 'extras' proposal

Daniel Holth dholth at gmail.com
Mon Jun 25 20:13:36 CEST 2012


The prose isn't PEP-compliant yet, but here is my whole proposal for
adding extras to .dist-info-style  / Metadata 1.2 distributions.

An 'extra' is an optional feature that can augment a distribution's
requirements. An extra name must be a valid Python identifier and is
referenced using subscript notation, e.g. distribution[extra]. As a
shortcut, multiple extras can be referenced as a comma-separated list
distribution[extra1,extra2,...] which is expanded to "distribution
distribution[extra1] distribution[extra2]". (It is not legal to
require an extra without also requiring the providing distribution).

The name 'extra' is added to the list of variables in PKG-INFO
environment markers. During marker execution 'extra' is either 'None'
or the name of the extra that is being installed. (The markers must be
evaluated once for each extra that is being installed.)

Extras are declared with the new Provides-Extra: extra field, repeated
for each extra that a distribution provides. A distribution need not
reference Provides-Extra: in any Requires-Dist: fields, a case that
will most often occur to preserve compatibility with other
distributions that require the named extra when a once-optional
dependency becomes standard.

The extra names 'test' and 'doc' are reserved for requirements that
are needed for running automated tests or building documentation,
respectively.

Example lines from PKG-INFO:

Requires-Dist: nose; extra == 'test'
Provides-Extra: test


More information about the Distutils-SIG mailing list