• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. _setup-script:
2
3************************
4Writing the Setup Script
5************************
6
7.. include:: ./_setuptools_disclaimer.rst
8
9The setup script is the centre of all activity in building, distributing, and
10installing modules using the Distutils.  The main purpose of the setup script is
11to describe your module distribution to the Distutils, so that the various
12commands that operate on your modules do the right thing.  As we saw in section
13:ref:`distutils-simple-example` above, the setup script consists mainly of a call to
14:func:`setup`, and most information supplied to the Distutils by the module
15developer is supplied as keyword arguments to :func:`setup`.
16
17Here's a slightly more involved example, which we'll follow for the next couple
18of sections: the Distutils' own setup script.  (Keep in mind that although the
19Distutils are included with Python 1.6 and later, they also have an independent
20existence so that Python 1.5.2 users can use them to install other module
21distributions.  The Distutils' own setup script, shown here, is used to install
22the package into Python 1.5.2.) ::
23
24    #!/usr/bin/env python
25
26    from distutils.core import setup
27
28    setup(name='Distutils',
29          version='1.0',
30          description='Python Distribution Utilities',
31          author='Greg Ward',
32          author_email='gward@python.net',
33          url='https://www.python.org/sigs/distutils-sig/',
34          packages=['distutils', 'distutils.command'],
35         )
36
37There are only two differences between this and the trivial one-file
38distribution presented in section :ref:`distutils-simple-example`: more metadata, and the
39specification of pure Python modules by package, rather than by module.  This is
40important since the Distutils consist of a couple of dozen modules split into
41(so far) two packages; an explicit list of every module would be tedious to
42generate and difficult to maintain.  For more information on the additional
43meta-data, see section :ref:`meta-data`.
44
45Note that any pathnames (files or directories) supplied in the setup script
46should be written using the Unix convention, i.e. slash-separated.  The
47Distutils will take care of converting this platform-neutral representation into
48whatever is appropriate on your current platform before actually using the
49pathname.  This makes your setup script portable across operating systems, which
50of course is one of the major goals of the Distutils.  In this spirit, all
51pathnames in this document are slash-separated.
52
53This, of course, only applies to pathnames given to Distutils functions.  If
54you, for example, use standard Python functions such as :func:`glob.glob` or
55:func:`os.listdir` to specify files, you should be careful to write portable
56code instead of hardcoding path separators::
57
58    glob.glob(os.path.join('mydir', 'subdir', '*.html'))
59    os.listdir(os.path.join('mydir', 'subdir'))
60
61
62.. _listing-packages:
63
64Listing whole packages
65======================
66
67The ``packages`` option tells the Distutils to process (build, distribute,
68install, etc.) all pure Python modules found in each package mentioned in the
69``packages`` list.  In order to do this, of course, there has to be a
70correspondence between package names and directories in the filesystem.  The
71default correspondence is the most obvious one, i.e. package :mod:`distutils` is
72found in the directory :file:`distutils` relative to the distribution root.
73Thus, when you say ``packages = ['foo']`` in your setup script, you are
74promising that the Distutils will find a file :file:`foo/__init__.py` (which
75might be spelled differently on your system, but you get the idea) relative to
76the directory where your setup script lives.  If you break this promise, the
77Distutils will issue a warning but still process the broken package anyway.
78
79If you use a different convention to lay out your source directory, that's no
80problem: you just have to supply the ``package_dir`` option to tell the
81Distutils about your convention.  For example, say you keep all Python source
82under :file:`lib`, so that modules in the "root package" (i.e., not in any
83package at all) are in :file:`lib`, modules in the :mod:`foo` package are in
84:file:`lib/foo`, and so forth.  Then you would put ::
85
86    package_dir = {'': 'lib'}
87
88in your setup script.  The keys to this dictionary are package names, and an
89empty package name stands for the root package.  The values are directory names
90relative to your distribution root.  In this case, when you say ``packages =
91['foo']``, you are promising that the file :file:`lib/foo/__init__.py` exists.
92
93Another possible convention is to put the :mod:`foo` package right in
94:file:`lib`, the :mod:`foo.bar` package in :file:`lib/bar`, etc.  This would be
95written in the setup script as ::
96
97    package_dir = {'foo': 'lib'}
98
99A ``package: dir`` entry in the ``package_dir`` dictionary implicitly
100applies to all packages below *package*, so the :mod:`foo.bar` case is
101automatically handled here.  In this example, having ``packages = ['foo',
102'foo.bar']`` tells the Distutils to look for :file:`lib/__init__.py` and
103:file:`lib/bar/__init__.py`.  (Keep in mind that although ``package_dir``
104applies recursively, you must explicitly list all packages in
105``packages``: the Distutils will *not* recursively scan your source tree
106looking for any directory with an :file:`__init__.py` file.)
107
108
109.. _listing-modules:
110
111Listing individual modules
112==========================
113
114For a small module distribution, you might prefer to list all modules rather
115than listing packages---especially the case of a single module that goes in the
116"root package" (i.e., no package at all).  This simplest case was shown in
117section :ref:`distutils-simple-example`; here is a slightly more involved example::
118
119    py_modules = ['mod1', 'pkg.mod2']
120
121This describes two modules, one of them in the "root" package, the other in the
122:mod:`pkg` package.  Again, the default package/directory layout implies that
123these two modules can be found in :file:`mod1.py` and :file:`pkg/mod2.py`, and
124that :file:`pkg/__init__.py` exists as well. And again, you can override the
125package/directory correspondence using the ``package_dir`` option.
126
127
128.. _describing-extensions:
129
130Describing extension modules
131============================
132
133Just as writing Python extension modules is a bit more complicated than writing
134pure Python modules, describing them to the Distutils is a bit more complicated.
135Unlike pure modules, it's not enough just to list modules or packages and expect
136the Distutils to go out and find the right files; you have to specify the
137extension name, source file(s), and any compile/link requirements (include
138directories, libraries to link with, etc.).
139
140.. XXX read over this section
141
142All of this is done through another keyword argument to :func:`setup`, the
143``ext_modules`` option.  ``ext_modules`` is just a list of
144:class:`~distutils.core.Extension` instances, each of which describes a
145single extension module.
146Suppose your distribution includes a single extension, called :mod:`foo` and
147implemented by :file:`foo.c`.  If no additional instructions to the
148compiler/linker are needed, describing this extension is quite simple::
149
150    Extension('foo', ['foo.c'])
151
152The :class:`Extension` class can be imported from :mod:`distutils.core` along
153with :func:`setup`.  Thus, the setup script for a module distribution that
154contains only this one extension and nothing else might be::
155
156    from distutils.core import setup, Extension
157    setup(name='foo',
158          version='1.0',
159          ext_modules=[Extension('foo', ['foo.c'])],
160          )
161
162The :class:`Extension` class (actually, the underlying extension-building
163machinery implemented by the :command:`build_ext` command) supports a great deal
164of flexibility in describing Python extensions, which is explained in the
165following sections.
166
167
168Extension names and packages
169----------------------------
170
171The first argument to the :class:`~distutils.core.Extension` constructor is
172always the name of the extension, including any package names.  For example, ::
173
174    Extension('foo', ['src/foo1.c', 'src/foo2.c'])
175
176describes an extension that lives in the root package, while ::
177
178    Extension('pkg.foo', ['src/foo1.c', 'src/foo2.c'])
179
180describes the same extension in the :mod:`pkg` package.  The source files and
181resulting object code are identical in both cases; the only difference is where
182in the filesystem (and therefore where in Python's namespace hierarchy) the
183resulting extension lives.
184
185If you have a number of extensions all in the same package (or all under the
186same base package), use the ``ext_package`` keyword argument to
187:func:`setup`.  For example, ::
188
189    setup(...,
190          ext_package='pkg',
191          ext_modules=[Extension('foo', ['foo.c']),
192                       Extension('subpkg.bar', ['bar.c'])],
193         )
194
195will compile :file:`foo.c` to the extension :mod:`pkg.foo`, and :file:`bar.c` to
196:mod:`pkg.subpkg.bar`.
197
198
199Extension source files
200----------------------
201
202The second argument to the :class:`~distutils.core.Extension` constructor is
203a list of source
204files.  Since the Distutils currently only support C, C++, and Objective-C
205extensions, these are normally C/C++/Objective-C source files.  (Be sure to use
206appropriate extensions to distinguish C++ source files: :file:`.cc` and
207:file:`.cpp` seem to be recognized by both Unix and Windows compilers.)
208
209However, you can also include SWIG interface (:file:`.i`) files in the list; the
210:command:`build_ext` command knows how to deal with SWIG extensions: it will run
211SWIG on the interface file and compile the resulting C/C++ file into your
212extension.
213
214.. XXX SWIG support is rough around the edges and largely untested!
215
216This warning notwithstanding, options to SWIG can be currently passed like
217this::
218
219    setup(...,
220          ext_modules=[Extension('_foo', ['foo.i'],
221                                 swig_opts=['-modern', '-I../include'])],
222          py_modules=['foo'],
223         )
224
225Or on the commandline like this::
226
227    > python setup.py build_ext --swig-opts="-modern -I../include"
228
229On some platforms, you can include non-source files that are processed by the
230compiler and included in your extension.  Currently, this just means Windows
231message text (:file:`.mc`) files and resource definition (:file:`.rc`) files for
232Visual C++. These will be compiled to binary resource (:file:`.res`) files and
233linked into the executable.
234
235
236Preprocessor options
237--------------------
238
239Three optional arguments to :class:`~distutils.core.Extension` will help if
240you need to specify include directories to search or preprocessor macros to
241define/undefine: ``include_dirs``, ``define_macros``, and ``undef_macros``.
242
243For example, if your extension requires header files in the :file:`include`
244directory under your distribution root, use the ``include_dirs`` option::
245
246    Extension('foo', ['foo.c'], include_dirs=['include'])
247
248You can specify absolute directories there; if you know that your extension will
249only be built on Unix systems with X11R6 installed to :file:`/usr`, you can get
250away with ::
251
252    Extension('foo', ['foo.c'], include_dirs=['/usr/include/X11'])
253
254You should avoid this sort of non-portable usage if you plan to distribute your
255code: it's probably better to write C code like  ::
256
257    #include <X11/Xlib.h>
258
259If you need to include header files from some other Python extension, you can
260take advantage of the fact that header files are installed in a consistent way
261by the Distutils :command:`install_headers` command.  For example, the Numerical
262Python header files are installed (on a standard Unix installation) to
263:file:`/usr/local/include/python1.5/Numerical`. (The exact location will differ
264according to your platform and Python installation.)  Since the Python include
265directory---\ :file:`/usr/local/include/python1.5` in this case---is always
266included in the search path when building Python extensions, the best approach
267is to write C code like  ::
268
269    #include <Numerical/arrayobject.h>
270
271If you must put the :file:`Numerical` include directory right into your header
272search path, though, you can find that directory using the Distutils
273:mod:`distutils.sysconfig` module::
274
275    from distutils.sysconfig import get_python_inc
276    incdir = os.path.join(get_python_inc(plat_specific=1), 'Numerical')
277    setup(...,
278          Extension(..., include_dirs=[incdir]),
279          )
280
281Even though this is quite portable---it will work on any Python installation,
282regardless of platform---it's probably easier to just write your C code in the
283sensible way.
284
285You can define and undefine pre-processor macros with the ``define_macros`` and
286``undef_macros`` options. ``define_macros`` takes a list of ``(name, value)``
287tuples, where ``name`` is the name of the macro to define (a string) and
288``value`` is its value: either a string or ``None``.  (Defining a macro ``FOO``
289to ``None`` is the equivalent of a bare ``#define FOO`` in your C source: with
290most compilers, this sets ``FOO`` to the string ``1``.)  ``undef_macros`` is
291just a list of macros to undefine.
292
293For example::
294
295    Extension(...,
296              define_macros=[('NDEBUG', '1'),
297                             ('HAVE_STRFTIME', None)],
298              undef_macros=['HAVE_FOO', 'HAVE_BAR'])
299
300is the equivalent of having this at the top of every C source file::
301
302    #define NDEBUG 1
303    #define HAVE_STRFTIME
304    #undef HAVE_FOO
305    #undef HAVE_BAR
306
307
308Library options
309---------------
310
311You can also specify the libraries to link against when building your extension,
312and the directories to search for those libraries.  The ``libraries`` option is
313a list of libraries to link against, ``library_dirs`` is a list of directories
314to search for libraries at  link-time, and ``runtime_library_dirs`` is a list of
315directories to  search for shared (dynamically loaded) libraries at run-time.
316
317For example, if you need to link against libraries known to be in the standard
318library search path on target systems ::
319
320    Extension(...,
321              libraries=['gdbm', 'readline'])
322
323If you need to link with libraries in a non-standard location, you'll have to
324include the location in ``library_dirs``::
325
326    Extension(...,
327              library_dirs=['/usr/X11R6/lib'],
328              libraries=['X11', 'Xt'])
329
330(Again, this sort of non-portable construct should be avoided if you intend to
331distribute your code.)
332
333.. XXX Should mention clib libraries here or somewhere else!
334
335
336Other options
337-------------
338
339There are still some other options which can be used to handle special cases.
340
341The ``optional`` option is a boolean; if it is true,
342a build failure in the extension will not abort the build process, but
343instead simply not install the failing extension.
344
345The ``extra_objects`` option is a list of object files to be passed to the
346linker. These files must not have extensions, as the default extension for the
347compiler is used.
348
349``extra_compile_args`` and ``extra_link_args`` can be used to
350specify additional command line options for the respective compiler and linker
351command lines.
352
353``export_symbols`` is only useful on Windows.  It can contain a list of
354symbols (functions or variables) to be exported. This option is not needed when
355building compiled extensions: Distutils  will automatically add ``initmodule``
356to the list of exported symbols.
357
358The ``depends`` option is a list of files that the extension depends on
359(for example header files). The build command will call the compiler on the
360sources to rebuild extension if any on this files has been modified since the
361previous build.
362
363Relationships between Distributions and Packages
364================================================
365
366A distribution may relate to packages in three specific ways:
367
368#. It can require packages or modules.
369
370#. It can provide packages or modules.
371
372#. It can obsolete packages or modules.
373
374These relationships can be specified using keyword arguments to the
375:func:`distutils.core.setup` function.
376
377Dependencies on other Python modules and packages can be specified by supplying
378the *requires* keyword argument to :func:`setup`. The value must be a list of
379strings.  Each string specifies a package that is required, and optionally what
380versions are sufficient.
381
382To specify that any version of a module or package is required, the string
383should consist entirely of the module or package name. Examples include
384``'mymodule'`` and ``'xml.parsers.expat'``.
385
386If specific versions are required, a sequence of qualifiers can be supplied in
387parentheses.  Each qualifier may consist of a comparison operator and a version
388number.  The accepted comparison operators are::
389
390    <    >    ==
391    <=   >=   !=
392
393These can be combined by using multiple qualifiers separated by commas (and
394optional whitespace).  In this case, all of the qualifiers must be matched; a
395logical AND is used to combine the evaluations.
396
397Let's look at a bunch of examples:
398
399+-------------------------+----------------------------------------------+
400| Requires Expression     | Explanation                                  |
401+=========================+==============================================+
402| ``==1.0``               | Only version ``1.0`` is compatible           |
403+-------------------------+----------------------------------------------+
404| ``>1.0, !=1.5.1, <2.0`` | Any version after ``1.0`` and before ``2.0`` |
405|                         | is compatible, except ``1.5.1``              |
406+-------------------------+----------------------------------------------+
407
408Now that we can specify dependencies, we also need to be able to specify what we
409provide that other distributions can require.  This is done using the *provides*
410keyword argument to :func:`setup`. The value for this keyword is a list of
411strings, each of which names a Python module or package, and optionally
412identifies the version.  If the version is not specified, it is assumed to match
413that of the distribution.
414
415Some examples:
416
417+---------------------+----------------------------------------------+
418| Provides Expression | Explanation                                  |
419+=====================+==============================================+
420| ``mypkg``           | Provide ``mypkg``, using the distribution    |
421|                     | version                                      |
422+---------------------+----------------------------------------------+
423| ``mypkg (1.1)``     | Provide ``mypkg`` version 1.1, regardless of |
424|                     | the distribution version                     |
425+---------------------+----------------------------------------------+
426
427A package can declare that it obsoletes other packages using the *obsoletes*
428keyword argument.  The value for this is similar to that of the *requires*
429keyword: a list of strings giving module or package specifiers.  Each specifier
430consists of a module or package name optionally followed by one or more version
431qualifiers.  Version qualifiers are given in parentheses after the module or
432package name.
433
434The versions identified by the qualifiers are those that are obsoleted by the
435distribution being described.  If no qualifiers are given, all versions of the
436named module or package are understood to be obsoleted.
437
438.. _distutils-installing-scripts:
439
440Installing Scripts
441==================
442
443So far we have been dealing with pure and non-pure Python modules, which are
444usually not run by themselves but imported by scripts.
445
446Scripts are files containing Python source code, intended to be started from the
447command line.  Scripts don't require Distutils to do anything very complicated.
448The only clever feature is that if the first line of the script starts with
449``#!`` and contains the word "python", the Distutils will adjust the first line
450to refer to the current interpreter location. By default, it is replaced with
451the current interpreter location.  The :option:`!--executable` (or :option:`!-e`)
452option will allow the interpreter path to be explicitly overridden.
453
454The ``scripts`` option simply is a list of files to be handled in this
455way.  From the PyXML setup script::
456
457    setup(...,
458          scripts=['scripts/xmlproc_parse', 'scripts/xmlproc_val']
459          )
460
461.. versionchanged:: 3.1
462   All the scripts will also be added to the ``MANIFEST`` file if no template is
463   provided.  See :ref:`manifest`.
464
465
466.. _distutils-installing-package-data:
467
468Installing Package Data
469=======================
470
471Often, additional files need to be installed into a package.  These files are
472often data that's closely related to the package's implementation, or text files
473containing documentation that might be of interest to programmers using the
474package.  These files are called :dfn:`package data`.
475
476Package data can be added to packages using the ``package_data`` keyword
477argument to the :func:`setup` function.  The value must be a mapping from
478package name to a list of relative path names that should be copied into the
479package.  The paths are interpreted as relative to the directory containing the
480package (information from the ``package_dir`` mapping is used if appropriate);
481that is, the files are expected to be part of the package in the source
482directories. They may contain glob patterns as well.
483
484The path names may contain directory portions; any necessary directories will be
485created in the installation.
486
487For example, if a package should contain a subdirectory with several data files,
488the files can be arranged like this in the source tree::
489
490    setup.py
491    src/
492        mypkg/
493            __init__.py
494            module.py
495            data/
496                tables.dat
497                spoons.dat
498                forks.dat
499
500The corresponding call to :func:`setup` might be::
501
502    setup(...,
503          packages=['mypkg'],
504          package_dir={'mypkg': 'src/mypkg'},
505          package_data={'mypkg': ['data/*.dat']},
506          )
507
508
509.. versionchanged:: 3.1
510   All the files that match ``package_data`` will be added to the ``MANIFEST``
511   file if no template is provided.  See :ref:`manifest`.
512
513
514.. _distutils-additional-files:
515
516Installing Additional Files
517===========================
518
519The ``data_files`` option can be used to specify additional files needed
520by the module distribution: configuration files, message catalogs, data files,
521anything which doesn't fit in the previous categories.
522
523``data_files`` specifies a sequence of (*directory*, *files*) pairs in the
524following way::
525
526    setup(...,
527          data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
528                      ('config', ['cfg/data.cfg'])],
529         )
530
531Each (*directory*, *files*) pair in the sequence specifies the installation
532directory and the files to install there.
533
534Each file name in *files* is interpreted relative to the :file:`setup.py`
535script at the top of the package source distribution. Note that you can
536specify the directory where the data files will be installed, but you cannot
537rename the data files themselves.
538
539The *directory* should be a relative path. It is interpreted relative to the
540installation prefix (Python's ``sys.prefix`` for system installations;
541``site.USER_BASE`` for user installations). Distutils allows *directory* to be
542an absolute installation path, but this is discouraged since it is
543incompatible with the wheel packaging format. No directory information from
544*files* is used to determine the final location of the installed file; only
545the name of the file is used.
546
547You can specify the ``data_files`` options as a simple sequence of files
548without specifying a target directory, but this is not recommended, and the
549:command:`install` command will print a warning in this case. To install data
550files directly in the target directory, an empty string should be given as the
551directory.
552
553.. versionchanged:: 3.1
554   All the files that match ``data_files`` will be added to the ``MANIFEST``
555   file if no template is provided.  See :ref:`manifest`.
556
557
558.. _meta-data:
559
560Additional meta-data
561====================
562
563The setup script may include additional meta-data beyond the name and version.
564This information includes:
565
566+----------------------+---------------------------+-----------------+--------+
567| Meta-Data            | Description               | Value           | Notes  |
568+======================+===========================+=================+========+
569| ``name``             | name of the package       | short string    | \(1)   |
570+----------------------+---------------------------+-----------------+--------+
571| ``version``          | version of this release   | short string    | (1)(2) |
572+----------------------+---------------------------+-----------------+--------+
573| ``author``           | package author's name     | short string    | \(3)   |
574+----------------------+---------------------------+-----------------+--------+
575| ``author_email``     | email address of the      | email address   | \(3)   |
576|                      | package author            |                 |        |
577+----------------------+---------------------------+-----------------+--------+
578| ``maintainer``       | package maintainer's name | short string    | \(3)   |
579+----------------------+---------------------------+-----------------+--------+
580| ``maintainer_email`` | email address of the      | email address   | \(3)   |
581|                      | package maintainer        |                 |        |
582+----------------------+---------------------------+-----------------+--------+
583| ``url``              | home page for the package | URL             | \(1)   |
584+----------------------+---------------------------+-----------------+--------+
585| ``description``      | short, summary            | short string    |        |
586|                      | description of the        |                 |        |
587|                      | package                   |                 |        |
588+----------------------+---------------------------+-----------------+--------+
589| ``long_description`` | longer description of the | long string     | \(4)   |
590|                      | package                   |                 |        |
591+----------------------+---------------------------+-----------------+--------+
592| ``download_url``     | location where the        | URL             |        |
593|                      | package may be downloaded |                 |        |
594+----------------------+---------------------------+-----------------+--------+
595| ``classifiers``      | a list of classifiers     | list of strings | (6)(7) |
596+----------------------+---------------------------+-----------------+--------+
597| ``platforms``        | a list of platforms       | list of strings | (6)(8) |
598+----------------------+---------------------------+-----------------+--------+
599| ``keywords``         | a list of keywords        | list of strings | (6)(8) |
600+----------------------+---------------------------+-----------------+--------+
601| ``license``          | license for the package   | short string    | \(5)   |
602+----------------------+---------------------------+-----------------+--------+
603
604Notes:
605
606(1)
607    These fields are required.
608
609(2)
610    It is recommended that versions take the form *major.minor[.patch[.sub]]*.
611
612(3)
613    Either the author or the maintainer must be identified. If maintainer is
614    provided, distutils lists it as the author in :file:`PKG-INFO`.
615
616(4)
617    The ``long_description`` field is used by PyPI when you publish a package,
618    to build its project page.
619
620(5)
621    The ``license`` field is a text indicating the license covering the
622    package where the license is not a selection from the "License" Trove
623    classifiers. See the ``Classifier`` field. Notice that
624    there's a ``licence`` distribution option which is deprecated but still
625    acts as an alias for ``license``.
626
627(6)
628    This field must be a list.
629
630(7)
631    The valid classifiers are listed on
632    `PyPI <https://pypi.org/classifiers>`_.
633
634(8)
635    To preserve backward compatibility, this field also accepts a string. If
636    you pass a comma-separated string ``'foo, bar'``, it will be converted to
637    ``['foo', 'bar']``, Otherwise, it will be converted to a list of one
638    string.
639
640'short string'
641    A single line of text, not more than 200 characters.
642
643'long string'
644    Multiple lines of plain text in reStructuredText format (see
645    http://docutils.sourceforge.net/).
646
647'list of strings'
648    See below.
649
650Encoding the version information is an art in itself. Python packages generally
651adhere to the version format *major.minor[.patch][sub]*. The major number is 0
652for initial, experimental releases of software. It is incremented for releases
653that represent major milestones in a package. The minor number is incremented
654when important new features are added to the package. The patch number
655increments when bug-fix releases are made. Additional trailing version
656information is sometimes used to indicate sub-releases.  These are
657"a1,a2,...,aN" (for alpha releases, where functionality and API may change),
658"b1,b2,...,bN" (for beta releases, which only fix bugs) and "pr1,pr2,...,prN"
659(for final pre-release release testing). Some examples:
660
6610.1.0
662    the first, experimental release of a package
663
6641.0.1a2
665    the second alpha release of the first patch version of 1.0
666
667``classifiers`` must be specified in a list::
668
669    setup(...,
670          classifiers=[
671              'Development Status :: 4 - Beta',
672              'Environment :: Console',
673              'Environment :: Web Environment',
674              'Intended Audience :: End Users/Desktop',
675              'Intended Audience :: Developers',
676              'Intended Audience :: System Administrators',
677              'License :: OSI Approved :: Python Software Foundation License',
678              'Operating System :: MacOS :: MacOS X',
679              'Operating System :: Microsoft :: Windows',
680              'Operating System :: POSIX',
681              'Programming Language :: Python',
682              'Topic :: Communications :: Email',
683              'Topic :: Office/Business',
684              'Topic :: Software Development :: Bug Tracking',
685              ],
686          )
687
688.. versionchanged:: 3.7
689   :class:`~distutils.core.setup` now warns when ``classifiers``, ``keywords``
690   or ``platforms`` fields are not specified as a list or a string.
691
692.. _debug-setup-script:
693
694Debugging the setup script
695==========================
696
697Sometimes things go wrong, and the setup script doesn't do what the developer
698wants.
699
700Distutils catches any exceptions when running the setup script, and print a
701simple error message before the script is terminated.  The motivation for this
702behaviour is to not confuse administrators who don't know much about Python and
703are trying to install a package.  If they get a big long traceback from deep
704inside the guts of Distutils, they may think the package or the Python
705installation is broken because they don't read all the way down to the bottom
706and see that it's a permission problem.
707
708On the other hand, this doesn't help the developer to find the cause of the
709failure. For this purpose, the :envvar:`DISTUTILS_DEBUG` environment variable can be set
710to anything except an empty string, and distutils will now print detailed
711information about what it is doing, dump the full traceback when an exception
712occurs, and print the whole command line when an external program (like a C
713compiler) fails.
714