blob: a38101751ed609b9d75b872811a369378d45a42b [file] [log] [blame]
Éric Araujo3a9f58f2011-06-01 20:42:49 +02001.. highlightlang:: cfg
2
Éric Araujo0300b5c2011-06-06 01:54:54 +02003.. _setupcfg-spec:
Éric Araujo823759e2011-06-04 18:46:25 +02004
Éric Araujo3a9f58f2011-06-01 20:42:49 +02005*******************************************
6Specification of the :file:`setup.cfg` file
7*******************************************
8
Éric Araujoba661a92011-06-04 02:31:14 +02009:version: 0.9
Éric Araujo3a9f58f2011-06-01 20:42:49 +020010
11This document describes the :file:`setup.cfg`, an ini-style configuration file
Éric Araujoed4fd702011-06-06 02:07:24 +020012used by Packaging to replace the :file:`setup.py` file used by Distutils.
13This specification is language-agnostic, and will therefore repeat some
14information that's already documented for Python in the
15:class:`configparser.RawConfigParser` documentation.
Éric Araujoba661a92011-06-04 02:31:14 +020016
Éric Araujof0f9b222011-06-06 01:52:37 +020017.. contents::
18 :depth: 3
19 :local:
20
Éric Araujoba661a92011-06-04 02:31:14 +020021
Éric Araujo79d9c422011-10-19 08:41:07 +020022.. _setupcfg-syntax:
23
Éric Araujoba661a92011-06-04 02:31:14 +020024Syntax
25======
26
Éric Araujoed4fd702011-06-06 02:07:24 +020027The ini-style format used in the configuration file is a simple collection of
28sections that group sets of key-value fields separated by ``=`` or ``:`` and
29optional whitespace. Lines starting with ``#`` or ``;`` are comments and will
30be ignored. Empty lines are also ignored. Example::
Éric Araujoba661a92011-06-04 02:31:14 +020031
32 [section1]
33 # comment
34 name = value
35 name2 = "other value"
36
37 [section2]
38 foo = bar
39
40
Éric Araujoed4fd702011-06-06 02:07:24 +020041Parsing values
42---------------
Éric Araujoba661a92011-06-04 02:31:14 +020043
Éric Araujoed4fd702011-06-06 02:07:24 +020044Here are a set of rules to parse values:
Éric Araujoba661a92011-06-04 02:31:14 +020045
Éric Araujoed4fd702011-06-06 02:07:24 +020046- If a value is quoted with ``"`` chars, it's a string. If a quote character is
47 present in the quoted value, it can be escaped as ``\"`` or left as-is.
48
49- If the value is ``true``, ``t``, ``yes``, ``y`` (case-insensitive) or ``1``,
50 it's converted to the language equivalent of a ``True`` value; if it's
51 ``false``, ``f``, ``no``, ``n`` (case-insensitive) or ``0``, it's converted to
52 the equivalent of ``False``.
53
54- A value can contain multiple lines. When read, lines are converted into a
55 sequence of values. Each line after the first must start with a least one
56 space or tab character; this leading indentation will be stripped.
57
58- All other values are considered strings.
Éric Araujoba661a92011-06-04 02:31:14 +020059
60Examples::
61
62 [section]
63 foo = one
64 two
65 three
66
67 bar = false
68 baz = 1.3
69 boo = "ok"
70 beee = "wqdqw pojpj w\"ddq"
71
72
73Extending files
74---------------
75
Éric Araujoed4fd702011-06-06 02:07:24 +020076A configuration file can be extended (i.e. included) by other files. For this,
Brett Cannon5c9a8d02011-09-05 21:08:14 -070077a ``DEFAULT`` section must contain an ``extends`` key whose value points to one
Éric Araujoed4fd702011-06-06 02:07:24 +020078or more files which will be merged into the current files by adding new sections
79and fields. If a file loaded by ``extends`` contains sections or keys that
80already exist in the original file, they will not override the previous values.
Éric Araujoba661a92011-06-04 02:31:14 +020081
Éric Araujo13890082011-06-06 01:58:25 +020082Contents of :file:`one.cfg`::
Éric Araujoba661a92011-06-04 02:31:14 +020083
84 [section1]
Éric Araujo13890082011-06-06 01:58:25 +020085 name = value
Éric Araujoba661a92011-06-04 02:31:14 +020086
87 [section2]
Éric Araujo13890082011-06-06 01:58:25 +020088 foo = foo from one.cfg
Éric Araujoba661a92011-06-04 02:31:14 +020089
Éric Araujo13890082011-06-06 01:58:25 +020090Contents of :file:`two.cfg`::
Éric Araujoba661a92011-06-04 02:31:14 +020091
92 [DEFAULT]
Éric Araujo13890082011-06-06 01:58:25 +020093 extends = one.cfg
Éric Araujoba661a92011-06-04 02:31:14 +020094
95 [section2]
Éric Araujo13890082011-06-06 01:58:25 +020096 foo = foo from two.cfg
97 baz = baz from two.cfg
Éric Araujoba661a92011-06-04 02:31:14 +020098
Éric Araujo13890082011-06-06 01:58:25 +020099The result of parsing :file:`two.cfg` is equivalent to this file::
Éric Araujoba661a92011-06-04 02:31:14 +0200100
101 [section1]
Éric Araujo13890082011-06-06 01:58:25 +0200102 name = value
Éric Araujoba661a92011-06-04 02:31:14 +0200103
104 [section2]
Éric Araujo13890082011-06-06 01:58:25 +0200105 foo = foo from one.cfg
106 baz = baz from two.cfg
Éric Araujoba661a92011-06-04 02:31:14 +0200107
Éric Araujo13890082011-06-06 01:58:25 +0200108Example use of multi-line notation to include more than one file::
Éric Araujoba661a92011-06-04 02:31:14 +0200109
110 [DEFAULT]
Éric Araujo13890082011-06-06 01:58:25 +0200111 extends = one.cfg
112 two.cfg
Éric Araujoba661a92011-06-04 02:31:14 +0200113
Éric Araujoed4fd702011-06-06 02:07:24 +0200114When several files are provided, they are processed sequentially, following the
115precedence rules explained above. This means that the list of files should go
116from most specialized to most common.
Éric Araujoba661a92011-06-04 02:31:14 +0200117
Éric Araujoed4fd702011-06-06 02:07:24 +0200118**Tools will need to provide a way to produce a merged version of the
119file**. This will be useful to let users publish a single file.
Éric Araujoba661a92011-06-04 02:31:14 +0200120
121
Éric Araujo79d9c422011-10-19 08:41:07 +0200122.. _setupcfg-sections:
123
Éric Araujoba661a92011-06-04 02:31:14 +0200124Description of sections and fields
125==================================
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200126
127Each section contains a description of its options.
128
129- Options that are marked *multi* can have multiple values, one value per
130 line.
131- Options that are marked *optional* can be omitted.
132- Options that are marked *environ* can use environment markers, as described
133 in :PEP:`345`.
134
135
136The sections are:
137
138global
139 Global options not related to one command.
140
141metadata
142 Name, version and other information defined by :PEP:`345`.
143
144files
145 Modules, scripts, data, documentation and other files to include in the
146 distribution.
147
Éric Araujoc7f9f2b2011-06-09 08:18:17 +0200148extension sections
149 Options used to build extension modules.
150
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200151command sections
152 Options given for specific commands, identical to those that can be given
153 on the command line.
154
155
Éric Araujo79d9c422011-10-19 08:41:07 +0200156.. _setupcfg-section-global:
157
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200158Global options
Éric Araujoa462a802011-06-09 08:15:47 +0200159--------------
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200160
161Contains global options for Packaging. This section is shared with Distutils.
162
163
164commands
165 Defined Packaging command. A command is defined by its fully
166 qualified name. *optional*, *multi*
167
168 Examples::
169
170 [global]
171 commands =
172 package.setup.CustomSdistCommand
173 package.setup.BdistDeb
174
175compilers
176 Defined Packaging compiler. A compiler is defined by its fully
177 qualified name. *optional*, *multi*
178
179 Example::
180
181 [global]
182 compilers =
183 hotcompiler.SmartCCompiler
184
Éric Araujo643cb732011-06-11 00:33:38 +0200185setup_hooks
186 Defines a list of callables to be called right after the :file:`setup.cfg`
Éric Araujo54bb1e62011-06-19 21:34:16 +0200187 file is read, before any other processing. Each value is a Python dotted
188 name to an object, which has to be defined in a module present in the project
189 directory alonside :file:`setup.cfg` or on Python's :data:`sys.path` (see
190 :ref:`packaging-finding-hooks`). The callables are executed in the
Éric Araujo643cb732011-06-11 00:33:38 +0200191 order they're found in the file; if one of them cannot be found, tools should
192 not stop, but for example produce a warning and continue with the next line.
193 Each callable receives the configuration as a dictionary (keys are
194 :file:`setup.cfg` sections, values are dictionaries of fields) and can make
Éric Araujo54bb1e62011-06-19 21:34:16 +0200195 any change to it. *optional*, *multi*
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200196
197 Example::
198
199 [global]
Éric Araujo54bb1e62011-06-19 21:34:16 +0200200 setup_hooks = _setuphooks.customize_config
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200201
202
Éric Araujo79d9c422011-10-19 08:41:07 +0200203
204.. _setupcfg-section-metadata:
205
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200206Metadata
Éric Araujoa462a802011-06-09 08:15:47 +0200207--------
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200208
209The metadata section contains the metadata for the project as described in
210:PEP:`345`. Field names are case-insensitive.
211
212Fields:
213
214name
215 Name of the project.
216
217version
218 Version of the project. Must comply with :PEP:`386`.
219
220platform
221 Platform specification describing an operating system
222 supported by the distribution which is not listed in the "Operating System"
223 Trove classifiers (:PEP:`301`). *optional*, *multi*
224
225supported-platform
226 Binary distributions containing a PKG-INFO file will
227 use the Supported-Platform field in their metadata to specify the OS and
228 CPU for which the binary distribution was compiled. The semantics of
229 the Supported-Platform field are free form. *optional*, *multi*
230
231summary
232 A one-line summary of what the distribution does.
233 (Used to be called *description* in Distutils1.)
234
235description
236 A longer description. (Used to be called *long_description*
237 in Distutils1.) A file can be provided in the *description-file* field.
238 *optional*
239
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200240keywords
241 A list of additional keywords to be used to assist searching
242 for the distribution in a larger catalog. Comma or space-separated.
243 *optional*
244
245home-page
246 The URL for the distribution's home page.
247
248download-url
249 The URL from which this version of the distribution
250 can be downloaded. *optional*
251
252author
253 Author's name. *optional*
254
255author-email
256 Author's e-mail. *optional*
257
258maintainer
259 Maintainer's name. *optional*
260
261maintainer-email
262 Maintainer's e-mail. *optional*
263
264license
265 A text indicating the term of uses, when a trove classifier does
266 not match. *optional*.
267
268classifiers
269 Classification for the distribution, as described in PEP 301.
270 *optional*, *multi*, *environ*
271
272requires-dist
273 name of another packaging project required as a dependency.
274 The format is *name (version)* where version is an optional
275 version declaration, as described in PEP 345. *optional*, *multi*, *environ*
276
277provides-dist
278 name of another packaging project contained within this
279 distribution. Same format than *requires-dist*. *optional*, *multi*,
280 *environ*
281
282obsoletes-dist
283 name of another packaging project this version obsoletes.
284 Same format than *requires-dist*. *optional*, *multi*, *environ*
285
286requires-python
Éric Araujofdeb8bf2011-06-06 19:57:02 +0200287 Specifies the Python version the distribution requires. The value is a
288 comma-separated list of version predicates, as described in PEP 345.
289 *optional*, *environ*
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200290
291requires-externals
292 a dependency in the system. This field is free-form,
293 and just a hint for downstream maintainers. *optional*, *multi*,
294 *environ*
295
296project-url
297 A label, followed by a browsable URL for the project.
298 "label, url". The label is limited to 32 signs. *optional*, *multi*
299
Éric Araujo8a4e7a92011-06-06 01:58:54 +0200300One extra field not present in PEP 345 is supported:
301
302description-file
303 Path to a text file that will be used to fill the ``description`` field.
Éric Araujo8474f292011-06-11 00:21:18 +0200304 Multiple values are accepted; they must be separated by whitespace.
Éric Araujo8a4e7a92011-06-06 01:58:54 +0200305 ``description-file`` and ``description`` are mutually exclusive. *optional*
306
307
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200308
309Example::
310
311 [metadata]
312 name = pypi2rpm
313 version = 0.1
314 author = Tarek Ziadé
315 author-email = tarek@ziade.org
316 summary = Script that transforms an sdist archive into a RPM package
317 description-file = README
318 home-page = http://bitbucket.org/tarek/pypi2rpm/wiki/Home
319 project-url:
320 Repository, http://bitbucket.org/tarek/pypi2rpm/
321 RSS feed, https://bitbucket.org/tarek/pypi2rpm/rss
322 classifier =
323 Development Status :: 3 - Alpha
324 License :: OSI Approved :: Mozilla Public License 1.1 (MPL 1.1)
325
326You should not give any explicit value for metadata-version: it will be guessed
327from the fields present in the file.
328
329
Éric Araujo79d9c422011-10-19 08:41:07 +0200330.. _setupcfg-section-files:
331
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200332Files
Éric Araujoa462a802011-06-09 08:15:47 +0200333-----
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200334
335This section describes the files included in the project.
336
337packages_root
338 the root directory containing all packages and modules
Éric Araujo79d9c422011-10-19 08:41:07 +0200339 (default: current directory, i.e. the project's top-level
340 directory where :file:`setup.cfg` lives). *optional*
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200341
342packages
343 a list of packages the project includes *optional*, *multi*
344
345modules
346 a list of packages the project includes *optional*, *multi*
347
348scripts
349 a list of scripts the project includes *optional*, *multi*
350
351extra_files
Éric Araujo79d9c422011-10-19 08:41:07 +0200352 a list of patterns for additional files to include in source distributions
353 (see :ref:`packaging-manifest`) *optional*, *multi*
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200354
355Example::
356
357 [files]
358 packages_root = src
359 packages =
360 pypi2rpm
361 pypi2rpm.command
362
363 scripts =
364 pypi2rpm/pypi2rpm.py
365
366 extra_files =
367 setup.py
368 README
369
370
371.. Note::
372 The :file:`setup.cfg` configuration file is included by default. Contrary to
373 Distutils, :file:`README` (or :file:`README.txt`) and :file:`setup.py` are
374 not included by default.
375
376
377Resources
Éric Araujoa462a802011-06-09 08:15:47 +0200378^^^^^^^^^
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200379
380This section describes the files used by the project which must not be installed
381in the same place that python modules or libraries, they are called
382**resources**. They are for example documentation files, script files,
383databases, etc...
384
385For declaring resources, you must use this notation::
386
387 source = destination
388
389Data-files are declared in the **resources** field in the **file** section, for
390example::
391
392 [files]
393 resources =
394 source1 = destination1
395 source2 = destination2
396
397The **source** part of the declaration are relative paths of resources files
398(using unix path separator **/**). For example, if you've this source tree::
399
400 foo/
401 doc/
402 doc.man
403 scripts/
404 foo.sh
405
406Your setup.cfg will look like::
407
408 [files]
409 resources =
410 doc/doc.man = destination_doc
411 scripts/foo.sh = destination_scripts
412
413The final paths where files will be placed are composed by : **source** +
414**destination**. In the previous example, **doc/doc.man** will be placed in
415**destination_doc/doc/doc.man** and **scripts/foo.sh** will be placed in
416**destination_scripts/scripts/foo.sh**. (If you want more control on the final
Éric Araujo0300b5c2011-06-06 01:54:54 +0200417path, take a look at :ref:`setupcfg-resources-base-prefix`).
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200418
419The **destination** part of resources declaration are paths with categories.
420Indeed, it's generally a bad idea to give absolute path as it will be cross
421incompatible. So, you must use resources categories in your **destination**
422declaration. Categories will be replaced by their real path at the installation
423time. Using categories is all benefit, your declaration will be simpler, cross
424platform and it will allow packager to place resources files where they want
425without breaking your code.
426
427Categories can be specified by using this syntax::
428
429 {category}
430
431Default categories are:
432
433* config
434* appdata
435* appdata.arch
436* appdata.persistent
437* appdata.disposable
438* help
439* icon
440* scripts
441* doc
442* info
443* man
444
445A special category also exists **{distribution.name}** that will be replaced by
446the name of the distribution, but as most of the defaults categories use them,
447so it's not necessary to add **{distribution.name}** into your destination.
448
449If you use categories in your declarations, and you are encouraged to do, final
450path will be::
451
452 source + destination_expanded
453
454.. _example_final_path:
455
456For example, if you have this setup.cfg::
457
458 [metadata]
459 name = foo
460
461 [files]
462 resources =
463 doc/doc.man = {doc}
464
465And if **{doc}** is replaced by **{datadir}/doc/{distribution.name}**, final
466path will be::
467
468 {datadir}/doc/foo/doc/doc.man
469
470Where {datafir} category will be platform-dependent.
471
472
473More control on source part
Éric Araujoa462a802011-06-09 08:15:47 +0200474"""""""""""""""""""""""""""
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200475
476Glob syntax
Éric Araujoa462a802011-06-09 08:15:47 +0200477'''''''''''
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200478
479When you declare source file, you can use a glob-like syntax to match multiples file, for example::
480
481 scripts/* = {script}
482
483Will match all the files in the scripts directory and placed them in the script category.
484
485Glob tokens are:
486
487 * ``*``: match all files.
488 * ``?``: match any character.
489 * ``**``: match any level of tree recursion (even 0).
490 * ``{}``: will match any part separated by comma (example: ``{sh,bat}``).
491
492.. TODO Add examples
493
494Order of declaration
Éric Araujoa462a802011-06-09 08:15:47 +0200495''''''''''''''''''''
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200496
497The order of declaration is important if one file match multiple rules. The last
498rules matched by file is used, this is useful if you have this source tree::
499
500 foo/
501 doc/
502 index.rst
503 setup.rst
504 documentation.txt
505 doc.tex
506 README
507
508And you want all the files in the doc directory to be placed in {doc} category,
509but README must be placed in {help} category, instead of listing all the files
510one by one, you can declare them in this way::
511
512 [files]
513 resources =
514 doc/* = {doc}
515 doc/README = {help}
516
517Exclude
Éric Araujoa462a802011-06-09 08:15:47 +0200518'''''''
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200519
520You can exclude some files of resources declaration by giving no destination, it
521can be useful if you have a non-resources file in the same directory of
522resources files::
523
524 foo/
525 doc/
526 RELEASES
527 doc.tex
528 documentation.txt
529 docu.rst
530
531Your **files** section will be::
532
533 [files]
534 resources =
535 doc/* = {doc}
536 doc/RELEASES =
537
538More control on destination part
Éric Araujoa462a802011-06-09 08:15:47 +0200539""""""""""""""""""""""""""""""""
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200540
Éric Araujo0300b5c2011-06-06 01:54:54 +0200541.. _setupcfg-resources-base-prefix:
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200542
543Defining a base prefix
Éric Araujoa462a802011-06-09 08:15:47 +0200544''''''''''''''''''''''
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200545
546When you define your resources, you can have more control of how the final path
Éric Araujo60533e02011-06-06 02:00:54 +0200547is computed.
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200548
549By default, the final path is::
550
551 destination + source
552
553This can generate long paths, for example (example_final_path_)::
554
555 {datadir}/doc/foo/doc/doc.man
556
557When you declare your source, you can use whitespace to split the source in
558**prefix** **suffix**. So, for example, if you have this source::
559
560 docs/ doc.man
561
562The **prefix** is "docs/" and the **suffix** is "doc.html".
563
564.. note::
565
566 Separator can be placed after a path separator or replace it. So these two
567 sources are equivalent::
568
569 docs/ doc.man
570 docs doc.man
571
572.. note::
573
Éric Araujo60533e02011-06-06 02:00:54 +0200574 Glob syntax is working the same way with standard source and split source.
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200575 So these rules::
576
577 docs/*
578 docs/ *
579 docs *
580
581 Will match all the files in the docs directory.
582
Éric Araujo60533e02011-06-06 02:00:54 +0200583When you use split source, the final path is computed this way::
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200584
585 destination + prefix
586
587So for example, if you have this setup.cfg::
588
589 [metadata]
590 name = foo
591
592 [files]
593 resources =
594 doc/ doc.man = {doc}
595
596And if **{doc}** is replaced by **{datadir}/doc/{distribution.name}**, final
597path will be::
598
599 {datadir}/doc/foo/doc.man
600
601
602Overwriting paths for categories
Éric Araujoa462a802011-06-09 08:15:47 +0200603""""""""""""""""""""""""""""""""
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200604
605This part is intended for system administrators or downstream OS packagers.
606
607The real paths of categories are registered in the *sysconfig.cfg* file
608installed in your python installation. This file uses an ini format too.
609The content of the file is organized into several sections:
610
611* globals: Standard categories's paths.
612* posix_prefix: Standard paths for categories and installation paths for posix
613 system.
614* other ones XXX
615
616Standard categories paths are platform independent, they generally refers to
617other categories, which are platform dependent. :mod:`sysconfig` will choose
618these category from sections matching os.name. For example::
619
620 doc = {datadir}/doc/{distribution.name}
621
622It refers to datadir category, which can be different between platforms. In
623posix system, it may be::
624
625 datadir = /usr/share
626
627So the final path will be::
628
629 doc = /usr/share/doc/{distribution.name}
630
631The platform-dependent categories are:
632
633* confdir
634* datadir
635* libdir
636* base
637
638
639Defining extra categories
Éric Araujoa462a802011-06-09 08:15:47 +0200640"""""""""""""""""""""""""
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200641
642.. TODO
643
644
645Examples
Éric Araujoa462a802011-06-09 08:15:47 +0200646""""""""
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200647
648These examples are incremental but work unitarily.
649
650Resources in root dir
Éric Araujoa462a802011-06-09 08:15:47 +0200651'''''''''''''''''''''
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200652
653Source tree::
654
655 babar-1.0/
656 README
657 babar.sh
658 launch.sh
659 babar.py
660
661:file:`setup.cfg`::
662
663 [files]
664 resources =
665 README = {doc}
666 *.sh = {scripts}
667
668So babar.sh and launch.sh will be placed in {scripts} directory.
669
670Now let's move all the scripts into a scripts directory.
671
672Resources in sub-directory
Éric Araujoa462a802011-06-09 08:15:47 +0200673''''''''''''''''''''''''''
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200674
675Source tree::
676
677 babar-1.1/
678 README
679 scripts/
680 babar.sh
681 launch.sh
682 LAUNCH
683 babar.py
684
685:file:`setup.cfg`::
686
687 [files]
688 resources =
689 README = {doc}
690 scripts/ LAUNCH = {doc}
691 scripts/ *.sh = {scripts}
692
693It's important to use the separator after scripts/ to install all the shell
694scripts into {scripts} instead of {scripts}/scripts.
695
696Now let's add some docs.
697
698Resources in multiple sub-directories
Éric Araujoa462a802011-06-09 08:15:47 +0200699'''''''''''''''''''''''''''''''''''''
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200700
701Source tree::
702
703 babar-1.2/
704 README
705 scripts/
706 babar.sh
707 launch.sh
708 LAUNCH
709 docs/
710 api
711 man
712 babar.py
713
714:file:`setup.cfg`::
715
716 [files]
717 resources =
718 README = {doc}
719 scripts/ LAUNCH = {doc}
720 scripts/ *.sh = {scripts}
721 doc/ * = {doc}
722 doc/ man = {man}
723
724You want to place all the file in the docs script into {doc} category, instead
725of man, which must be placed into {man} category, we will use the order of
726declaration of globs to choose the destination, the last glob that match the
727file is used.
728
729Now let's add some scripts for windows users.
730
731Complete example
Éric Araujoa462a802011-06-09 08:15:47 +0200732''''''''''''''''
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200733
734Source tree::
735
736 babar-1.3/
737 README
738 doc/
739 api
740 man
741 scripts/
742 babar.sh
743 launch.sh
744 babar.bat
745 launch.bat
746 LAUNCH
747
748:file:`setup.cfg`::
749
750 [files]
751 resources =
752 README = {doc}
753 scripts/ LAUNCH = {doc}
754 scripts/ *.{sh,bat} = {scripts}
755 doc/ * = {doc}
756 doc/ man = {man}
757
758We use brace expansion syntax to place all the shell and batch scripts into
759{scripts} category.
760
761
Éric Araujo79d9c422011-10-19 08:41:07 +0200762.. _setupcfg-section-extensions:
763
764Extension modules sections
765--------------------------
Éric Araujoc7f9f2b2011-06-09 08:18:17 +0200766
767If a project includes extension modules written in C or C++, each one of them
768needs to have its options defined in a dedicated section. Here's an example::
769
770 [files]
771 packages = coconut
772
Éric Araujo336b4e42011-09-01 06:29:11 +0200773 [extension: coconut._fastcoconut]
Éric Araujoc7f9f2b2011-06-09 08:18:17 +0200774 language = cxx
775 sources = cxx_src/cononut_utils.cxx
776 cxx_src/python_module.cxx
777 include_dirs = /usr/include/gecode
778 /usr/include/blitz
779 extra_compile_args =
780 -fPIC -O2
781 -DGECODE_VERSION=$(./gecode_version) -- sys.platform != 'win32'
Éric Araujo0efc4192011-11-14 18:21:38 +0100782 /DGECODE_VERSION=win32 -- sys.platform == 'win32'
Éric Araujoc7f9f2b2011-06-09 08:18:17 +0200783
Éric Araujo336b4e42011-09-01 06:29:11 +0200784The section name must start with ``extension:``; the right-hand part is used as
785the full name (including a parent package, if any) of the extension. Whitespace
Éric Araujod9299e92011-09-01 07:01:13 +0200786around the extension name is allowed. If the extension module is not standalone
787(e.g. ``_bisect``) but part of a package (e.g. ``thing._speedups``), the parent
788package must be listed in the ``packages`` field.
Éric Araujo336b4e42011-09-01 06:29:11 +0200789Valid fields and their values are listed in the documentation of the
Éric Araujoc7f9f2b2011-06-09 08:18:17 +0200790:class:`packaging.compiler.extension.Extension` class; values documented as
791Python lists translate to multi-line values in the configuration file. In
792addition, multi-line values accept environment markers on each line, after a
793``--``.
794
795
Éric Araujo79d9c422011-10-19 08:41:07 +0200796.. _setupcfg-section-commands:
797
798Commands sections
799-----------------
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200800
801To pass options to commands without having to type them on the command line
802for each invocation, you can write them in the :file:`setup.cfg` file, in a
803section named after the command. Example::
804
805 [sdist]
806 # special function to add custom files
807 manifest-builders = package.setup.list_extra_files
808
809 [build]
810 use-2to3 = True
811
812 [build_ext]
813 inplace = on
814
815 [check]
816 strict = on
817 all = on
818
819Option values given in the configuration file can be overriden on the command
820line. See :ref:`packaging-setup-config` for more information.
Éric Araujoba661a92011-06-04 02:31:14 +0200821
Éric Araujo79d9c422011-10-19 08:41:07 +0200822These sections are also used to define :ref:`command hooks
823<packaging-command-hooks>`.
824
825
826.. _setupcfg-extensibility:
Éric Araujoba661a92011-06-04 02:31:14 +0200827
828Extensibility
829=============
830
Éric Araujo1cf8a322011-06-06 02:00:03 +0200831Every section can have fields that are not part of this specification. They are
832called **extensions**.
Éric Araujoba661a92011-06-04 02:31:14 +0200833
Éric Araujo1cf8a322011-06-06 02:00:03 +0200834An extension field starts with ``X-``. Example::
Éric Araujoba661a92011-06-04 02:31:14 +0200835
836 [metadata]
Éric Araujo1cf8a322011-06-06 02:00:03 +0200837 name = Distribute
Éric Araujoba661a92011-06-04 02:31:14 +0200838 X-Debian-Name = python-distribute
839
840
Éric Araujo79d9c422011-10-19 08:41:07 +0200841.. _setupcfg-changes:
842
Éric Araujoba661a92011-06-04 02:31:14 +0200843Changes in the specification
844============================
845
Éric Araujoa69ade82011-06-06 02:02:34 +0200846The versioning scheme for this specification is **MAJOR.MINOR**. Changes in the
847specification will cause the version number to be updated.
Éric Araujoba661a92011-06-04 02:31:14 +0200848
Éric Araujoa69ade82011-06-06 02:02:34 +0200849Changes to the minor number reflect backwards-compatible changes:
Éric Araujoba661a92011-06-04 02:31:14 +0200850
Éric Araujoa69ade82011-06-06 02:02:34 +0200851- New fields and sections (optional or mandatory) can be added.
852- Optional fields can be removed.
Éric Araujoba661a92011-06-04 02:31:14 +0200853
Éric Araujoa69ade82011-06-06 02:02:34 +0200854The major number will be incremented for backwards-incompatible changes:
Éric Araujoba661a92011-06-04 02:31:14 +0200855
Éric Araujoa69ade82011-06-06 02:02:34 +0200856- Mandatory fields or sections are removed.
857- Fields change their meaning.
Éric Araujoba661a92011-06-04 02:31:14 +0200858
Éric Araujoa69ade82011-06-06 02:02:34 +0200859As a consequence, a tool written to consume 1.5 has these properties:
Éric Araujoba661a92011-06-04 02:31:14 +0200860
Éric Araujoa69ade82011-06-06 02:02:34 +0200861- Can read 1.1, 1.2 and all versions < 1.5, since the tool knows what
862 optional fields weren't there.
Éric Araujoba661a92011-06-04 02:31:14 +0200863
Éric Araujoa69ade82011-06-06 02:02:34 +0200864 .. XXX clarify
Éric Araujoba661a92011-06-04 02:31:14 +0200865
Éric Araujoa69ade82011-06-06 02:02:34 +0200866- Can also read 1.6 and other 1.x versions: The tool will just ignore fields it
867 doesn't know about, even if they are mandatory in the new version. If
868 optional fields were removed, the tool will just consider them absent.
Éric Araujoba661a92011-06-04 02:31:14 +0200869
Éric Araujoa69ade82011-06-06 02:02:34 +0200870- Cannot read 2.x and should refuse to interpret such files.
Éric Araujoba661a92011-06-04 02:31:14 +0200871
Éric Araujoa69ade82011-06-06 02:02:34 +0200872A tool written to produce 1.x should have these properties:
Éric Araujoba661a92011-06-04 02:31:14 +0200873
Éric Araujoa69ade82011-06-06 02:02:34 +0200874- Writes all mandatory fields.
875- May write optional fields.
Éric Araujo1cf8a322011-06-06 02:00:03 +0200876
877
Éric Araujo79d9c422011-10-19 08:41:07 +0200878.. _setupcfg-acks:
879
Éric Araujo1cf8a322011-06-06 02:00:03 +0200880Acknowledgments
881===============
882
883This specification includes work and feedback from these people:
884
885- Tarek Ziadé
886- Julien Jehannet
887- Boris Feld
888- Éric Araujo
889
890(If your name is missing, please :ref:`let us know <reporting-bugs>`.)