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