Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 1 | \documentclass{howto} |
| 2 | \usepackage{ltxmarkup} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame^] | 3 | \usepackage{distutils} |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 4 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame^] | 5 | \title{Distributing Python Modules} |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 6 | |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 7 | \author{Greg Ward} |
| 8 | \authoraddress{E-mail: \email{gward@python.net}} |
| 9 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame^] | 10 | |
| 11 | \newcommand{\XXX}[1]{\textbf{**#1**}} |
| 12 | |
| 13 | |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 14 | \begin{document} |
| 15 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame^] | 16 | |
| 17 | \section{Introduction} |
| 18 | \label{sec:intro} |
| 19 | |
| 20 | In the past, Python module developers have not had much infrastructure |
| 21 | support for distributing modules, nor have Python users had much support |
| 22 | for installing and maintaining third-party modules. With the |
| 23 | introduction of the Python Distribution Utilities (Distutils for short) |
| 24 | in Python 1.6, this situation should start to improve. |
| 25 | |
| 26 | This document only covers using the Distutils to distribute your Python |
| 27 | modules. Using the Distutils does not tie you to Python 1.6, though: |
| 28 | the Distutils work just fine with Python 1.5, and it is reasonable (and |
| 29 | expected to become commonplace) to expect users of Python 1.5 to |
| 30 | download and install the Distutils separately before they can install |
| 31 | your modules. Python 1.6 users, of course, won't have to add anything |
| 32 | to their Python installation in order to use the Distutils to install |
| 33 | third-party modules. |
| 34 | |
| 35 | This document concentrates on the role of developer/distributor: if |
| 36 | you're looking for information on installing Python modules, you should |
| 37 | refer to the ``Installing Python Modules'' manual. |
| 38 | |
| 39 | |
| 40 | \section{Concepts & Terminology} |
| 41 | \label{sec:concepts} |
| 42 | |
| 43 | Using the Distutils is quite simple, both for module developers and for |
| 44 | users/administrators installing third-party modules. As a developer, |
| 45 | your responsibilites (apart from writing solid, well-documented and |
| 46 | well-tested code, of course!) are: |
| 47 | \begin{itemize} |
| 48 | \item write a setup script (\file{setup.py} by convention) |
| 49 | \item (optional) write a setup configuration file |
| 50 | \item create a source distribution |
| 51 | \item (optional) create one or more built (binary) distributions |
| 52 | \end{itemize} |
| 53 | Each of these tasks is covered in this document. |
| 54 | |
| 55 | Not all module developers have access to a multitude of platforms, so |
| 56 | it's not always feasible to expect them to create a multitude of built |
| 57 | distributions. It is hoped that a class of intermediaries, called |
| 58 | \emph{packagers}, will arise to take address this need. Packagers will |
| 59 | take source distributions released by module developers, build them on |
| 60 | one or more platforms, and release the resulting built distributions. |
| 61 | Thus, users on the most popular platforms will be able to install most |
| 62 | popular Python module distributions in the most natural way for their |
| 63 | platform, without having to run a single setup script or compile a line |
| 64 | of code. |
| 65 | |
| 66 | |
| 67 | \subsection{A simple example} |
| 68 | \label{sec:simple-example} |
| 69 | |
| 70 | The setup script is usually quite simple, although since it's written in |
| 71 | Python, there are no arbitrary limits to what you can do. If all you |
| 72 | want to do is distribute a module called \module{foo}, contained in a |
| 73 | file \file{foo.py}, then you can get away with as little as this: |
| 74 | \begin{verbatim} |
| 75 | from distutils.core import setup |
| 76 | setup (name = "foo", |
| 77 | version = "1.0", |
| 78 | py_modules = ["foo"]) |
| 79 | \end{verbatim} |
| 80 | Some observations: |
| 81 | \begin{itemize} |
| 82 | \item all information that you supply to the Distutils is supplied as |
| 83 | keyword arguments to the \func{setup()} function |
| 84 | \item those keyword arguments fall into two categories: package |
| 85 | meta-data (name, version number) and information about what's in the |
| 86 | package (list of pure modules, in this case) |
| 87 | \item modules are specified by module name, not filename (the same will |
| 88 | hold true for packages and extensions) |
| 89 | \item it's recommended that you supply a little more meta-data, in |
| 90 | particular your name, email address and a URL for the project |
| 91 | \end{itemize} |
| 92 | |
| 93 | To create a source distribution for this module, you would run |
| 94 | \begin{verbatim} |
| 95 | python setup.py sdist |
| 96 | \end{verbatim} |
| 97 | which will create an archive file (e.g., tarball on Unix, zip file on |
| 98 | Windows) containing your setup script, \file{setup.py}, and your module, |
| 99 | \file{foo.py}. The archive file will be named \file{Foo-1.0.tar.gz} (or |
| 100 | \file{.zip}), and will unpack into a directory \file{Foo-1.0}. |
| 101 | |
| 102 | If an end-user wishes to install your \module{foo} module, all she has |
| 103 | to do is download \file{Foo-1.0.tar.gz}) (or \file{.zip}), unpack it, |
| 104 | and---from the \file{Foo-1.0} directory---run |
| 105 | \begin{verbatim} |
| 106 | python setup.py install |
| 107 | \end{verbatim} |
| 108 | which will ultimately copy \file{foo.py} to the appropriate directory |
| 109 | for third-party modules in their Python installation. |
| 110 | |
| 111 | This simple example demonstrates some fundamental concepts of the |
| 112 | Distutils: first, both developers and installers have the same basic |
| 113 | user interface, i.e. the setup script. The difference is which |
| 114 | Distutils \emph{commands} they use: the \command{sdist} command is |
| 115 | almost exclusively for module developers, while \command{install} is |
| 116 | more often for installers (although most developers will want to install |
| 117 | their own code occasionally). |
| 118 | |
| 119 | \XXX{only partially implemented}% |
| 120 | If you want to make things really easy for your users, you can create |
| 121 | one or more built distributions for them. For instance, if you are |
| 122 | running on a Windows machine, and want to make things easy for other |
| 123 | Windows users, you can create an executable installer (the most |
| 124 | appropriate type of built distribution for this platform) with the |
| 125 | \command{bdist\_wise} command. (Wise is the installation tool used to |
| 126 | create Windows installers for Python itself, so we have adopted it for |
| 127 | use by any Python module distribution. You'll need to have version XXX |
| 128 | of Wise installed on your system for the \command{bdist\_wise} to work; |
| 129 | it's available from \url{http://foo/bar/baz}. For example: |
| 130 | \begin{verbatim} |
| 131 | python setup.py bdist_wise |
| 132 | \end{verbatim} |
| 133 | will create an executable installer, \file{Foo-1_0.exe}, in the current |
| 134 | directory. |
| 135 | |
| 136 | \XXX{not implemented yet} |
| 137 | Other \command{bdist\_*} commands exist for RPM-based Linux systems |
| 138 | (\command{bdist\_rpm}), Debian-based Linux systems |
| 139 | (\command{bdist\_deb}), ... |
| 140 | |
| 141 | |
| 142 | \subsection{General Python terminology} |
| 143 | \label{sec:python-terms} |
| 144 | |
| 145 | If you're reading this document, you probably have a good idea of what |
| 146 | modules, extensions, and so forth are. Nevertheless, just to be sure |
| 147 | that everyone is operating from a common starting point, we offer the |
| 148 | following glossary of common Python terms: |
| 149 | \begin{description} |
| 150 | \item[module] the basic unit of code reusability in Python: a block of |
| 151 | code imported by some other code. There are three types of modules |
| 152 | that concern us here: pure Python modules, extension modules, and |
| 153 | packages. |
| 154 | \item[pure Python module] a module written in Python and contained in a |
| 155 | single \file{.py} file (and possibly associated \file{.pyc} and/or |
| 156 | \file{.pyo} files). Sometimes referred to as a ``pure module.'' |
| 157 | \item[extension module] a module written in the low-level language of |
| 158 | the Python implemention: C/C++ for CPython, Java for JPython. |
| 159 | Typically contained in a single dynamically loadable pre-compiled |
| 160 | file, e.g. a shared object (\file{.so}) file for CPython extensions on |
| 161 | Unix, a DLL (given the \file{.pyd} extension) for CPython extensions |
| 162 | on Windows, or a Java class file for JPython extensions. |
| 163 | \item[package] a module that contains other modules; typically contained |
| 164 | in a directory in the filesystem and distinguished from other |
| 165 | directories by the presence of a file \file{\_\_init\_\_.py}. |
| 166 | \end{description} |
| 167 | |
| 168 | |
| 169 | \subsection{Distutils-specific terminology} |
| 170 | \label{sec:distutils-term} |
| 171 | |
| 172 | The following terms apply more specifically to the domain of |
| 173 | distributing Python modules using the Distutils: |
| 174 | \begin{description} |
| 175 | \item[module distribution] a collection of Python modules distributed |
| 176 | together as a single downloadable resource and meant to be installed |
| 177 | \emph{en masse}. Examples of some well-known module distributions are |
| 178 | Numeric Python, PyXML, PIL (the Python Imaging Library), or |
| 179 | mxDateTime. (This would be called a \emph{package}, except that term |
| 180 | is already spoken for in the Python context: a single module |
| 181 | distribution may contain zero, one, or many Python packages.) |
| 182 | \item[pure module distribution] a module distribution that contains only |
| 183 | pure Python modules and packages. Sometimes referred to as a ``pure |
| 184 | distribution.'' |
| 185 | \item[non-pure module distribution] a module distribution that contains |
| 186 | at least one extension module. Sometimes referred to as a ``non-pure |
| 187 | distribution.'' |
| 188 | \item[distribution root] the top-level directory of your source tree (or |
| 189 | source distribution); the directory where \file{setup.py} exists and |
| 190 | is run from |
| 191 | \end{description} |
| 192 | |
| 193 | |
| 194 | \section{Writing the Setup Script} |
| 195 | \label{sec:setup-script} |
| 196 | |
| 197 | The setup script is the centre of all activity in building, |
| 198 | distributing, and installing modules using the Distutils. The main |
| 199 | purpose of the setup script is to describe your module distribution to |
| 200 | the Distutils, so that the various commands that operate on your modules |
| 201 | do the right thing. As we saw in section~\ref{sec:simple-example} |
| 202 | above, the setup script consists mainly of a call to \func{setup()}, and |
| 203 | all information supplied to the Distutils is suppled as keyword |
| 204 | arguments to \func{setup()}. |
| 205 | |
| 206 | Here's a slightly more involved example, which we'll follow for the next |
| 207 | couple of sections: the Distutils' own setup script. (Keep in mind that |
| 208 | although the Distutils are included with Python 1.6, they also have an |
| 209 | independent existence so that Python 1.5 users can use them to install |
| 210 | other module distributions.) |
| 211 | |
| 212 | \begin{verbatim} |
| 213 | #!/usr/bin/env python |
| 214 | |
| 215 | from distutils.core import setup |
| 216 | |
| 217 | setup (name = "Distutils", |
| 218 | version = "1.0", |
| 219 | description = "Python Module Distribution Utilities", |
| 220 | author = "Greg Ward", |
| 221 | author_email = "gward@python.net", |
| 222 | url = "http://www.python.org/sigs/distutils-sig/", |
| 223 | |
| 224 | packages = ['distutils', 'distutils.command'], |
| 225 | ) |
| 226 | \end{verbatim} |
| 227 | There are only two differences between this and the trivial one-file |
| 228 | distribution presented in section~\ref{sec:simple-example}: more |
| 229 | meta-data, and the specification of pure Python modules by package, |
| 230 | rather than by module. This is important since the Distutils consist of |
| 231 | a couple of dozen modules split into (so far) two packages; an explicit |
| 232 | list of every module would be tedious to generate and difficult to |
| 233 | maintain. |
| 234 | |
| 235 | |
| 236 | \subsection{Package directories} |
| 237 | \label{sec:package-dirs} |
| 238 | |
| 239 | The \option{packages} option tells the Distutils to process (build, |
| 240 | distribute, install, etc.) all pure Python modules found in each package |
| 241 | mentioned in the \option{packages} list. In order to do this, of |
| 242 | course, there has to be a correspondence between package names and |
| 243 | directories in the filesystem. The default correspondence is the most |
| 244 | obvious one, i.e. package \package{distutils} is found in the directory |
| 245 | \file{distutils} relative to the distribution root. Thus, when you say |
| 246 | \code{packages = ['foo']} in your setup script, you are promising that |
| 247 | the Distutils will find a file \file{foo/\_\_init\_\_.py} (which might |
| 248 | be spelled differently on your system, but you get the idea) relative to |
| 249 | the directory where your setup script lives. (If you break this |
| 250 | promise, the Distutils will issue a warning but process the broken |
| 251 | package anyways.) |
| 252 | |
| 253 | If you use a different convention to lay out your source directory, |
| 254 | that's no problem: you just have to supply the \option{package\_dir} |
| 255 | option to tell the Distutils about your convention. For example, say |
| 256 | you keep all Python source under \file{lib}, so that modules not in any |
| 257 | package are right in \file{lib}, modules in the \package{foo} package |
| 258 | are in \file{lib/foo}, and so forth. Then you would put |
| 259 | \begin{verbatim} |
| 260 | package_dir = {'': 'lib'} |
| 261 | \end{verbatim} |
| 262 | in your setup script. (The keys to this dictionary are package names, |
| 263 | and an empty package name stands for the ``root package,'' i.e. no |
| 264 | package at all. The values are directory names relative to your |
| 265 | distribution root.) In this case, when you say |
| 266 | \code{packages = ['foo']}, you are promising that the file |
| 267 | \file{lib/foo/\_\_init\_\_.py} exists. |
| 268 | |
| 269 | Another possible convention is to put the \package{foo} package right in |
| 270 | \file{lib}, the \package{foo.bar} package in \file{lib/bar}, etc. This |
| 271 | would be written in the setup script as |
| 272 | \begin{verbatim} |
| 273 | package_dir = {'foo': 'lib'} |
| 274 | \end{verbatim} |
| 275 | Note that a \code{\var{package}: \var{dir}} entry in the |
| 276 | \option{package\_dir} option implicitly applies to all packages below |
| 277 | \var{package}, so the \package{foo.bar} case is automatically handled |
| 278 | here. In this example, having \code{packages = ['foo', 'foo.bar']} |
| 279 | tells the Distutils to look for \file{lib/__init__.py} and |
| 280 | \file{lib/bar/__init__.py}. |
| 281 | |
| 282 | |
| 283 | \subsection{Listing individual modules} |
| 284 | \label{sec:listing-modules} |
| 285 | |
| 286 | For a small module distribution, you might prefer to list all modules |
| 287 | rather than listing packages---especially the case of a single module |
| 288 | that goes in the ``root package'' (i.e., no package at all). This |
| 289 | simplest case was shown in section~\ref{sec:simple-example}; here is a |
| 290 | slightly more involved example: |
| 291 | \begin{verbatim} |
| 292 | py_modules = ['mod1', 'pkg.mod2'] |
| 293 | \end{verbatim} |
| 294 | This describes two modules, one of them in the ``root'' package, the |
| 295 | other in the \package{pkg} package. Again, the default |
| 296 | package/directory layout implies that these two modules can be found in |
| 297 | \file{mod1.py} and \file{pkg/mod2.py}, and that \file{pkg/__init__.py} |
| 298 | exists as well. And again, you can override the package/directory |
| 299 | layout using the \option{package\_dir} option. \XXX{not sure if this is |
| 300 | actually true---must check!} |
| 301 | |
| 302 | |
| 303 | \section{Writing the Setup Configuration File} |
| 304 | \label{sec:setup-config} |
| 305 | |
| 306 | \XXX{not implemented yet!} |
| 307 | |
| 308 | Often, it's not possible to write down everything needed to build a |
| 309 | distribution \emph{a priori}. You need to get some information from the |
| 310 | user, or from the user's system, in order to proceed. For example, you |
| 311 | might include an optional extension module that provides an interface to |
| 312 | a particular C library. If that library is installed on the user's |
| 313 | system, then you can build your optional extension---but you need to |
| 314 | know where to find the header and library file. If it's not installed, |
| 315 | you need to know this so you can omit your optional extension. |
| 316 | |
| 317 | The preferred way to do this, of course, would be for you to tell the |
| 318 | Distutils which optional features (C libraries, system calls, external |
| 319 | utilities, etc.) you're looking for, and it would inspect the user's |
| 320 | system and try to find them. This functionality may appear in a future |
| 321 | version of the Distutils, but it isn't there now. So, for the time |
| 322 | being, we rely on the user building and installing your software to |
| 323 | provide the necessary information. The vehicle for doing so is the |
| 324 | setup configuration file, \file{setup.cfg}. |
| 325 | |
| 326 | \XXX{need more here!} |
| 327 | |
| 328 | |
| 329 | \section{Creating a Source Distribution} |
| 330 | \label{sec:source-dist} |
| 331 | |
| 332 | As shown in section~\ref{sec:simple-example}, you use the |
| 333 | \command{sdist} command to create a source distribution. In the |
| 334 | simplest case, |
| 335 | \begin{verbatim} |
| 336 | python setup.py sdist |
| 337 | \end{verbatim} |
| 338 | (assuming you haven't specified any \command{sdist} options in the setup |
| 339 | script or config file), \command{sdist} creates the the archive of the |
| 340 | default format for the current platform. The default formats are: |
| 341 | \begin{tableii}{ll}{textrm}% |
| 342 | {Platform}{Default archive format for source distributions} |
| 343 | \lineii{Unix}{gzipped tar file (\file{.tar.gz})} |
| 344 | \lineii{Windows}{zip file} |
| 345 | \end{tableii} |
| 346 | You can specify as many formats as you like using the \option{--formats} |
| 347 | option, for example: |
| 348 | \begin{verbatim} |
| 349 | python setup.py sdist --formats=gztar,zip |
| 350 | \end{verbatim} |
| 351 | to create a gzipped tarball and a zip file. The available formats are: |
| 352 | \begin{tableii}{ll}{textrm}% |
| 353 | {Format}{Description} |
| 354 | \lineii{zip}{zip file (\file{.zip})} |
| 355 | \lineii{gztar}{gzipped tar file (\file{.tar.gz})} |
| 356 | \lineii{ztar}{compressed tar file (\file{.tar.Z})} |
| 357 | \lineii{tar}{tar file (\file{.tar})} |
| 358 | \end{tableii} |
| 359 | |
| 360 | |
| 361 | \subsection{The manifest and manifest template} |
| 362 | \label{sec:manifest} |
| 363 | |
| 364 | Without any additional information, the \command{sdist} command puts a |
| 365 | minimal set of files into the source distribution: |
| 366 | \begin{itemize} |
| 367 | \item all Python source files implied by the \option{py_modules} and |
| 368 | \option{packages} options |
| 369 | \item all C source files mentioned in the \option{ext_modules} or |
| 370 | \option{libraries} options (\XXX{getting C library sources currently |
| 371 | broken -- no get_source_files() method in build_clib.py!}) |
| 372 | \item anything that looks like a test script: \file{test/test*.py} |
| 373 | (currently, the Distutils don't do anything with test scripts except |
| 374 | include them in source distributions, but in the future there will be |
| 375 | a standard for testing Python module distributions) |
| 376 | \item \file{README.txt} (or \file{README}) and \file{setup.py} |
| 377 | \end{itemize} |
| 378 | Sometimes this is enough, but usually you will want to specify |
| 379 | additional files to distribute. The typical way to do this is to write |
| 380 | a \emph{manifest template}, called \file{MANIFEST.in} by default. The |
| 381 | \command{sdist} command processes this template and generates a manifest |
| 382 | file, \file{MANIFEST}. (If you prefer, you can skip the manifest |
| 383 | template and generate the manifest yourself: it just lists one file per |
| 384 | line.) |
| 385 | |
| 386 | The manifest template has one command per line, where each command |
| 387 | specifies a set of files to include or exclude from the source |
| 388 | distribution. For an example, again we turn to the Distutils' own |
| 389 | manifest template: |
| 390 | \begin{verbatim} |
| 391 | include *.txt |
| 392 | recursive-include examples *.txt |
| 393 | recursive-include examples *.py |
| 394 | prune examples/sample?/build |
| 395 | \end{verbatim} |
| 396 | The meanings should be fairly clear: include all files in the |
| 397 | distribution root matching \code{*.txt}, all files anywhere under the |
| 398 | \file{examples} directory matching \code{*.txt} or \code{*.py}, and |
| 399 | exclude all directories matching \code{examples/sample?/build}. There |
| 400 | are several other commands available in the manifest template |
| 401 | mini-language; see section~\ref{sec:sdist-cmd}. |
| 402 | |
| 403 | The order of commands in the manifest template very much matters: |
| 404 | initially, we have the list of default files as described above, and |
| 405 | each command in the template adds to or removes from that list of files. |
| 406 | When we have fully processed the manifest template, we have our complete |
| 407 | list of files. This list is written to the manifest for future |
| 408 | reference, and then used to build the source distribution archive(s). |
| 409 | |
| 410 | We can now see how the \command{sdist} command will build the list of |
| 411 | files to include in the Distutils source distribution: |
| 412 | \begin{enumerate} |
| 413 | \item include all Python source files in the \file{distutils} and |
| 414 | \file{distutils/command} subdirectories (because packages |
| 415 | corresponding to those two directories were mentioned in the |
| 416 | \option{packages} option in the setup script) |
| 417 | \item include \file{test/test*.py} (always included) |
| 418 | \item include \file{README.txt} and \file{setup.py} (always included) |
| 419 | \item include \file{*.txt} in the distribution root (this will find |
| 420 | \file{README.txt} a second time, but such redundancies are weeded out |
| 421 | later) |
| 422 | \item in the sub-tree under \file{examples}, include anything matching |
| 423 | \file{*.txt} |
| 424 | \item in the sub-tree under \file{examples}, include anything matching |
| 425 | \file{*.py} |
| 426 | \item remove all files in the sub-trees starting at directories matching |
| 427 | \file{examples/sample?/build}---this may exclude files included by the |
| 428 | previous two steps, so it's important that the \code{prune} command in |
| 429 | the manifest template comes after the two \code{recursive-include} |
| 430 | commands |
| 431 | \end{itemize} |
| 432 | |
| 433 | |
| 434 | \subsection{Manifest-related options} |
| 435 | \label{sec:manifest-options} |
| 436 | |
| 437 | The normal course of operations for the \command{sdist} command is as |
| 438 | follows: |
| 439 | \begin{itemize} |
| 440 | \item if \file{MANIFEST.in} is more recent than \file{MANIFEST}, or |
| 441 | \file{MANIFEST} doesn't exist at all, recreate \file{MANIFEST} by |
| 442 | processing \file{MANIFEST.in} |
| 443 | \item use the list of files now in \file{MANIFEST} (either just |
| 444 | generated or read in) to create the source distribution archive(s) |
| 445 | \end{itemize} |
| 446 | There are a couple of options that modify this behaviour. |
| 447 | |
| 448 | First, you might want to force the manifest to be regenerated---for |
| 449 | example, if you have added or removed files or directories that match an |
| 450 | existing pattern in the manifest template, you should regenerate the |
| 451 | manifest: |
| 452 | \begin{verbatim} |
| 453 | python setup.py sdist --force-manifest |
| 454 | \end{verbatim} |
| 455 | \XXX{this is stupid, but is there a better way to do it without |
| 456 | reprocessing MANIFEST.in every single bloody time?} |
| 457 | |
| 458 | Or, you might just want to (re)generate the manifest, but not create a |
| 459 | source distribution: |
| 460 | \begin{verbatim} |
| 461 | python setup.py sdist --manifest-only |
| 462 | \end{verbatim} |
| 463 | (\option{--manifest-only} implies \option{--force-manifest}.) |
| 464 | |
| 465 | If you don't want to use the default file set, you can supply the |
| 466 | \option{--no-defaults} option. If you use \option{--no-defaults} and |
| 467 | don't supply a manifest template (or it's empty, or nothing matches the |
| 468 | patterns in it), then your source distribution will be empty. |
| 469 | |
| 470 | |
| 471 | \section{Creating Built Distributions} |
| 472 | \label{sec:built-dist} |
| 473 | |
| 474 | |
| 475 | |
| 476 | \section{Examples} |
| 477 | \label{sec:examples} |
| 478 | |
| 479 | |
| 480 | \subsection{Pure Python distribution (by module)} |
| 481 | \label{sec:pure-mod} |
| 482 | |
| 483 | |
| 484 | \subsection{Pure Python distribution (by package)} |
| 485 | \label{sec:pure-pkg} |
| 486 | |
| 487 | |
| 488 | \subsection{Single extension module} |
| 489 | \label{sec:single-ext} |
| 490 | |
| 491 | |
| 492 | \subsection{Multiple extension modules} |
| 493 | \label{sec:multiple-ext} |
| 494 | |
| 495 | |
| 496 | \subsection{Putting it all together} |
| 497 | |
| 498 | |
| 499 | \section{Reference} |
| 500 | \label{sec:ref} |
| 501 | |
| 502 | |
| 503 | \subsection{Building modules: the \command{build} command family} |
| 504 | \label{sec:build-cmds} |
| 505 | |
| 506 | \subsubsection{\command{build}} |
| 507 | \label{sec:build-cmd} |
| 508 | |
| 509 | \subsubsection{\command{build\_py}} |
| 510 | \label{sec:build-py-cmd} |
| 511 | |
| 512 | \subsubsection{\command{build\_ext}} |
| 513 | \label{sec:build-ext-cmd} |
| 514 | |
| 515 | \subsubsection{\command{build\_clib}} |
| 516 | \label{sec:build-clib-cmd} |
| 517 | |
| 518 | |
| 519 | \subsection{Installing modules: the \command{install} command family} |
| 520 | \label{sec:install-cmd} |
| 521 | |
| 522 | |
| 523 | \subsection{Cleaning up: the \command{clean} command} |
| 524 | \label{sec:clean-cmd} |
| 525 | |
| 526 | |
| 527 | \subsection{Creating a source distribution: the \command{sdist} command} |
| 528 | \label{sec:sdist-cmd} |
| 529 | |
| 530 | |
| 531 | \XXX{fragment moved down from above: needs context!} |
| 532 | The manifest template commands are: |
| 533 | \begin{tableii}{ll}{command}{Command}{Description} |
| 534 | \lineii{include \var{pat}}{include all files matching \var{pat}} |
| 535 | \lineii{exclude \var{pat}}{exclude all files matching \var{pat}} |
| 536 | \lineii{recursive-include \var{dir} \var{pat}} |
| 537 | {include all files under \var{dir} matching \var{pat}} |
| 538 | \lineii{recursive-exclude \var{dir} \var{pat}} |
| 539 | {exclude all files under \var{dir} matching \var{pat}} |
| 540 | \lineii{global-include \var{pat}} |
| 541 | {include all files anywhere in the source tree matching \var{pat}} |
| 542 | \lineii{global-exclude \var{pat}} |
| 543 | {exclude all files anywhere in the source tree matching \var{pat}} |
| 544 | \lineii{prune \var{dir}}{exclude all files under \var{dir}} |
| 545 | \lineii{graft \var{dir}}{include all files under \var{dir}} |
| 546 | \end{tableii} |
| 547 | The patterns here are Unix-style ``glob'' patterns: \code{*} matches any |
| 548 | sequence of regular filename characters, \code{?} matches any single |
| 549 | regular filename character, and \code{[\var{range}]} matches any of the |
| 550 | characters in \var{range} (e.g., \code{a-z}, \code{a-zA-Z}, |
| 551 | \code{a-f0-9_.}). The definition of ``regular filename character'' is |
| 552 | platform-specific: on Unix it is anything except slash; on Windows |
| 553 | anything except backslash or colon; on Mac OS anything except colon. |
| 554 | \XXX{Windows and Mac OS support not there yet} |
| 555 | |
| 556 | |
| 557 | \subsection{Creating a ``built'' distribution: the \command{bdist} command |
| 558 | family} |
| 559 | \label{sec:bdist-cmds} |
| 560 | |
| 561 | |
| 562 | \subsubsection{\command{blib}} |
| 563 | |
| 564 | \subsubsection{\command{blib\_dumb}} |
| 565 | |
| 566 | \subsubsection{\command{blib\_rpm}} |
| 567 | |
| 568 | \subsubsection{\command{blib\_wise}} |
| 569 | |
| 570 | |
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 577 | \end{document} |