11.. highlightlang :: cfg
22
3+ .. _setupcfg-spec :
4+
35*******************************************
46Specification of the :file: `setup.cfg ` file
57*******************************************
68
7- .. :version: 1.0
9+ :version: 0.9
810
911This document describes the :file: `setup.cfg `, an ini-style configuration file
10- (compatible with :class: `configparser.RawConfigParser `) configuration file used
11- by Packaging to replace the :file: `setup.py ` file.
12+ used by Packaging to replace the :file: `setup.py ` file used by Distutils.
13+ This specification is language-agnostic, and will therefore repeat some
14+ information that's already documented for Python in the
15+ :class: `configparser.RawConfigParser ` documentation.
16+
17+ .. contents ::
18+ :depth: 3
19+ :local:
20+
21+
22+ Syntax
23+ ======
24+
25+ The ini-style format used in the configuration file is a simple collection of
26+ sections that group sets of key-value fields separated by ``= `` or ``: `` and
27+ optional whitespace. Lines starting with ``# `` or ``; `` are comments and will
28+ be ignored. Empty lines are also ignored. Example::
29+
30+ [section1]
31+ # comment
32+ name = value
33+ name2 = "other value"
34+
35+ [section2]
36+ foo = bar
37+
38+
39+ Parsing values
40+ ---------------
41+
42+ Here are a set of rules to parse values:
43+
44+ - If a value is quoted with ``" `` chars, it's a string. If a quote character is
45+ present in the quoted value, it can be escaped as ``\" `` or left as-is.
46+
47+ - If the value is ``true ``, ``t ``, ``yes ``, ``y `` (case-insensitive) or ``1 ``,
48+ it's converted to the language equivalent of a ``True `` value; if it's
49+ ``false ``, ``f ``, ``no ``, ``n `` (case-insensitive) or ``0 ``, it's converted to
50+ the equivalent of ``False ``.
51+
52+ - A value can contain multiple lines. When read, lines are converted into a
53+ sequence of values. Each line after the first must start with a least one
54+ space or tab character; this leading indentation will be stripped.
55+
56+ - All other values are considered strings.
57+
58+ Examples::
59+
60+ [section]
61+ foo = one
62+ two
63+ three
64+
65+ bar = false
66+ baz = 1.3
67+ boo = "ok"
68+ beee = "wqdqw pojpj w\"ddq"
69+
70+
71+ Extending files
72+ ---------------
73+
74+ A configuration file can be extended (i.e. included) by other files. For this,
75+ a ``DEFAULT `` section must contain an ``extends `` key which value points to one
76+ or more files which will be merged into the current files by adding new sections
77+ and fields. If a file loaded by ``extends `` contains sections or keys that
78+ already exist in the original file, they will not override the previous values.
79+
80+ Contents of :file: `one.cfg `::
81+
82+ [section1]
83+ name = value
84+
85+ [section2]
86+ foo = foo from one.cfg
87+
88+ Contents of :file: `two.cfg `::
89+
90+ [DEFAULT]
91+ extends = one.cfg
92+
93+ [section2]
94+ foo = foo from two.cfg
95+ baz = baz from two.cfg
96+
97+ The result of parsing :file: `two.cfg ` is equivalent to this file::
98+
99+ [section1]
100+ name = value
101+
102+ [section2]
103+ foo = foo from one.cfg
104+ baz = baz from two.cfg
105+
106+ Example use of multi-line notation to include more than one file::
107+
108+ [DEFAULT]
109+ extends = one.cfg
110+ two.cfg
111+
112+ When several files are provided, they are processed sequentially, following the
113+ precedence rules explained above. This means that the list of files should go
114+ from most specialized to most common.
115+
116+ **Tools will need to provide a way to produce a merged version of the
117+ file **. This will be useful to let users publish a single file.
118+
119+
120+ Description of sections and fields
121+ ==================================
12122
13123Each section contains a description of its options.
14124
@@ -108,10 +218,6 @@ description
108218 in Distutils1.) A file can be provided in the *description-file * field.
109219 *optional *
110220
111- description-file
112- path to a text file that will be used for the
113- **description ** field. *optional *
114-
115221keywords
116222 A list of additional keywords to be used to assist searching
117223 for the distribution in a larger catalog. Comma or space-separated.
@@ -172,6 +278,13 @@ project-url
172278 A label, followed by a browsable URL for the project.
173279 "label, url". The label is limited to 32 signs. *optional *, *multi *
174280
281+ One extra field not present in PEP 345 is supported:
282+
283+ description-file
284+ Path to a text file that will be used to fill the ``description `` field.
285+ ``description-file `` and ``description `` are mutually exclusive. *optional *
286+
287+
175288
176289Example::
177290
@@ -278,7 +391,7 @@ The final paths where files will be placed are composed by : **source** +
278391**destination **. In the previous example, **doc/doc.man ** will be placed in
279392**destination_doc/doc/doc.man ** and **scripts/foo.sh ** will be placed in
280393**destination_scripts/scripts/foo.sh **. (If you want more control on the final
281- path, take a look at base_prefix _ ).
394+ path, take a look at :ref: ` setupcfg-resources-base-prefix ` ).
282395
283396The **destination ** part of resources declaration are paths with categories.
284397Indeed, it's generally a bad idea to give absolute path as it will be cross
@@ -402,13 +515,13 @@ Your **files** section will be::
402515More control on destination part
403516^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
404517
405- .. _ base_prefix :
518+ .. _ setupcfg-resources-base-prefix :
406519
407520Defining a base prefix
408521""""""""""""""""""""""
409522
410523When you define your resources, you can have more control of how the final path
411- is compute .
524+ is computed .
412525
413526By default, the final path is::
414527
@@ -435,7 +548,7 @@ The **prefix** is "docs/" and the **suffix** is "doc.html".
435548
436549.. note ::
437550
438- Glob syntax is working the same way with standard source and splitted source.
551+ Glob syntax is working the same way with standard source and split source.
439552 So these rules::
440553
441554 docs/*
@@ -444,7 +557,7 @@ The **prefix** is "docs/" and the **suffix** is "doc.html".
444557
445558 Will match all the files in the docs directory.
446559
447- When you use splitted source, the final path is compute in this way::
560+ When you use split source, the final path is computed this way::
448561
449562 destination + prefix
450563
@@ -646,3 +759,64 @@ section named after the command. Example::
646759
647760Option values given in the configuration file can be overriden on the command
648761line. See :ref: `packaging-setup-config ` for more information.
762+
763+
764+ Extensibility
765+ =============
766+
767+ Every section can have fields that are not part of this specification. They are
768+ called **extensions **.
769+
770+ An extension field starts with ``X- ``. Example::
771+
772+ [metadata]
773+ name = Distribute
774+ X-Debian-Name = python-distribute
775+
776+
777+ Changes in the specification
778+ ============================
779+
780+ The versioning scheme for this specification is **MAJOR.MINOR **. Changes in the
781+ specification will cause the version number to be updated.
782+
783+ Changes to the minor number reflect backwards-compatible changes:
784+
785+ - New fields and sections (optional or mandatory) can be added.
786+ - Optional fields can be removed.
787+
788+ The major number will be incremented for backwards-incompatible changes:
789+
790+ - Mandatory fields or sections are removed.
791+ - Fields change their meaning.
792+
793+ As a consequence, a tool written to consume 1.5 has these properties:
794+
795+ - Can read 1.1, 1.2 and all versions < 1.5, since the tool knows what
796+ optional fields weren't there.
797+
798+ .. XXX clarify
799+
800+ - Can also read 1.6 and other 1.x versions: The tool will just ignore fields it
801+ doesn't know about, even if they are mandatory in the new version. If
802+ optional fields were removed, the tool will just consider them absent.
803+
804+ - Cannot read 2.x and should refuse to interpret such files.
805+
806+ A tool written to produce 1.x should have these properties:
807+
808+ - Writes all mandatory fields.
809+ - May write optional fields.
810+
811+
812+ Acknowledgments
813+ ===============
814+
815+ This specification includes work and feedback from these people:
816+
817+ - Tarek Ziadé
818+ - Julien Jehannet
819+ - Boris Feld
820+ - Éric Araujo
821+
822+ (If your name is missing, please :ref: `let us know <reporting-bugs >`.)
0 commit comments