/docs/source/distutils/setupscript.rst

https://bitbucket.org/tarek/distutils2/ · ReStructuredText · 686 lines · 516 code · 170 blank · 0 comment · 0 complexity · 50edb40a1862aee35e13ee9dac0ccac1 MD5 · raw file

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