Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 1 | \documentclass{howto} |
| 2 | \usepackage{ltxmarkup} |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 3 | \usepackage{times} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 4 | \usepackage{distutils} |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 5 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 6 | \title{Distributing Python Modules} |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 7 | |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 8 | \author{Greg Ward} |
| 9 | \authoraddress{E-mail: \email{gward@python.net}} |
| 10 | |
Greg Ward | e3cca26 | 2000-08-31 16:36:31 +0000 | [diff] [blame] | 11 | \makeindex |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 12 | |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 13 | \begin{document} |
| 14 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 15 | \maketitle |
Greg Ward | e3cca26 | 2000-08-31 16:36:31 +0000 | [diff] [blame] | 16 | \begin{abstract} |
| 17 | \noindent |
| 18 | This document describes the Python Distribution Utilities |
| 19 | (``Distutils'') from the module developer's point-of-view, describing |
| 20 | how to use the Distutils to make Python modules and extensions easily |
| 21 | available to a wider audience with very little overhead for |
| 22 | build/release/install mechanics. |
| 23 | \end{abstract} |
| 24 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 25 | \tableofcontents |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 26 | |
| 27 | \section{Introduction} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 28 | \label{intro} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 29 | |
| 30 | In the past, Python module developers have not had much infrastructure |
| 31 | support for distributing modules, nor have Python users had much support |
| 32 | for installing and maintaining third-party modules. With the |
| 33 | introduction of the Python Distribution Utilities (Distutils for short) |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 34 | in Python 1.6, this situation should start to improve. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 35 | |
| 36 | This document only covers using the Distutils to distribute your Python |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 37 | modules. Using the Distutils does not tie you to Python 1.6, though: |
| 38 | the Distutils work just fine with Python 1.5.2, and it is reasonable |
| 39 | (and expected to become commonplace) to expect users of Python 1.5.2 to |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 40 | download and install the Distutils separately before they can install |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 41 | your modules. Python 1.6 (or later) users, of course, won't have to add |
| 42 | anything to their Python installation in order to use the Distutils to |
| 43 | install third-party modules. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 44 | |
| 45 | This document concentrates on the role of developer/distributor: if |
Fred Drake | 01df453 | 2000-06-30 03:36:41 +0000 | [diff] [blame] | 46 | you're looking for information on installing Python modules, you |
| 47 | should refer to the \citetitle[../inst/inst.html]{Installing Python |
| 48 | Modules} manual. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 49 | |
| 50 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 51 | \section{Concepts \& Terminology} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 52 | \label{concepts} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 53 | |
| 54 | Using the Distutils is quite simple, both for module developers and for |
| 55 | users/administrators installing third-party modules. As a developer, |
| 56 | your responsibilites (apart from writing solid, well-documented and |
| 57 | well-tested code, of course!) are: |
| 58 | \begin{itemize} |
| 59 | \item write a setup script (\file{setup.py} by convention) |
| 60 | \item (optional) write a setup configuration file |
| 61 | \item create a source distribution |
| 62 | \item (optional) create one or more built (binary) distributions |
| 63 | \end{itemize} |
| 64 | Each of these tasks is covered in this document. |
| 65 | |
| 66 | Not all module developers have access to a multitude of platforms, so |
| 67 | it's not always feasible to expect them to create a multitude of built |
| 68 | distributions. It is hoped that a class of intermediaries, called |
Greg Ward | 19c67f8 | 2000-06-24 01:33:16 +0000 | [diff] [blame] | 69 | \emph{packagers}, will arise to address this need. Packagers will take |
| 70 | source distributions released by module developers, build them on one or |
| 71 | more platforms, and release the resulting built distributions. Thus, |
| 72 | users on the most popular platforms will be able to install most popular |
| 73 | Python module distributions in the most natural way for their platform, |
| 74 | without having to run a single setup script or compile a line of code. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 75 | |
| 76 | |
| 77 | \subsection{A simple example} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 78 | \label{simple-example} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 79 | |
| 80 | The setup script is usually quite simple, although since it's written in |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame^] | 81 | Python, there are no arbitrary limits to what you can do with |
| 82 | it.\footnote{But be careful about putting arbitrarily expensive |
| 83 | operations in your setup script; unlike, say, Autoconf-style configure |
| 84 | scripts, the setup script may be run multiple times in the course of |
| 85 | building and installing your module distribution. If you need to |
| 86 | insert potentially expensive processing steps into the Distutils |
| 87 | chain, see section~\ref{extending} on extending the Distutils.} If |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 88 | all you want to do is distribute a module called \module{foo}, contained |
| 89 | in a file \file{foo.py}, then your setup script can be as little as |
| 90 | this: |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 91 | \begin{verbatim} |
| 92 | from distutils.core import setup |
| 93 | setup (name = "foo", |
| 94 | version = "1.0", |
| 95 | py_modules = ["foo"]) |
| 96 | \end{verbatim} |
Greg Ward | 370248d | 2000-06-24 01:45:47 +0000 | [diff] [blame] | 97 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 98 | Some observations: |
| 99 | \begin{itemize} |
Greg Ward | 370248d | 2000-06-24 01:45:47 +0000 | [diff] [blame] | 100 | \item most information that you supply to the Distutils is supplied as |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 101 | keyword arguments to the \function{setup()} function |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 102 | \item those keyword arguments fall into two categories: package |
| 103 | meta-data (name, version number) and information about what's in the |
Greg Ward | 370248d | 2000-06-24 01:45:47 +0000 | [diff] [blame] | 104 | package (a list of pure Python modules, in this case) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 105 | \item modules are specified by module name, not filename (the same will |
| 106 | hold true for packages and extensions) |
| 107 | \item it's recommended that you supply a little more meta-data, in |
| 108 | particular your name, email address and a URL for the project |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame^] | 109 | (see section~\ref{setup-script} for an example) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 110 | \end{itemize} |
| 111 | |
Greg Ward | 370248d | 2000-06-24 01:45:47 +0000 | [diff] [blame] | 112 | To create a source distribution for this module, you would create a |
| 113 | setup script, \file{setup.py}, containing the above code, and run: |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 114 | \begin{verbatim} |
| 115 | python setup.py sdist |
| 116 | \end{verbatim} |
| 117 | which will create an archive file (e.g., tarball on Unix, zip file on |
| 118 | Windows) containing your setup script, \file{setup.py}, and your module, |
| 119 | \file{foo.py}. The archive file will be named \file{Foo-1.0.tar.gz} (or |
| 120 | \file{.zip}), and will unpack into a directory \file{Foo-1.0}. |
| 121 | |
| 122 | If an end-user wishes to install your \module{foo} module, all she has |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 123 | to do is download \file{Foo-1.0.tar.gz} (or \file{.zip}), unpack it, |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 124 | and---from the \file{Foo-1.0} directory---run |
| 125 | \begin{verbatim} |
| 126 | python setup.py install |
| 127 | \end{verbatim} |
| 128 | which will ultimately copy \file{foo.py} to the appropriate directory |
| 129 | for third-party modules in their Python installation. |
| 130 | |
| 131 | This simple example demonstrates some fundamental concepts of the |
| 132 | Distutils: first, both developers and installers have the same basic |
| 133 | user interface, i.e. the setup script. The difference is which |
| 134 | Distutils \emph{commands} they use: the \command{sdist} command is |
| 135 | almost exclusively for module developers, while \command{install} is |
| 136 | more often for installers (although most developers will want to install |
| 137 | their own code occasionally). |
| 138 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 139 | If you want to make things really easy for your users, you can create |
| 140 | one or more built distributions for them. For instance, if you are |
| 141 | running on a Windows machine, and want to make things easy for other |
| 142 | Windows users, you can create an executable installer (the most |
| 143 | appropriate type of built distribution for this platform) with the |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 144 | \command{bdist\_wininst} command. For example: |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 145 | \begin{verbatim} |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 146 | python setup.py bdist_wininst |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 147 | \end{verbatim} |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 148 | will create an executable installer, \file{Foo-1.0.win32.exe}, in the |
| 149 | current directory. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 150 | |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 151 | \XXX{not implemented yet} |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 152 | (Another way to create executable installers for Windows is with the |
| 153 | \command{bdist\_wise} command, which uses Wise---the commercial |
| 154 | installer-generator used to create Python's own installer---to create |
| 155 | the installer. Wise-based installers are more appropriate for large, |
| 156 | industrial-strength applications that need the full capabilities of a |
| 157 | ``real'' installer. \command{bdist\_wininst} creates a self-extracting |
| 158 | zip file with a minimal user interface, which is enough for small- to |
| 159 | medium-sized module collections. You'll need to have version XXX of |
Greg Ward | 370248d | 2000-06-24 01:45:47 +0000 | [diff] [blame] | 160 | Wise installed on your system for the \command{bdist\_wise} command to |
| 161 | work; it's available from \url{http://foo/bar/baz}.) |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 162 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame^] | 163 | Currently (Distutils 0.9.2), the are only other useful built |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 164 | distribution format is RPM, implemented by the \command{bdist\_rpm} |
| 165 | command. For example, the following command will create an RPM file |
| 166 | called \file{Foo-1.0.noarch.rpm}: |
| 167 | \begin{verbatim} |
| 168 | python setup.py bdist_rpm |
| 169 | \end{verbatim} |
| 170 | (This uses the \command{rpm} command, so has to be run on an RPM-based |
| 171 | system such as Red Hat Linux, SuSE Linux, or Mandrake Linux.) |
| 172 | |
| 173 | You can find out what distribution formats are available at any time by |
| 174 | running |
| 175 | \begin{verbatim} |
| 176 | python setup.py bdist --help-formats |
| 177 | \end{verbatim} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 178 | |
| 179 | |
| 180 | \subsection{General Python terminology} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 181 | \label{python-terms} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 182 | |
| 183 | If you're reading this document, you probably have a good idea of what |
| 184 | modules, extensions, and so forth are. Nevertheless, just to be sure |
| 185 | that everyone is operating from a common starting point, we offer the |
| 186 | following glossary of common Python terms: |
| 187 | \begin{description} |
| 188 | \item[module] the basic unit of code reusability in Python: a block of |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 189 | code imported by some other code. Three types of modules concern us |
| 190 | here: pure Python modules, extension modules, and packages. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 191 | \item[pure Python module] a module written in Python and contained in a |
| 192 | single \file{.py} file (and possibly associated \file{.pyc} and/or |
| 193 | \file{.pyo} files). Sometimes referred to as a ``pure module.'' |
| 194 | \item[extension module] a module written in the low-level language of |
| 195 | the Python implemention: C/C++ for CPython, Java for JPython. |
| 196 | Typically contained in a single dynamically loadable pre-compiled |
| 197 | file, e.g. a shared object (\file{.so}) file for CPython extensions on |
| 198 | Unix, a DLL (given the \file{.pyd} extension) for CPython extensions |
Greg Ward | 1bbe329 | 2000-06-25 03:14:13 +0000 | [diff] [blame] | 199 | on Windows, or a Java class file for JPython extensions. (Note that |
| 200 | currently, the Distutils only handles C/C++ extensions for CPython.) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 201 | \item[package] a module that contains other modules; typically contained |
| 202 | in a directory in the filesystem and distinguished from other |
| 203 | directories by the presence of a file \file{\_\_init\_\_.py}. |
Greg Ward | 6153fa1 | 2000-05-26 02:24:28 +0000 | [diff] [blame] | 204 | \item[root package] the root of the hierarchy of packages. (This isn't |
| 205 | really a package, since it doesn't have an \file{\_\_init\_\_.py} |
| 206 | file. But we have to call it something.) The vast majority of the |
| 207 | standard library is in the root package, as are many small, standalone |
| 208 | third-party modules that don't belong to a larger module collection. |
| 209 | Unlike regular packages, modules in the root package can be found in |
| 210 | many directories: in fact, every directory listed in \code{sys.path} |
| 211 | can contribute modules to the root package. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 212 | \end{description} |
| 213 | |
| 214 | |
| 215 | \subsection{Distutils-specific terminology} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 216 | \label{distutils-term} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 217 | |
| 218 | The following terms apply more specifically to the domain of |
| 219 | distributing Python modules using the Distutils: |
| 220 | \begin{description} |
| 221 | \item[module distribution] a collection of Python modules distributed |
| 222 | together as a single downloadable resource and meant to be installed |
| 223 | \emph{en masse}. Examples of some well-known module distributions are |
| 224 | Numeric Python, PyXML, PIL (the Python Imaging Library), or |
| 225 | mxDateTime. (This would be called a \emph{package}, except that term |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 226 | is already taken in the Python context: a single module distribution |
| 227 | may contain zero, one, or many Python packages.) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 228 | \item[pure module distribution] a module distribution that contains only |
| 229 | pure Python modules and packages. Sometimes referred to as a ``pure |
| 230 | distribution.'' |
| 231 | \item[non-pure module distribution] a module distribution that contains |
| 232 | at least one extension module. Sometimes referred to as a ``non-pure |
| 233 | distribution.'' |
| 234 | \item[distribution root] the top-level directory of your source tree (or |
| 235 | source distribution); the directory where \file{setup.py} exists and |
| 236 | is run from |
| 237 | \end{description} |
| 238 | |
| 239 | |
| 240 | \section{Writing the Setup Script} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 241 | \label{setup-script} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 242 | |
| 243 | The setup script is the centre of all activity in building, |
| 244 | distributing, and installing modules using the Distutils. The main |
| 245 | purpose of the setup script is to describe your module distribution to |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 246 | the Distutils, so that the various commands that operate on your modules |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 247 | do the right thing. As we saw in section~\ref{simple-example} above, |
| 248 | the setup script consists mainly of a call to \function{setup()}, and |
Greg Ward | 1bbe329 | 2000-06-25 03:14:13 +0000 | [diff] [blame] | 249 | most information supplied to the Distutils by the module developer is |
| 250 | supplied as keyword arguments to \function{setup()}. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 251 | |
| 252 | Here's a slightly more involved example, which we'll follow for the next |
| 253 | couple of sections: the Distutils' own setup script. (Keep in mind that |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 254 | although the Distutils are included with Python 1.6 and later, they also |
| 255 | have an independent existence so that Python 1.5.2 users can use them to |
| 256 | install other module distributions. The Distutils' own setup script, |
| 257 | shown here, is used to install the package into Python 1.5.2.) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 258 | |
| 259 | \begin{verbatim} |
| 260 | #!/usr/bin/env python |
| 261 | |
| 262 | from distutils.core import setup |
| 263 | |
| 264 | setup (name = "Distutils", |
| 265 | version = "1.0", |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 266 | description = "Python Distribution Utilities", |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 267 | author = "Greg Ward", |
| 268 | author_email = "gward@python.net", |
| 269 | url = "http://www.python.org/sigs/distutils-sig/", |
| 270 | |
| 271 | packages = ['distutils', 'distutils.command'], |
| 272 | ) |
| 273 | \end{verbatim} |
| 274 | There are only two differences between this and the trivial one-file |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 275 | distribution presented in section~\ref{simple-example}: more |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 276 | meta-data, and the specification of pure Python modules by package, |
| 277 | rather than by module. This is important since the Distutils consist of |
| 278 | a couple of dozen modules split into (so far) two packages; an explicit |
| 279 | list of every module would be tedious to generate and difficult to |
| 280 | maintain. |
| 281 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 282 | Note that any pathnames (files or directories) supplied in the setup |
| 283 | script should be written using the Unix convention, i.e. |
| 284 | slash-separated. The Distutils will take care of converting this |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 285 | platform-neutral representation into whatever is appropriate on your |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 286 | current platform before actually using the pathname. This makes your |
| 287 | setup script portable across operating systems, which of course is one |
| 288 | of the major goals of the Distutils. In this spirit, all pathnames in |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 289 | this document are slash-separated (Mac OS programmers should keep in |
| 290 | mind that the \emph{absence} of a leading slash indicates a relative |
| 291 | path, the opposite of the Mac OS convention with colons). |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 292 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 293 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 294 | \subsection{Listing whole packages} |
| 295 | \label{listing-packages} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 296 | |
| 297 | The \option{packages} option tells the Distutils to process (build, |
| 298 | distribute, install, etc.) all pure Python modules found in each package |
| 299 | mentioned in the \option{packages} list. In order to do this, of |
| 300 | course, there has to be a correspondence between package names and |
| 301 | directories in the filesystem. The default correspondence is the most |
Greg Ward | 1ecc251 | 2000-04-19 22:36:24 +0000 | [diff] [blame] | 302 | obvious one, i.e. package \module{distutils} is found in the directory |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 303 | \file{distutils} relative to the distribution root. Thus, when you say |
| 304 | \code{packages = ['foo']} in your setup script, you are promising that |
| 305 | the Distutils will find a file \file{foo/\_\_init\_\_.py} (which might |
| 306 | be spelled differently on your system, but you get the idea) relative to |
| 307 | the directory where your setup script lives. (If you break this |
| 308 | promise, the Distutils will issue a warning but process the broken |
| 309 | package anyways.) |
| 310 | |
| 311 | If you use a different convention to lay out your source directory, |
| 312 | that's no problem: you just have to supply the \option{package\_dir} |
| 313 | option to tell the Distutils about your convention. For example, say |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 314 | you keep all Python source under \file{lib}, so that modules in the |
| 315 | ``root package'' (i.e., not in any package at all) are right in |
| 316 | \file{lib}, modules in the \module{foo} package are in \file{lib/foo}, |
| 317 | and so forth. Then you would put |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 318 | \begin{verbatim} |
| 319 | package_dir = {'': 'lib'} |
| 320 | \end{verbatim} |
| 321 | in your setup script. (The keys to this dictionary are package names, |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 322 | and an empty package name stands for the root package. The values are |
| 323 | directory names relative to your distribution root.) In this case, when |
| 324 | you say \code{packages = ['foo']}, you are promising that the file |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 325 | \file{lib/foo/\_\_init\_\_.py} exists. |
| 326 | |
Greg Ward | 1ecc251 | 2000-04-19 22:36:24 +0000 | [diff] [blame] | 327 | Another possible convention is to put the \module{foo} package right in |
| 328 | \file{lib}, the \module{foo.bar} package in \file{lib/bar}, etc. This |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 329 | would be written in the setup script as |
| 330 | \begin{verbatim} |
| 331 | package_dir = {'foo': 'lib'} |
| 332 | \end{verbatim} |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 333 | A \code{\var{package}: \var{dir}} entry in the \option{package\_dir} |
| 334 | dictionary implicitly applies to all packages below \var{package}, so |
| 335 | the \module{foo.bar} case is automatically handled here. In this |
| 336 | example, having \code{packages = ['foo', 'foo.bar']} tells the Distutils |
| 337 | to look for \file{lib/\_\_init\_\_.py} and |
| 338 | \file{lib/bar/\_\_init\_\_.py}. (Keep in mind that although |
| 339 | \option{package\_dir} applies recursively, you must explicitly list all |
| 340 | packages in \option{packages}: the Distutils will \emph{not} recursively |
| 341 | scan your source tree looking for any directory with an |
| 342 | \file{\_\_init\_\_.py} file.) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 343 | |
| 344 | |
| 345 | \subsection{Listing individual modules} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 346 | \label{listing-modules} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 347 | |
| 348 | For a small module distribution, you might prefer to list all modules |
| 349 | rather than listing packages---especially the case of a single module |
| 350 | that goes in the ``root package'' (i.e., no package at all). This |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 351 | simplest case was shown in section~\ref{simple-example}; here is a |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 352 | slightly more involved example: |
| 353 | \begin{verbatim} |
| 354 | py_modules = ['mod1', 'pkg.mod2'] |
| 355 | \end{verbatim} |
| 356 | This describes two modules, one of them in the ``root'' package, the |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 357 | other in the \module{pkg} package. Again, the default package/directory |
| 358 | layout implies that these two modules can be found in \file{mod1.py} and |
| 359 | \file{pkg/mod2.py}, and that \file{pkg/\_\_init\_\_.py} exists as well. |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 360 | And again, you can override the package/directory correspondence using |
| 361 | the \option{package\_dir} option. |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 362 | |
| 363 | |
| 364 | \subsection{Describing extension modules} |
Greg Ward | 1365a30 | 2000-08-31 14:47:05 +0000 | [diff] [blame] | 365 | \label{describing-extensions} |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 366 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 367 | Just as writing Python extension modules is a bit more complicated than |
| 368 | writing pure Python modules, describing them to the Distutils is a bit |
| 369 | more complicated. Unlike pure modules, it's not enough just to list |
| 370 | modules or packages and expect the Distutils to go out and find the |
| 371 | right files; you have to specify the extension name, source file(s), and |
| 372 | any compile/link requirements (include directories, libraries to link |
| 373 | with, etc.). |
| 374 | |
| 375 | All of this is done through another keyword argument to |
| 376 | \function{setup()}, the \option{extensions} option. \option{extensions} |
| 377 | is just a list of \class{Extension} instances, each of which describes a |
| 378 | single extension module. Suppose your distribution includes a single |
| 379 | extension, called \module{foo} and implemented by \file{foo.c}. If no |
| 380 | additional instructions to the compiler/linker are needed, describing |
| 381 | this extension is quite simple: |
| 382 | \begin{verbatim} |
| 383 | Extension("foo", ["foo.c"]) |
| 384 | \end{verbatim} |
| 385 | The \class{Extension} class can be imported from |
| 386 | \module{distutils.core}, along with \function{setup()}. Thus, the setup |
| 387 | script for a module distribution that contains only this one extension |
| 388 | and nothing else might be: |
| 389 | \begin{verbatim} |
| 390 | from distutils.core import setup, Extension |
| 391 | setup(name = "foo", version = "1.0", |
| 392 | extensions = [Extension("foo", ["foo.c"])]) |
| 393 | \end{verbatim} |
| 394 | |
| 395 | The \class{Extension} class (actually, the underlying extension-building |
| 396 | machinery implemented by the \command{built\_ext} command) supports a |
| 397 | great deal of flexibility in describing Python extensions, which is |
| 398 | explained in the following sections. |
| 399 | |
| 400 | |
| 401 | \subsubsection{Extension names and packages} |
| 402 | |
| 403 | The first argument to the \class{Extension} constructor is always the |
| 404 | name of the extension, including any package names. For example, |
| 405 | \begin{verbatim} |
| 406 | Extension("foo", ["src/foo1.c", "src/foo2.c"]) |
| 407 | \end{verbatim} |
| 408 | describes an extension that lives in the root package, while |
| 409 | \begin{verbatim} |
| 410 | Extension("pkg.foo", ["src/foo1.c", "src/foo2.c"]) |
| 411 | \end{verbatim} |
| 412 | describes the same extension in the \module{pkg} package. The source |
| 413 | files and resulting object code are identical in both cases; the only |
| 414 | difference is where in the filesystem (and therefore where in Python's |
| 415 | namespace hierarchy) the resulting extension lives. |
| 416 | |
| 417 | If you have a number of extensions all in the same package (or all under |
| 418 | the same base package), use the \option{ext\_package} keyword argument |
| 419 | to \function{setup()}. For example, |
| 420 | \begin{verbatim} |
| 421 | setup(... |
| 422 | ext_package = "pkg", |
| 423 | extensions = [Extension("foo", ["foo.c"]), |
| 424 | Extension("subpkg.bar", ["bar.c"])] |
| 425 | ) |
| 426 | \end{verbatim} |
| 427 | will compile \file{foo.c} to the extension \module{pkg.foo}, and |
| 428 | \file{bar.c} to \module{pkg.subpkg.bar}. |
| 429 | |
| 430 | |
| 431 | \subsubsection{Extension source files} |
| 432 | |
| 433 | The second argument to the \class{Extension} constructor is a list of |
| 434 | source files. Since the Distutils currently only support C/C++ |
| 435 | extensions, these are normally C/C++ source files. (Be sure to use |
| 436 | appropriate extensions to distinguish C++ source files: \file{.cc} and |
| 437 | \file{.cpp} seem to be recognized by both Unix and Windows compilers.) |
| 438 | |
| 439 | However, you can also include SWIG interface (\file{.i}) files in the |
| 440 | list; the \command{build\_ext} command knows how to deal with SWIG |
| 441 | extensions: it will run SWIG on the interface file and compile the |
| 442 | resulting C/C++ file into your extension. |
| 443 | |
| 444 | \XXX{SWIG support is rough around the edges and largely untested; |
| 445 | especially SWIG support of C++ extensions! Explain in more detail |
| 446 | here when the interface firms up.} |
| 447 | |
| 448 | On some platforms, you can include non-source files that are processed |
| 449 | by the compiler and included in your extension. Currently, this just |
| 450 | means Windows resource files for Visual C++. \XXX{get more detail on |
| 451 | this feature from Thomas Heller!} |
| 452 | |
| 453 | |
| 454 | \subsubsection{Preprocessor options} |
| 455 | |
| 456 | Three optional arguments to \class{Extension} will help if you need to |
| 457 | specify include directories to search or preprocessor macros to |
| 458 | define/undefine: \code{include\_dirs}, \code{define\_macros}, and |
| 459 | \code{undef\_macros}. |
| 460 | |
| 461 | For example, if your extension requires header files in the |
| 462 | \file{include} directory under your distribution root, use the |
| 463 | \code{include\_dirs} option: |
| 464 | \begin{verbatim} |
| 465 | Extension("foo", ["foo.c"], include_dirs=["include"]) |
| 466 | \end{verbatim} |
| 467 | |
| 468 | You can specify absolute directories there; if you know that your |
| 469 | extension will only be built on Unix systems with X11R6 installed to |
| 470 | \file{/usr}, you can get away with |
| 471 | \begin{verbatim} |
| 472 | Extension("foo", ["foo.c"], include_dirs=["/usr/include/X11"]) |
| 473 | \end{verbatim} |
| 474 | You should avoid this sort of non-portable usage if you plan to |
| 475 | distribute your code: it's probably better to write your code to include |
| 476 | (e.g.) \code{<X11/Xlib.h>}. |
| 477 | |
| 478 | If you need to include header files from some other Python extension, |
| 479 | you can take advantage of the fact that the Distutils install extension |
| 480 | header files in a consistent way. For example, the Numerical Python |
| 481 | header files are installed (on a standard Unix installation) to |
| 482 | \file{/usr/local/include/python1.5/Numerical}. (The exact location will |
| 483 | differ according to your platform and Python installation.) Since the |
| 484 | Python include directory---\file{/usr/local/include/python1.5} in this |
| 485 | case---is always included in the search path when building Python |
| 486 | extensions, the best approach is to include (e.g.) |
| 487 | \code{<Numerical/arrayobject.h>}. If you insist on putting the |
| 488 | \file{Numerical} include directory right into your header search path, |
| 489 | though, you can find that directory using the Distutils |
| 490 | \module{sysconfig} module: |
| 491 | \begin{verbatim} |
| 492 | from distutils.sysconfig import get_python_inc |
| 493 | incdir = os.path.join(get_python_inc(plat_specific=1), "Numerical") |
| 494 | setup(..., |
| 495 | Extension(..., include_dirs=[incdir])) |
| 496 | \end{verbatim} |
| 497 | Even though this is quite portable---it will work on any Python |
| 498 | installation, regardless of platform---it's probably easier to just |
| 499 | write your C code in the sensible way. |
| 500 | |
| 501 | You can define and undefine pre-processor macros with the |
| 502 | \code{define\_macros} and \code{undef\_macros} options. |
| 503 | \code{define\_macros} takes a list of \code{(name, value)} tuples, where |
| 504 | \code{name} is the name of the macro to define (a string) and |
| 505 | \code{value} is its value: either a string or \code{None}. (Defining a |
| 506 | macro \code{FOO} to \code{None} is the equivalent of a bare |
| 507 | \code{\#define FOO} in your C source: with most compilers, this sets |
| 508 | \code{FOO} to the string \code{1}.) \code{undef\_macros} is just |
| 509 | a list of macros to undefine. |
| 510 | |
| 511 | For example: |
| 512 | \begin{verbatim} |
| 513 | Extension(..., |
| 514 | define_macros=[('NDEBUG', '1')], |
| 515 | ('HAVE_STRFTIME', None), |
| 516 | undef_macros=['HAVE_FOO', 'HAVE_BAR']) |
| 517 | \end{verbatim} |
| 518 | is the equivalent of having this at the top of every C source file: |
| 519 | \begin{verbatim} |
| 520 | #define NDEBUG 1 |
| 521 | #define HAVE_STRFTIME |
| 522 | #undef HAVE_FOO |
| 523 | #undef HAVE_BAR |
| 524 | \end{verbatim} |
| 525 | |
| 526 | |
| 527 | \subsubsection{Library options} |
| 528 | |
| 529 | You can also specify the libraries to link against when building your |
| 530 | extension, and the directories to search for those libraries. The |
| 531 | \code{libraries} option is a list of libraries to link against, |
| 532 | \code{library\_dirs} is a list of directories to search for libraries at |
| 533 | link-time, and \code{runtime\_library\_dirs} is a list of directories to |
| 534 | search for shared (dynamically loaded) libraries at run-time. |
| 535 | |
| 536 | For example, if you need to link against libraries known to be in the |
| 537 | standard library search path on target systems |
| 538 | \begin{verbatim} |
| 539 | Extension(..., |
| 540 | libraries=["gdbm", "readline"]) |
| 541 | \end{verbatim} |
| 542 | |
| 543 | If you need to link with libraries in a non-standard location, you'll |
| 544 | have to include the location in \code{library\_dirs}: |
| 545 | \begin{verbatim} |
| 546 | Extension(..., |
| 547 | library_dirs=["/usr/X11R6/lib"], |
| 548 | libraries=["X11", "Xt"]) |
| 549 | \end{verbatim} |
| 550 | (Again, this sort of non-portable construct should be avoided if you |
| 551 | intend to distribute your code.) |
| 552 | |
| 553 | \XXX{still undocumented: extra\_objects, extra\_compile\_args, |
| 554 | extra\_link\_args, export\_symbols---none of which are frequently |
| 555 | needed, some of which might be completely unnecessary!} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 556 | |
| 557 | |
| 558 | \section{Writing the Setup Configuration File} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 559 | \label{setup-config} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 560 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 561 | Often, it's not possible to write down everything needed to build a |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame^] | 562 | distribution \emph{a priori}: you may need to get some information from |
| 563 | the user, or from the user's system, in order to proceed. As long as |
| 564 | that information is fairly simple---a list of directories to search for |
| 565 | C header files or libraries, for example---then providing a |
| 566 | configuration file, \file{setup.cfg}, for users to edit is a cheap and |
| 567 | easy way to solicit it. Configuration files also let you provide |
| 568 | default values for any command option, which the installer can then |
| 569 | override either on the command-line or by editing the config file. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 570 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame^] | 571 | (If you have more advanced needs, such as determining which extensions |
| 572 | to build based on what capabilities are present on the target system, |
| 573 | then you need the Distutils ``auto-configuration'' facility. This |
| 574 | started to appear in Distutils 0.9 but, as of this writing, isn't mature |
| 575 | or stable enough yet for real-world use.) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 576 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame^] | 577 | \XXX{should reference description of distutils config files in |
| 578 | ``Installing'' manual here} |
| 579 | |
| 580 | The setup configuration file is a useful middle-ground between the setup |
| 581 | script---which, ideally, would be opaque to installers\footnote{This |
| 582 | ideal probably won't be achieved until auto-configuration is fully |
| 583 | supported by the Distutils.}---and the command-line to the setup |
| 584 | script, which is outside of your control and entirely up to the |
| 585 | installer. In fact, \file{setup.cfg} (and any other Distutils |
| 586 | configuration files present on the target system) are processed after |
| 587 | the contents of the setup script, but before the command-line. This has |
| 588 | several useful consequences: |
| 589 | \begin{itemize} |
| 590 | \item installers can override some of what you put in \file{setup.py} by |
| 591 | editing \file{setup.cfg} |
| 592 | \item you can provide non-standard defaults for options that are not |
| 593 | easily set in \file{setup.py} |
| 594 | \item installers can override anything in \file{setup.cfg} using the |
| 595 | command-line options to \file{setup.py} |
| 596 | \end{itemize} |
| 597 | |
| 598 | The basic syntax of the configuration file is simple: |
| 599 | \begin{verbatim} |
| 600 | [command] |
| 601 | option=value |
| 602 | ... |
| 603 | \end{verbatim} |
| 604 | where \var{command} is one of the Distutils commands (e.g. |
| 605 | \command{build\_py}, \command{install}), and \var{option} is one of the |
| 606 | options that command supports. Any number of options can be supplied |
| 607 | for each command, and any number of command sections can be included in |
| 608 | the file. Blank lines are ignored, as are comments (from a \verb+#+ |
| 609 | character to end-of-line). Long option values can be split across |
| 610 | multiple lines simply by indenting the continuation lines. |
| 611 | |
| 612 | You can find out the list of options supported by a particular command |
| 613 | with the universal \longprogramopt{help} option, e.g. |
| 614 | \begin{verbatim} |
| 615 | > python setup.py --help build_ext |
| 616 | [...] |
| 617 | Options for 'build_ext' command: |
| 618 | --build-lib (-b) directory for compiled extension modules |
| 619 | --build-temp (-t) directory for temporary files (build by-products) |
| 620 | --inplace (-i) ignore build-lib and put compiled extensions into the |
| 621 | source directory alongside your pure Python modules |
| 622 | --include-dirs (-I) list of directories to search for header files |
| 623 | --define (-D) C preprocessor macros to define |
| 624 | --undef (-U) C preprocessor macros to undefine |
| 625 | [...] |
| 626 | \end{verbatim} |
| 627 | Or consult section \ref{reference} of this document (the command |
| 628 | reference). |
| 629 | |
| 630 | Note that an option spelled \longprogramopt{foo-bar} on the command-line |
| 631 | is spelled \option{foo\_bar} in configuration files. |
| 632 | |
| 633 | For example, say you want your extensions to be built |
| 634 | ``in-place''---that is, you have an extension \module{pkg.ext}, and you |
| 635 | want the compiled extension file (\file{ext.so} on Unix, say) to be put |
| 636 | in the same source directory as your pure Python modules |
| 637 | \module{pkg.mod1} and \module{pkg.mod2}. You can always use the |
| 638 | \longprogramopt{inplace} option on the command-line to ensure this: |
| 639 | \begin{verbatim} |
| 640 | python setup.py build_ext --inplace |
| 641 | \end{verbatim} |
| 642 | But this requires that you always specify the \command{build\_ext} |
| 643 | command explicitly, and remember to provide \longprogramopt{inplace}. |
| 644 | An easier way is to ``set and forget'' this option, by encoding it in |
| 645 | \file{setup.cfg}, the configuration file for this distribution: |
| 646 | \begin{verbatim} |
| 647 | [build_ext] |
| 648 | inplace=1 |
| 649 | \end{verbatim} |
| 650 | This will affect all builds of this module distribution, whether or not |
| 651 | you explcitly specify \command{build\_ext}. If you include |
| 652 | \file{setup.cfg} in your source distribution, it will also affect |
| 653 | end-user builds---which is probably a bad idea for this option, since |
| 654 | always building extensions in-place would break installation of the |
| 655 | module distribution. In certain peculiar cases, though, modules are |
| 656 | built right in their installation directory, so this is conceivably a |
| 657 | useful ability. (Distributing extensions that expect to be built in |
| 658 | their installation directory is almost always a bad idea, though.) |
| 659 | |
| 660 | Another example: certain commands take a lot of options that don't |
| 661 | change from run-to-run; for example, \command{bdist\_rpm} needs to know |
| 662 | everything required to generate a ``spec'' file for creating an RPM |
| 663 | distribution. Some of this information comes from the setup script, and |
| 664 | some is automatically generated by the Distutils (such as the list of |
| 665 | files installed). But some of it has to be supplied as options to |
| 666 | \command{bdist\_rpm}, which would be very tedious to do on the |
| 667 | command-line for every run. Hence, here is a snippet from the |
| 668 | Distutils' own \file{setup.cfg}: |
| 669 | \begin{verbatim} |
| 670 | [bdist_rpm] |
| 671 | release = 1 |
| 672 | packager = Greg Ward <gward@python.net> |
| 673 | doc_files = CHANGES.txt |
| 674 | README.txt |
| 675 | USAGE.txt |
| 676 | doc/ |
| 677 | examples/ |
| 678 | \end{verbatim} |
| 679 | Note that the \option{doc\_files} option is simply a |
| 680 | whitespace-separated string split across multiple lines for readability. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 681 | |
| 682 | |
| 683 | \section{Creating a Source Distribution} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 684 | \label{source-dist} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 685 | |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 686 | As shown in section~\ref{simple-example}, you use the |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 687 | \command{sdist} command to create a source distribution. In the |
| 688 | simplest case, |
| 689 | \begin{verbatim} |
| 690 | python setup.py sdist |
| 691 | \end{verbatim} |
Greg Ward | 19c67f8 | 2000-06-24 01:33:16 +0000 | [diff] [blame] | 692 | (assuming you haven't specified any \command{sdist} options in the setup |
| 693 | script or config file), \command{sdist} creates the archive of the |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 694 | default format for the current platform. The default formats are: |
| 695 | \begin{tableii}{ll}{textrm}% |
| 696 | {Platform}{Default archive format for source distributions} |
| 697 | \lineii{Unix}{gzipped tar file (\file{.tar.gz})} |
| 698 | \lineii{Windows}{zip file} |
| 699 | \end{tableii} |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 700 | You can specify as many formats as you like using the |
| 701 | \longprogramopt{formats} option, for example: |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 702 | \begin{verbatim} |
| 703 | python setup.py sdist --formats=gztar,zip |
| 704 | \end{verbatim} |
| 705 | to create a gzipped tarball and a zip file. The available formats are: |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 706 | \begin{tableiii}{l|l|c}{code}% |
| 707 | {Format}{Description}{Notes} |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame^] | 708 | \lineiii{zip}{zip file (\file{.zip})}{(1),(2)} |
| 709 | \lineiii{gztar}{gzip'ed tar file (\file{.tar.gz})}{(3),(4)} |
| 710 | \lineiii{bztar}{bzip2'ed tar file (\file{.tar.gz})}{(4)} |
| 711 | \lineiii{ztar}{compressed tar file (\file{.tar.Z})}{(4)} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 712 | \lineiii{tar}{tar file (\file{.tar})}{} |
| 713 | \end{tableiii} |
| 714 | |
| 715 | \noindent Notes: |
| 716 | \begin{description} |
| 717 | \item[(1)] default on Windows |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame^] | 718 | \item[(2)] under both Unix and Windows, requires either external |
| 719 | Info-ZIP utility \emph{or} the \module{zipfile} module |
| 720 | \item[(3)] default on Unix |
| 721 | \item[(4)] requires external utilities: \program{tar} and possibly one |
| 722 | of \program{gzip}, \program{bzip2}, or \program{compress} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 723 | \end{description} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 724 | |
| 725 | |
| 726 | \subsection{The manifest and manifest template} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 727 | \label{manifest} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 728 | |
| 729 | Without any additional information, the \command{sdist} command puts a |
| 730 | minimal set of files into the source distribution: |
| 731 | \begin{itemize} |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 732 | \item all Python source files implied by the \option{py\_modules} and |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 733 | \option{packages} options |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 734 | \item all C source files mentioned in the \option{ext\_modules} or |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 735 | \option{libraries} options (\XXX{getting C library sources currently |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 736 | broken -- no get\_source\_files() method in build\_clib.py!}) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 737 | \item anything that looks like a test script: \file{test/test*.py} |
| 738 | (currently, the Distutils don't do anything with test scripts except |
| 739 | include them in source distributions, but in the future there will be |
| 740 | a standard for testing Python module distributions) |
| 741 | \item \file{README.txt} (or \file{README}) and \file{setup.py} |
| 742 | \end{itemize} |
| 743 | Sometimes this is enough, but usually you will want to specify |
| 744 | additional files to distribute. The typical way to do this is to write |
| 745 | a \emph{manifest template}, called \file{MANIFEST.in} by default. The |
| 746 | \command{sdist} command processes this template and generates a manifest |
| 747 | file, \file{MANIFEST}. (If you prefer, you can skip the manifest |
| 748 | template and generate the manifest yourself: it just lists one file per |
| 749 | line.) |
| 750 | |
| 751 | The manifest template has one command per line, where each command |
| 752 | specifies a set of files to include or exclude from the source |
| 753 | distribution. For an example, again we turn to the Distutils' own |
| 754 | manifest template: |
| 755 | \begin{verbatim} |
| 756 | include *.txt |
Greg Ward | 87da1ea | 2000-04-21 04:35:25 +0000 | [diff] [blame] | 757 | recursive-include examples *.txt *.py |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 758 | prune examples/sample?/build |
| 759 | \end{verbatim} |
| 760 | The meanings should be fairly clear: include all files in the |
| 761 | distribution root matching \code{*.txt}, all files anywhere under the |
| 762 | \file{examples} directory matching \code{*.txt} or \code{*.py}, and |
| 763 | exclude all directories matching \code{examples/sample?/build}. There |
| 764 | are several other commands available in the manifest template |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 765 | mini-language; see section~\ref{sdist-cmd}. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 766 | |
| 767 | The order of commands in the manifest template very much matters: |
| 768 | initially, we have the list of default files as described above, and |
| 769 | each command in the template adds to or removes from that list of files. |
| 770 | When we have fully processed the manifest template, we have our complete |
| 771 | list of files. This list is written to the manifest for future |
| 772 | reference, and then used to build the source distribution archive(s). |
| 773 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 774 | Following the Distutils' own manifest template, let's trace how the |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame^] | 775 | \command{sdist} command builds the list of files to include in the |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 776 | Distutils source distribution: |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 777 | \begin{enumerate} |
| 778 | \item include all Python source files in the \file{distutils} and |
| 779 | \file{distutils/command} subdirectories (because packages |
| 780 | corresponding to those two directories were mentioned in the |
| 781 | \option{packages} option in the setup script) |
| 782 | \item include \file{test/test*.py} (always included) |
| 783 | \item include \file{README.txt} and \file{setup.py} (always included) |
| 784 | \item include \file{*.txt} in the distribution root (this will find |
| 785 | \file{README.txt} a second time, but such redundancies are weeded out |
| 786 | later) |
| 787 | \item in the sub-tree under \file{examples}, include anything matching |
| 788 | \file{*.txt} |
| 789 | \item in the sub-tree under \file{examples}, include anything matching |
| 790 | \file{*.py} |
| 791 | \item remove all files in the sub-trees starting at directories matching |
| 792 | \file{examples/sample?/build}---this may exclude files included by the |
| 793 | previous two steps, so it's important that the \code{prune} command in |
| 794 | the manifest template comes after the two \code{recursive-include} |
| 795 | commands |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 796 | \end{enumerate} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 797 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 798 | Just like in the setup script, file and directory names in the manifest |
| 799 | template should always be slash-separated; the Distutils will take care |
| 800 | of converting them to the standard representation on your platform. |
| 801 | That way, the manifest template is portable across operating systems. |
| 802 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 803 | |
| 804 | \subsection{Manifest-related options} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 805 | \label{manifest-options} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 806 | |
| 807 | The normal course of operations for the \command{sdist} command is as |
| 808 | follows: |
| 809 | \begin{itemize} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 810 | \item if the manifest file, \file{MANIFEST} doesn't exist, read |
| 811 | \file{MANIFEST.in} and create the manifest |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 812 | \item if either \file{MANIFEST.in} or the setup script (\file{setup.py}) |
| 813 | are more recent than \file{MANIFEST}, recreate \file{MANIFEST} by |
| 814 | reading \file{MANIFEST.in} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 815 | \item use the list of files now in \file{MANIFEST} (either just |
| 816 | generated or read in) to create the source distribution archive(s) |
| 817 | \end{itemize} |
| 818 | There are a couple of options that modify this behaviour. |
| 819 | |
| 820 | First, you might want to force the manifest to be regenerated---for |
| 821 | example, if you have added or removed files or directories that match an |
| 822 | existing pattern in the manifest template, you should regenerate the |
| 823 | manifest: |
| 824 | \begin{verbatim} |
| 825 | python setup.py sdist --force-manifest |
| 826 | \end{verbatim} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 827 | |
| 828 | Or, you might just want to (re)generate the manifest, but not create a |
| 829 | source distribution: |
| 830 | \begin{verbatim} |
| 831 | python setup.py sdist --manifest-only |
| 832 | \end{verbatim} |
Greg Ward | a021aca | 2000-04-19 22:34:11 +0000 | [diff] [blame] | 833 | (\longprogramopt{manifest-only} implies \longprogramopt{force-manifest}.) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 834 | |
| 835 | If you don't want to use the default file set, you can supply the |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 836 | \longprogramopt{no-defaults} option. If you use |
| 837 | \longprogramopt{no-defaults} and don't supply a manifest template (or |
| 838 | it's empty, or nothing matches the patterns in it), then your source |
| 839 | distribution will be empty. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 840 | |
| 841 | |
| 842 | \section{Creating Built Distributions} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 843 | \label{built-dist} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 844 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 845 | A ``built distribution'' is what you're probably used to thinking of |
| 846 | either as a ``binary package'' or an ``installer'' (depending on your |
| 847 | background). It's not necessarily binary, though, because it might |
| 848 | contain only Python source code and/or byte-code; and we don't call it a |
| 849 | package, because that word is already spoken for in Python. (And |
| 850 | ``installer'' is a term specific to the Windows world. \XXX{do Mac |
| 851 | people use it?}) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 852 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 853 | A built distribution is how you make life as easy as possible for |
| 854 | installers of your module distribution: for users of RPM-based Linux |
| 855 | systems, it's a binary RPM; for Windows users, it's an executable |
| 856 | installer; for Debian-based Linux users, it's a Debian package; and so |
| 857 | forth. Obviously, no one person will be able to create built |
| 858 | distributions for every platform under the sun, so the Distutils is |
| 859 | designed to enable module developers to concentrate on their |
| 860 | specialty---writing code and creating source distributions---while an |
| 861 | intermediary species of \emph{packager} springs up to turn source |
Greg Ward | 19c67f8 | 2000-06-24 01:33:16 +0000 | [diff] [blame] | 862 | distributions into built distributions for as many platforms as there |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 863 | are packagers. |
| 864 | |
| 865 | Of course, the module developer could be his own packager; or the |
| 866 | packager could be a volunteer ``out there'' somewhere who has access to |
| 867 | a platform which the original developer does not; or it could be |
| 868 | software periodically grabbing new source distributions and turning them |
| 869 | into built distributions for as many platforms as the software has |
| 870 | access to. Regardless of the nature of the beast, a packager uses the |
| 871 | setup script and the \command{bdist} command family to generate built |
| 872 | distributions. |
| 873 | |
| 874 | As a simple example, if I run the following command in the Distutils |
| 875 | source tree: |
| 876 | \begin{verbatim} |
| 877 | python setup.py bdist |
| 878 | \end{verbatim} |
| 879 | then the Distutils builds my module distribution (the Distutils itself |
| 880 | in this case), does a ``fake'' installation (also in the \file{build} |
| 881 | directory), and creates the default type of built distribution for my |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 882 | platform. Currently, the default format for built distributions is a |
| 883 | ``dumb'' archive---tarball on Unix, ZIP file on Windows. (These are |
| 884 | called ``dumb'' built distributions, because they must be unpacked in a |
| 885 | specific location to work.) |
| 886 | |
| 887 | Thus, the above command on a Unix system creates |
| 888 | \file{Distutils-0.9.1.\filevar{plat}.tar.gz}; unpacking this tarball |
| 889 | from the root of the filesystemq installs the Distutils just as though |
| 890 | you had downloaded the source distribution and run \code{python setup.py |
| 891 | install}. (Assuming that the target system has their Python |
| 892 | installation laid out the same as you do---another reason these are |
| 893 | called ``dumb'' distributions.) Obviously, for pure Python |
| 894 | distributions, this isn't a huge win---but for non-pure distributions, |
| 895 | which include extensions that would need to be compiled, it can mean the |
| 896 | difference between someone being able to use your extensions or not. |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 897 | |
| 898 | \XXX{filenames are inaccurate here!} |
| 899 | |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 900 | The \command{bdist} command has a \longprogramopt{format} option, |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 901 | similar to the \command{sdist} command, which you can use to select the |
| 902 | types of built distribution to generate: for example, |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 903 | \begin{verbatim} |
| 904 | python setup.py bdist --format=zip |
| 905 | \end{verbatim} |
| 906 | would, when run on a Unix system, create |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 907 | \file{Distutils-0.8.\filevar{plat}.zip}---again, this archive would be |
| 908 | unpacked from the root directory to install the Distutils. |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 909 | |
| 910 | The available formats for built distributions are: |
| 911 | \begin{tableiii}{l|l|c}{code}% |
| 912 | {Format}{Description}{Notes} |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 913 | \lineiii{zip}{zip file (\file{.zip})}{} |
| 914 | \lineiii{gztar}{gzipped tar file (\file{.tar.gz})}{(1)} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 915 | \lineiii{ztar}{compressed tar file (\file{.tar.Z})}{} |
| 916 | \lineiii{tar}{tar file (\file{.tar})}{} |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 917 | \lineiii{rpm}{RPM}{} |
| 918 | \lineiii{srpm}{source RPM}{\XXX{to do!}} |
| 919 | \lineiii{wininst}{self-extracting ZIP file for Windows}{(2)} |
| 920 | %\lineiii{wise}{Wise installer for Windows}{(3)} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 921 | \end{tableiii} |
| 922 | |
| 923 | \noindent Notes: |
| 924 | \begin{description} |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 925 | \item[(1)] default on Unix |
| 926 | \item[(2)] default on Windows \XXX{to-do!} |
| 927 | %\item[(3)] not implemented yet |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 928 | \end{description} |
| 929 | |
| 930 | You don't have to use the \command{bdist} command with the |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 931 | \longprogramopt{formats} option; you can also use the command that |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 932 | directly implements the format you're interested in. Some of these |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 933 | \command{bdist} ``sub-commands'' actually generate several similar |
| 934 | formats; for instance, the \command{bdist\_dumb} command generates all |
| 935 | the ``dumb'' archive formats (\code{tar}, \code{ztar}, \code{gztar}, and |
| 936 | \code{zip}), and \command{bdist\_rpm} generates both binary and source |
| 937 | RPMs. The \command{bdist} sub-commands, and the formats generated by |
| 938 | each, are: |
| 939 | \begin{tableii}{l|l}{command}% |
| 940 | {Command}{Formats} |
| 941 | \lineii{bdist\_dumb}{tar, ztar, gztar, zip} |
| 942 | \lineii{bdist\_rpm}{rpm, srpm} |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 943 | \lineii{bdist\_wininst}{wininst} |
| 944 | %\lineii{bdist\_wise}{wise} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 945 | \end{tableii} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 946 | |
| 947 | \section{Examples} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 948 | \label{examples} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 949 | |
| 950 | |
| 951 | \subsection{Pure Python distribution (by module)} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 952 | \label{pure-mod} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 953 | |
| 954 | |
| 955 | \subsection{Pure Python distribution (by package)} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 956 | \label{pure-pkg} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 957 | |
| 958 | |
| 959 | \subsection{Single extension module} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 960 | \label{single-ext} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 961 | |
| 962 | |
| 963 | \subsection{Multiple extension modules} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 964 | \label{multiple-ext} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 965 | |
| 966 | |
| 967 | \subsection{Putting it all together} |
| 968 | |
| 969 | |
Greg Ward | 4a9e722 | 2000-04-25 02:57:36 +0000 | [diff] [blame] | 970 | |
| 971 | \section{Extending the Distutils} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 972 | \label{extending} |
Greg Ward | 4a9e722 | 2000-04-25 02:57:36 +0000 | [diff] [blame] | 973 | |
| 974 | |
| 975 | \subsection{Extending existing commands} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 976 | \label{extend-existing} |
Greg Ward | 4a9e722 | 2000-04-25 02:57:36 +0000 | [diff] [blame] | 977 | |
| 978 | |
| 979 | \subsection{Writing new commands} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 980 | \label{new-commands} |
Greg Ward | 4a9e722 | 2000-04-25 02:57:36 +0000 | [diff] [blame] | 981 | |
| 982 | |
| 983 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 984 | \section{Reference} |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame^] | 985 | \label{reference} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 986 | |
| 987 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 988 | \subsection{Building modules: the \protect\command{build} command family} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 989 | \label{build-cmds} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 990 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 991 | \subsubsection{\protect\command{build}} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 992 | \label{build-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 993 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 994 | \subsubsection{\protect\command{build\_py}} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 995 | \label{build-py-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 996 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 997 | \subsubsection{\protect\command{build\_ext}} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 998 | \label{build-ext-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 999 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1000 | \subsubsection{\protect\command{build\_clib}} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 1001 | \label{build-clib-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1002 | |
| 1003 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1004 | \subsection{Installing modules: the \protect\command{install} command family} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 1005 | \label{install-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1006 | |
Gregory P. Smith | 147e5f3 | 2000-05-12 00:58:18 +0000 | [diff] [blame] | 1007 | The install command ensures that the build commands have been run and then |
| 1008 | runs the subcommands \command{install\_lib}, |
| 1009 | \command{install\_data} and |
| 1010 | \command{install\_scripts}. |
| 1011 | |
| 1012 | \subsubsection{\protect\command{install\_lib}} |
Greg Ward | 1365a30 | 2000-08-31 14:47:05 +0000 | [diff] [blame] | 1013 | \label{install-lib-cmd} |
Gregory P. Smith | 147e5f3 | 2000-05-12 00:58:18 +0000 | [diff] [blame] | 1014 | |
| 1015 | \subsubsection{\protect\command{install\_data}} |
Greg Ward | 1365a30 | 2000-08-31 14:47:05 +0000 | [diff] [blame] | 1016 | \label{install-data-cmd} |
Gregory P. Smith | 147e5f3 | 2000-05-12 00:58:18 +0000 | [diff] [blame] | 1017 | This command installs all data files provided with the distribution. |
| 1018 | |
| 1019 | \subsubsection{\protect\command{install\_scripts}} |
Greg Ward | 1365a30 | 2000-08-31 14:47:05 +0000 | [diff] [blame] | 1020 | \label{install-scripts-cmd} |
Gregory P. Smith | 147e5f3 | 2000-05-12 00:58:18 +0000 | [diff] [blame] | 1021 | This command installs all (Python) scripts in the distribution. |
| 1022 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1023 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1024 | \subsection{Cleaning up: the \protect\command{clean} command} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 1025 | \label{clean-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1026 | |
| 1027 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1028 | \subsection{Creating a source distribution: the \protect\command{sdist} command} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 1029 | \label{sdist-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1030 | |
| 1031 | |
| 1032 | \XXX{fragment moved down from above: needs context!} |
| 1033 | The manifest template commands are: |
| 1034 | \begin{tableii}{ll}{command}{Command}{Description} |
Greg Ward | 87da1ea | 2000-04-21 04:35:25 +0000 | [diff] [blame] | 1035 | \lineii{include \var{pat1} \var{pat2} ... } |
| 1036 | {include all files matching any of the listed patterns} |
| 1037 | \lineii{exclude \var{pat1} \var{pat2} ... } |
| 1038 | {exclude all files matching any of the listed patterns} |
| 1039 | \lineii{recursive-include \var{dir} \var{pat1} \var{pat2} ... } |
| 1040 | {include all files under \var{dir} matching any of the listed patterns} |
| 1041 | \lineii{recursive-exclude \var{dir} \var{pat1} \var{pat2} ...} |
| 1042 | {exclude all files under \var{dir} matching any of the listed patterns} |
| 1043 | \lineii{global-include \var{pat1} \var{pat2} ...} |
Greg Ward | 1bbe329 | 2000-06-25 03:14:13 +0000 | [diff] [blame] | 1044 | {include all files anywhere in the source tree matching\\& |
Greg Ward | 87da1ea | 2000-04-21 04:35:25 +0000 | [diff] [blame] | 1045 | any of the listed patterns} |
| 1046 | \lineii{global-exclude \var{pat1} \var{pat2} ...} |
Greg Ward | 1bbe329 | 2000-06-25 03:14:13 +0000 | [diff] [blame] | 1047 | {exclude all files anywhere in the source tree matching\\& |
Greg Ward | 87da1ea | 2000-04-21 04:35:25 +0000 | [diff] [blame] | 1048 | any of the listed patterns} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1049 | \lineii{prune \var{dir}}{exclude all files under \var{dir}} |
| 1050 | \lineii{graft \var{dir}}{include all files under \var{dir}} |
| 1051 | \end{tableii} |
| 1052 | The patterns here are Unix-style ``glob'' patterns: \code{*} matches any |
| 1053 | sequence of regular filename characters, \code{?} matches any single |
| 1054 | regular filename character, and \code{[\var{range}]} matches any of the |
| 1055 | characters in \var{range} (e.g., \code{a-z}, \code{a-zA-Z}, |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1056 | \code{a-f0-9\_.}). The definition of ``regular filename character'' is |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1057 | platform-specific: on Unix it is anything except slash; on Windows |
| 1058 | anything except backslash or colon; on Mac OS anything except colon. |
| 1059 | \XXX{Windows and Mac OS support not there yet} |
| 1060 | |
| 1061 | |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 1062 | \subsection{Creating a ``built'' distribution: the |
| 1063 | \protect\command{bdist} command family} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 1064 | \label{bdist-cmds} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1065 | |
| 1066 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1067 | \subsubsection{\protect\command{blib}} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1068 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1069 | \subsubsection{\protect\command{blib\_dumb}} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1070 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1071 | \subsubsection{\protect\command{blib\_rpm}} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1072 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1073 | \subsubsection{\protect\command{blib\_wise}} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1074 | |
| 1075 | |
| 1076 | |
| 1077 | |
| 1078 | |
| 1079 | |
| 1080 | |
| 1081 | |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 1082 | \end{document} |