| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b00a75f commit 96c45a9
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,9 +21,7 @@ setup script). Indirectly provides the :class:`distutils.dist.Distribution` and | |||
| 21 | 21 | .. function:: setup(arguments) | |
| 22 | 22 | ||
| 23 | 23 | The basic do-everything function that does most everything you could ever ask | |
| 24 | - for from a Distutils method. | ||
| 25 | - | ||
| 26 | - .. See XXXXX | ||
| 24 | + for from a Distutils method. See XXXXX | ||
| 27 | 25 | ||
| 28 | 26 | The setup function takes a large number of arguments. These are laid out in the | |
| 29 | 27 | following table. | |
@@ -149,11 +147,11 @@ setup script). Indirectly provides the :class:`distutils.dist.Distribution` and | |||
| 149 | 147 | In addition, the :mod:`distutils.core` module exposed a number of classes that | |
| 150 | 148 | live elsewhere. | |
| 151 | 149 | ||
| 152 | - * :class:`~distutils.extension.Extension` from :mod:`distutils.extension` | ||
| 150 | + * :class:`Extension` from :mod:`distutils.extension` | ||
| 153 | 151 | ||
| 154 | - * :class:`~distutils.cmd.Command` from :mod:`distutils.cmd` | ||
| 152 | + * :class:`Command` from :mod:`distutils.cmd` | ||
| 155 | 153 | ||
| 156 | - * :class:`~distutils.dist.Distribution` from :mod:`distutils.dist` | ||
| 154 | + * :class:`Distribution` from :mod:`distutils.dist` | ||
| 157 | 155 | ||
| 158 | 156 | A short description of each of these follows, but see the relevant module for | |
| 159 | 157 | the full reference. | |
@@ -997,7 +995,7 @@ directories. | |||
| 997 | 995 | errors are ignored (apart from being reported to ``sys.stdout`` if *verbose* is | |
| 998 | 996 | true). | |
| 999 | 997 | ||
| 1000 | - .. XXX Some of this could be replaced with the shutil module? | ||
| 998 | + **\*\*** Some of this could be replaced with the shutil module? **\*\*** | ||
| 1001 | 999 | ||
| 1002 | 1000 | ||
| 1003 | 1001 | :mod:`distutils.file_util` --- Single file operations | |
@@ -1313,7 +1311,8 @@ provides the following additional features: | |||
| 1313 | 1311 | the "negative alias" of :option:`--verbose`, then :option:`--quiet` on the | |
| 1314 | 1312 | command line sets *verbose* to false. | |
| 1315 | 1313 | ||
| 1316 | - .. XXX Should be replaced with :mod:`optparse`. | ||
| 1314 | + **\*\*** Should be replaced with :mod:`optik` (which is also now known as | ||
| 1315 | + :mod:`optparse` in Python 2.3 and later). **\*\*** | ||
| 1317 | 1316 | ||
| 1318 | 1317 | ||
| 1319 | 1318 | .. function:: fancy_getopt(options, negative_opt, object, args) | |
@@ -1681,8 +1680,8 @@ lines, and joining lines with backslashes. | |||
| 1681 | 1680 | =================================================================== | |
| 1682 | 1681 | ||
| 1683 | 1682 | .. module:: distutils.cmd | |
| 1684 | - :synopsis: This module provides the abstract base class Command. This class | ||
| 1685 | - is subclassed by the modules in the distutils.command subpackage. | ||
| 1683 | + :synopsis: This module provides the abstract base class Command. This class is subclassed | ||
| 1684 | + by the modules in the distutils.command subpackage. | ||
| 1686 | 1685 | ||
| 1687 | 1686 | ||
| 1688 | 1687 | This module supplies the abstract base class :class:`Command`. | |
@@ -1692,84 +1691,20 @@ This module supplies the abstract base class :class:`Command`. | |||
| 1692 | 1691 | ||
| 1693 | 1692 | Abstract base class for defining command classes, the "worker bees" of the | |
| 1694 | 1693 | Distutils. A useful analogy for command classes is to think of them as | |
| 1695 | - subroutines with local variables called *options*. The options are declared | ||
| 1696 | - in :meth:`initialize_options` and defined (given their final values) in | ||
| 1697 | - :meth:`finalize_options`, both of which must be defined by every command | ||
| 1698 | - class. The distinction between the two is necessary because option values | ||
| 1699 | - might come from the outside world (command line, config file, ...), and any | ||
| 1700 | - options dependent on other options must be computed after these outside | ||
| 1701 | - influences have been processed --- hence :meth:`finalize_options`. The body | ||
| 1702 | - of the subroutine, where it does all its work based on the values of its | ||
| 1703 | - options, is the :meth:`run` method, which must also be implemented by every | ||
| 1704 | - command class. | ||
| 1705 | - | ||
| 1706 | - The class constructor takes a single argument *dist*, a :class:`Distribution` | ||
| 1694 | + subroutines with local variables called *options*. The options are declared in | ||
| 1695 | + :meth:`initialize_options` and defined (given their final values) in | ||
| 1696 | + :meth:`finalize_options`, both of which must be defined by every command class. | ||
| 1697 | + The distinction between the two is necessary because option values might come | ||
| 1698 | + from the outside world (command line, config file, ...), and any options | ||
| 1699 | + dependent on other options must be computed after these outside influences have | ||
| 1700 | + been processed --- hence :meth:`finalize_options`. The body of the subroutine, | ||
| 1701 | + where it does all its work based on the values of its options, is the | ||
| 1702 | + :meth:`run` method, which must also be implemented by every command class. | ||
| 1703 | + | ||
| 1704 | + The class constructor takes a single argument *dist*, a :class:`Distribution` | ||
| 1707 | 1705 | instance. | |
| 1708 | 1706 | ||
| 1709 | 1707 | ||
| 1710 | - Creating a new Distutils command | ||
| 1711 | - ================================ | ||
| 1712 | - | ||
| 1713 | - This section outlines the steps to create a new Distutils command. | ||
| 1714 | - | ||
| 1715 | - A new command lives in a module in the :mod:`distutils.command` package. There | ||
| 1716 | - is a sample template in that directory called :file:`command_template`. Copy | ||
| 1717 | - this file to a new module with the same name as the new command you're | ||
| 1718 | - implementing. This module should implement a class with the same name as the | ||
| 1719 | - module (and the command). So, for instance, to create the command | ||
| 1720 | - ``peel_banana`` (so that users can run ``setup.py peel_banana``), you'd copy | ||
| 1721 | - :file:`command_template` to :file:`distutils/command/peel_banana.py`, then edit | ||
| 1722 | - it so that it's implementing the class :class:`peel_banana`, a subclass of | ||
| 1723 | - :class:`distutils.cmd.Command`. | ||
| 1724 | - | ||
| 1725 | - Subclasses of :class:`Command` must define the following methods. | ||
| 1726 | - | ||
| 1727 | - .. method:: Command.initialize_options() | ||
| 1728 | - | ||
| 1729 | - Set default values for all the options that this command supports. Note that | ||
| 1730 | - these defaults may be overridden by other commands, by the setup script, by | ||
| 1731 | - config files, or by the command-line. Thus, this is not the place to code | ||
| 1732 | - dependencies between options; generally, :meth:`initialize_options` | ||
| 1733 | - implementations are just a bunch of ``self.foo = None`` assignments. | ||
| 1734 | - | ||
| 1735 | - | ||
| 1736 | - .. method:: Command.finalize_options() | ||
| 1737 | - | ||
| 1738 | - Set final values for all the options that this command supports. This is | ||
| 1739 | - always called as late as possible, ie. after any option assignments from the | ||
| 1740 | - command-line or from other commands have been done. Thus, this is the place | ||
| 1741 | - to to code option dependencies: if *foo* depends on *bar*, then it is safe to | ||
| 1742 | - set *foo* from *bar* as long as *foo* still has the same value it was | ||
| 1743 | - assigned in :meth:`initialize_options`. | ||
| 1744 | - | ||
| 1745 | - | ||
| 1746 | - .. method:: Command.run() | ||
| 1747 | - | ||
| 1748 | - A command's raison d'etre: carry out the action it exists to perform, | ||
| 1749 | - controlled by the options initialized in :meth:`initialize_options`, | ||
| 1750 | - customized by other commands, the setup script, the command-line, and config | ||
| 1751 | - files, and finalized in :meth:`finalize_options`. All terminal output and | ||
| 1752 | - filesystem interaction should be done by :meth:`run`. | ||
| 1753 | - | ||
| 1754 | - | ||
| 1755 | - .. attribute:: Command.sub_commands | ||
| 1756 | - | ||
| 1757 | - *sub_commands* formalizes the notion of a "family" of commands, | ||
| 1758 | - e.g. ``install`` as the parent with sub-commands ``install_lib``, | ||
| 1759 | - ``install_headers``, etc. The parent of a family of commands defines | ||
| 1760 | - *sub_commands* as a class attribute; it's a list of 2-tuples ``(command_name, | ||
| 1761 | - predicate)``, with *command_name* a string and *predicate* a function, a | ||
| 1762 | - string or ``None``. *predicate* is a method of the parent command that | ||
| 1763 | - determines whether the corresponding command is applicable in the current | ||
| 1764 | - situation. (E.g. we ``install_headers`` is only applicable if we have any C | ||
| 1765 | - header files to install.) If *predicate* is ``None``, that command is always | ||
| 1766 | - applicable. | ||
| 1767 | - | ||
| 1768 | - *sub_commands* is usually defined at the *end* of a class, because | ||
| 1769 | - predicates can be methods of the class, so they must already have been | ||
| 1770 | - defined. The canonical example is the :command:`install` command. | ||
| 1771 | - | ||
| 1772 | - | ||
| 1773 | 1708 | :mod:`distutils.command` --- Individual Distutils commands | |
| 1774 | 1709 | ========================================================== | |
| 1775 | 1710 | ||
@@ -2008,3 +1943,76 @@ The ``register`` command registers the package with the Python Package Index. | |||
| 2008 | 1943 | This is described in more detail in :pep:`301`. | |
| 2009 | 1944 | ||
| 2010 | 1945 | .. % todo | |
| 1946 | + | ||
| 1947 | + :mod:`distutils.command.check` --- Check the meta-data of a package | ||
| 1948 | + =================================================================== | ||
| 1949 | + | ||
| 1950 | + .. module:: distutils.command.check | ||
| 1951 | + :synopsis: Check the metadata of a package | ||
| 1952 | + | ||
| 1953 | + | ||
| 1954 | + The ``check`` command performs some tests on the meta-data of a package. | ||
| 1955 | + For example, it verifies that all required meta-data are provided as | ||
| 1956 | + the arguments passed to the :func:`setup` function. | ||
| 1957 | + | ||
| 1958 | + .. % todo | ||
| 1959 | + | ||
| 1960 | + | ||
| 1961 | + Creating a new Distutils command | ||
| 1962 | + ================================ | ||
| 1963 | + | ||
| 1964 | + This section outlines the steps to create a new Distutils command. | ||
| 1965 | + | ||
| 1966 | + A new command lives in a module in the :mod:`distutils.command` package. There | ||
| 1967 | + is a sample template in that directory called :file:`command_template`. Copy | ||
| 1968 | + this file to a new module with the same name as the new command you're | ||
| 1969 | + implementing. This module should implement a class with the same name as the | ||
| 1970 | + module (and the command). So, for instance, to create the command | ||
| 1971 | + ``peel_banana`` (so that users can run ``setup.py peel_banana``), you'd copy | ||
| 1972 | + :file:`command_template` to :file:`distutils/command/peel_banana.py`, then edit | ||
| 1973 | + it so that it's implementing the class :class:`peel_banana`, a subclass of | ||
| 1974 | + :class:`distutils.cmd.Command`. | ||
| 1975 | + | ||
| 1976 | + Subclasses of :class:`Command` must define the following methods. | ||
| 1977 | + | ||
| 1978 | + | ||
| 1979 | + .. method:: Command.initialize_options() | ||
| 1980 | + | ||
| 1981 | + Set default values for all the options that this command supports. Note that | ||
| 1982 | + these defaults may be overridden by other commands, by the setup script, by | ||
| 1983 | + config files, or by the command-line. Thus, this is not the place to code | ||
| 1984 | + dependencies between options; generally, :meth:`initialize_options` | ||
| 1985 | + implementations are just a bunch of ``self.foo = None`` assignments. | ||
| 1986 | + | ||
| 1987 | + | ||
| 1988 | + .. method:: Command.finalize_options() | ||
| 1989 | + | ||
| 1990 | + Set final values for all the options that this command supports. This is | ||
| 1991 | + always called as late as possible, ie. after any option assignments from the | ||
| 1992 | + command-line or from other commands have been done. Thus, this is the place | ||
| 1993 | + to to code option dependencies: if *foo* depends on *bar*, then it is safe to | ||
| 1994 | + set *foo* from *bar* as long as *foo* still has the same value it was | ||
| 1995 | + assigned in :meth:`initialize_options`. | ||
| 1996 | + | ||
| 1997 | + | ||
| 1998 | + .. method:: Command.run() | ||
| 1999 | + | ||
| 2000 | + A command's raison d'etre: carry out the action it exists to perform, controlled | ||
| 2001 | + by the options initialized in :meth:`initialize_options`, customized by other | ||
| 2002 | + commands, the setup script, the command-line, and config files, and finalized in | ||
| 2003 | + :meth:`finalize_options`. All terminal output and filesystem interaction should | ||
| 2004 | + be done by :meth:`run`. | ||
| 2005 | + | ||
| 2006 | + *sub_commands* formalizes the notion of a "family" of commands, eg. ``install`` | ||
| 2007 | + as the parent with sub-commands ``install_lib``, ``install_headers``, etc. The | ||
| 2008 | + parent of a family of commands defines *sub_commands* as a class attribute; it's | ||
| 2009 | + a list of 2-tuples ``(command_name, predicate)``, with *command_name* a string | ||
| 2010 | + and *predicate* a function, a string or None. *predicate* is a method of | ||
| 2011 | + the parent command that determines whether the corresponding command is | ||
| 2012 | + applicable in the current situation. (Eg. we ``install_headers`` is only | ||
| 2013 | + applicable if we have any C header files to install.) If *predicate* is None, | ||
| 2014 | + that command is always applicable. | ||
| 2015 | + | ||
| 2016 | + *sub_commands* is usually defined at the \*end\* of a class, because predicates | ||
| 2017 | + can be methods of the class, so they must already have been defined. The | ||
| 2018 | + canonical example is the :command:`install` command. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -146,8 +146,8 @@ commands. | |||
| 146 | 146 | Creating dumb built distributions | |
| 147 | 147 | ================================= | |
| 148 | 148 | ||
| 149 | - .. XXX Need to document absolute vs. prefix-relative packages here, but first | ||
| 150 | - I have to implement it! | ||
| 149 | + **\*\*** Need to document absolute vs. prefix-relative packages here, but first | ||
| 150 | + I have to implement it! **\*\*** | ||
| 151 | 151 | ||
| 152 | 152 | ||
| 153 | 153 | .. _creating-rpms: | |
@@ -241,8 +241,7 @@ tedious and error-prone, so it's usually best to put them in the setup | |||
| 241 | 241 | configuration file, :file:`setup.cfg`\ ---see section :ref:`setup-config`. If | |
| 242 | 242 | you distribute or package many Python module distributions, you might want to | |
| 243 | 243 | put options that apply to all of them in your personal Distutils configuration | |
| 244 | - file (:file:`~/.pydistutils.cfg`). If you want to temporarily disable | ||
| 245 | - this file, you can pass the --no-user-cfg option to setup.py. | ||
| 244 | + file (:file:`~/.pydistutils.cfg`). | ||
| 246 | 245 | ||
| 247 | 246 | There are three steps to building a binary RPM package, all of which are | |
| 248 | 247 | handled automatically by the Distutils: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,6 +48,50 @@ This command installs all (Python) scripts in the distribution. | |||
| 48 | 48 | .. % \label{clean-cmd} | |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | + .. _sdist-cmd: | ||
| 52 | + | ||
| 53 | + Creating a source distribution: the :command:`sdist` command | ||
| 54 | + ============================================================ | ||
| 55 | + | ||
| 56 | + **\*\*** fragment moved down from above: needs context! **\*\*** | ||
| 57 | + | ||
| 58 | + The manifest template commands are: | ||
| 59 | + | ||
| 60 | + +-------------------------------------------+-----------------------------------------------+ | ||
| 61 | + | Command | Description | | ||
| 62 | + +===========================================+===============================================+ | ||
| 63 | + | :command:`include pat1 pat2 ...` | include all files matching any of the listed | | ||
| 64 | + | | patterns | | ||
| 65 | + +-------------------------------------------+-----------------------------------------------+ | ||
| 66 | + | :command:`exclude pat1 pat2 ...` | exclude all files matching any of the listed | | ||
| 67 | + | | patterns | | ||
| 68 | + +-------------------------------------------+-----------------------------------------------+ | ||
| 69 | + | :command:`recursive-include dir pat1 pat2 | include all files under *dir* matching any of | | ||
| 70 | + | ...` | the listed patterns | | ||
| 71 | + +-------------------------------------------+-----------------------------------------------+ | ||
| 72 | + | :command:`recursive-exclude dir pat1 pat2 | exclude all files under *dir* matching any of | | ||
| 73 | + | ...` | the listed patterns | | ||
| 74 | + +-------------------------------------------+-----------------------------------------------+ | ||
| 75 | + | :command:`global-include pat1 pat2 ...` | include all files anywhere in the source tree | | ||
| 76 | + | | matching --- & any of the listed patterns | | ||
| 77 | + +-------------------------------------------+-----------------------------------------------+ | ||
| 78 | + | :command:`global-exclude pat1 pat2 ...` | exclude all files anywhere in the source tree | | ||
| 79 | + | | matching --- & any of the listed patterns | | ||
| 80 | + +-------------------------------------------+-----------------------------------------------+ | ||
| 81 | + | :command:`prune dir` | exclude all files under *dir* | | ||
| 82 | + +-------------------------------------------+-----------------------------------------------+ | ||
| 83 | + | :command:`graft dir` | include all files under *dir* | | ||
| 84 | + +-------------------------------------------+-----------------------------------------------+ | ||
| 85 | + | ||
| 86 | + The patterns here are Unix-style "glob" patterns: ``*`` matches any sequence of | ||
| 87 | + regular filename characters, ``?`` matches any single regular filename | ||
| 88 | + character, and ``[range]`` matches any of the characters in *range* (e.g., | ||
| 89 | + ``a-z``, ``a-zA-Z``, ``a-f0-9_.``). The definition of "regular filename | ||
| 90 | + character" is platform-specific: on Unix it is anything except slash; on Windows | ||
| 91 | + anything except backslash or colon. | ||
| 92 | + | ||
| 93 | + **\*\*** Windows support not there yet **\*\*** | ||
| 94 | + | ||
| 51 | 95 | .. % \section{Creating a built distribution: the | |
| 52 | 96 | .. % \protect\command{bdist} command family} | |
| 53 | 97 | .. % \label{bdist-cmds} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -233,6 +233,58 @@ With exactly the same source tree layout, this extension can be put in the | |||
| 233 | 233 | ext_modules=[Extension('foopkg.foo', ['foo.c'])], | |
| 234 | 234 | ) | |
| 235 | 235 | ||
| 236 | + Checking a package | ||
| 237 | + ================== | ||
| 238 | + | ||
| 239 | + The ``check`` command allows you to verify if your package meta-data | ||
| 240 | + meet the minimum requirements to build a distribution. | ||
| 241 | + | ||
| 242 | + To run it, just call it using your :file:`setup.py` script. If something is | ||
| 243 | + missing, ``check`` will display a warning. | ||
| 244 | + | ||
| 245 | + Let's take an example with a simple script:: | ||
| 246 | + | ||
| 247 | + from distutils.core import setup | ||
| 248 | + | ||
| 249 | + setup(name='foobar') | ||
| 250 | + | ||
| 251 | + Running the ``check`` command will display some warnings:: | ||
| 252 | + | ||
| 253 | + $ python setup.py check | ||
| 254 | + running check | ||
| 255 | + warning: check: missing required meta-data: version, url | ||
| 256 | + warning: check: missing meta-data: either (author and author_email) or | ||
| 257 | + (maintainer and maintainer_email) must be supplied | ||
| 258 | + | ||
| 259 | + | ||
| 260 | + If you use the reStructuredText syntax in the `long_description` field and | ||
| 261 | + `docutils <http://docutils.sourceforge.net/>`_ is installed you can check if | ||
| 262 | + the syntax is fine with the ``check`` command, using the `restructuredtext` | ||
| 263 | + option. | ||
| 264 | + | ||
| 265 | + For example, if the :file:`setup.py` script is changed like this:: | ||
| 266 | + | ||
| 267 | + from distutils.core import setup | ||
| 268 | + | ||
| 269 | + desc = """\ | ||
| 270 | + My description | ||
| 271 | + ============= | ||
| 272 | + | ||
| 273 | + This is the description of the ``foobar`` package. | ||
| 274 | + """ | ||
| 275 | + | ||
| 276 | + setup(name='foobar', version='1', author='tarek', | ||
| 277 | + author_email='tarek@ziade.org', | ||
| 278 | + url='http://example.com', long_description=desc) | ||
| 279 | + | ||
| 280 | + Where the long description is broken, ``check`` will be able to detect it | ||
| 281 | + by using the `docutils` parser:: | ||
| 282 | + | ||
| 283 | + $ pythontrunk setup.py check --restructuredtext | ||
| 284 | + running check | ||
| 285 | + warning: check: Title underline too short. (line 2) | ||
| 286 | + warning: check: Could not finish the parsing. | ||
| 287 | + | ||
| 236 | 288 | .. % \section{Multiple extension modules} | |
| 237 | 289 | .. % \label{multiple-ext} | |
| 238 | 290 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,8 +15,8 @@ want to modify existing commands; many simply add a few file extensions that | |||
| 15 | 15 | should be copied into packages in addition to :file:`.py` files as a | |
| 16 | 16 | convenience. | |
| 17 | 17 | ||
| 18 | - Most distutils command implementations are subclasses of the | ||
| 19 | - :class:`distutils.cmd.Command` class. New commands may directly inherit from | ||
| 18 | + Most distutils command implementations are subclasses of the :class:`Command` | ||
| 19 | + class from :mod:`distutils.cmd`. New commands may directly inherit from | ||
| 20 | 20 | :class:`Command`, while replacements often derive from :class:`Command` | |
| 21 | 21 | indirectly, directly subclassing the command they are replacing. Commands are | |
| 22 | 22 | required to derive from :class:`Command`. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -207,7 +207,7 @@ However, you can also include SWIG interface (:file:`.i`) files in the list; the | |||
| 207 | 207 | SWIG on the interface file and compile the resulting C/C++ file into your | |
| 208 | 208 | extension. | |
| 209 | 209 | ||
| 210 | - .. XXX SWIG support is rough around the edges and largely untested! | ||
| 210 | + **\*\*** SWIG support is rough around the edges and largely untested! **\*\*** | ||
| 211 | 211 | ||
| 212 | 212 | This warning notwithstanding, options to SWIG can be currently passed like | |
| 213 | 213 | this:: | |
@@ -326,7 +326,7 @@ include the location in ``library_dirs``:: | |||
| 326 | 326 | (Again, this sort of non-portable construct should be avoided if you intend to | |
| 327 | 327 | distribute your code.) | |
| 328 | 328 | ||
| 329 | - .. XXX Should mention clib libraries here or somewhere else! | ||
| 329 | + **\*\*** Should mention clib libraries here or somewhere else! **\*\*** | ||
| 330 | 330 | ||
| 331 | 331 | ||
| 332 | 332 | Other options | |
| Back | FazBrowse Home | New Git URL |
0 commit comments