blob: 02cce0e4317f02ce3ed567583905423f2a77c2e9 [file] [log] [blame]
Greg Wardabc52162000-02-26 00:52:48 +00001\documentclass{howto}
2\usepackage{ltxmarkup}
Greg Wardfacb8db2000-04-09 04:32:40 +00003\usepackage{times}
Greg Ward16aafcd2000-04-09 04:06:44 +00004\usepackage{distutils}
Greg Wardabc52162000-02-26 00:52:48 +00005
Greg Ward16aafcd2000-04-09 04:06:44 +00006\title{Distributing Python Modules}
Greg Wardabc52162000-02-26 00:52:48 +00007
Greg Wardabc52162000-02-26 00:52:48 +00008\author{Greg Ward}
9\authoraddress{E-mail: \email{gward@python.net}}
10
Greg Ward16aafcd2000-04-09 04:06:44 +000011
Greg Wardabc52162000-02-26 00:52:48 +000012\begin{document}
13
Greg Wardfacb8db2000-04-09 04:32:40 +000014\maketitle
15\tableofcontents
Greg Ward16aafcd2000-04-09 04:06:44 +000016
17\section{Introduction}
Greg Warde78298a2000-04-28 17:12:24 +000018\label{intro}
Greg Ward16aafcd2000-04-09 04:06:44 +000019
20In the past, Python module developers have not had much infrastructure
21support for distributing modules, nor have Python users had much support
22for installing and maintaining third-party modules. With the
23introduction of the Python Distribution Utilities (Distutils for short)
Greg Ward1d8f57a2000-08-05 00:43:11 +000024in Python 1.6, this situation should start to improve.
Greg Ward16aafcd2000-04-09 04:06:44 +000025
26This document only covers using the Distutils to distribute your Python
Greg Ward1d8f57a2000-08-05 00:43:11 +000027modules. Using the Distutils does not tie you to Python 1.6, though:
28the Distutils work just fine with Python 1.5.2, and it is reasonable
29(and expected to become commonplace) to expect users of Python 1.5.2 to
Greg Ward16aafcd2000-04-09 04:06:44 +000030download and install the Distutils separately before they can install
Greg Ward1d8f57a2000-08-05 00:43:11 +000031your modules. Python 1.6 (or later) users, of course, won't have to add
32anything to their Python installation in order to use the Distutils to
33install third-party modules.
Greg Ward16aafcd2000-04-09 04:06:44 +000034
35This document concentrates on the role of developer/distributor: if
Fred Drake01df4532000-06-30 03:36:41 +000036you're looking for information on installing Python modules, you
37should refer to the \citetitle[../inst/inst.html]{Installing Python
38Modules} manual.
Greg Ward16aafcd2000-04-09 04:06:44 +000039
40
Greg Wardfacb8db2000-04-09 04:32:40 +000041\section{Concepts \& Terminology}
Greg Warde78298a2000-04-28 17:12:24 +000042\label{concepts}
Greg Ward16aafcd2000-04-09 04:06:44 +000043
44Using the Distutils is quite simple, both for module developers and for
45users/administrators installing third-party modules. As a developer,
46your responsibilites (apart from writing solid, well-documented and
47well-tested code, of course!) are:
48\begin{itemize}
49\item write a setup script (\file{setup.py} by convention)
50\item (optional) write a setup configuration file
51\item create a source distribution
52\item (optional) create one or more built (binary) distributions
53\end{itemize}
54Each of these tasks is covered in this document.
55
56Not all module developers have access to a multitude of platforms, so
57it's not always feasible to expect them to create a multitude of built
58distributions. It is hoped that a class of intermediaries, called
Greg Ward19c67f82000-06-24 01:33:16 +000059\emph{packagers}, will arise to address this need. Packagers will take
60source distributions released by module developers, build them on one or
61more platforms, and release the resulting built distributions. Thus,
62users on the most popular platforms will be able to install most popular
63Python module distributions in the most natural way for their platform,
64without having to run a single setup script or compile a line of code.
Greg Ward16aafcd2000-04-09 04:06:44 +000065
66
67\subsection{A simple example}
Greg Warde78298a2000-04-28 17:12:24 +000068\label{simple-example}
Greg Ward16aafcd2000-04-09 04:06:44 +000069
70The setup script is usually quite simple, although since it's written in
Greg Ward1d8f57a2000-08-05 00:43:11 +000071Python, there are no arbitrary limits to what you can do with it. If
72all you want to do is distribute a module called \module{foo}, contained
73in a file \file{foo.py}, then your setup script can be as little as
74this:
Greg Ward16aafcd2000-04-09 04:06:44 +000075\begin{verbatim}
76from distutils.core import setup
77setup (name = "foo",
78 version = "1.0",
79 py_modules = ["foo"])
80\end{verbatim}
Greg Ward370248d2000-06-24 01:45:47 +000081
Greg Ward16aafcd2000-04-09 04:06:44 +000082Some observations:
83\begin{itemize}
Greg Ward370248d2000-06-24 01:45:47 +000084\item most information that you supply to the Distutils is supplied as
Greg Wardfacb8db2000-04-09 04:32:40 +000085 keyword arguments to the \function{setup()} function
Greg Ward16aafcd2000-04-09 04:06:44 +000086\item those keyword arguments fall into two categories: package
87 meta-data (name, version number) and information about what's in the
Greg Ward370248d2000-06-24 01:45:47 +000088 package (a list of pure Python modules, in this case)
Greg Ward16aafcd2000-04-09 04:06:44 +000089\item modules are specified by module name, not filename (the same will
90 hold true for packages and extensions)
91\item it's recommended that you supply a little more meta-data, in
92 particular your name, email address and a URL for the project
93\end{itemize}
94
Greg Ward370248d2000-06-24 01:45:47 +000095To create a source distribution for this module, you would create a
96setup script, \file{setup.py}, containing the above code, and run:
Greg Ward16aafcd2000-04-09 04:06:44 +000097\begin{verbatim}
98python setup.py sdist
99\end{verbatim}
100which will create an archive file (e.g., tarball on Unix, zip file on
101Windows) containing your setup script, \file{setup.py}, and your module,
102\file{foo.py}. The archive file will be named \file{Foo-1.0.tar.gz} (or
103\file{.zip}), and will unpack into a directory \file{Foo-1.0}.
104
105If an end-user wishes to install your \module{foo} module, all she has
Greg Ward59d382e2000-05-26 01:04:47 +0000106to do is download \file{Foo-1.0.tar.gz} (or \file{.zip}), unpack it,
Greg Ward16aafcd2000-04-09 04:06:44 +0000107and---from the \file{Foo-1.0} directory---run
108\begin{verbatim}
109python setup.py install
110\end{verbatim}
111which will ultimately copy \file{foo.py} to the appropriate directory
112for third-party modules in their Python installation.
113
114This simple example demonstrates some fundamental concepts of the
115Distutils: first, both developers and installers have the same basic
116user interface, i.e. the setup script. The difference is which
117Distutils \emph{commands} they use: the \command{sdist} command is
118almost exclusively for module developers, while \command{install} is
119more often for installers (although most developers will want to install
120their own code occasionally).
121
Greg Ward16aafcd2000-04-09 04:06:44 +0000122If you want to make things really easy for your users, you can create
123one or more built distributions for them. For instance, if you are
124running on a Windows machine, and want to make things easy for other
125Windows users, you can create an executable installer (the most
126appropriate type of built distribution for this platform) with the
Greg Ward59d382e2000-05-26 01:04:47 +0000127\command{bdist\_wininst} command. For example:
Greg Ward16aafcd2000-04-09 04:06:44 +0000128\begin{verbatim}
Greg Ward59d382e2000-05-26 01:04:47 +0000129python setup.py bdist_wininst
Greg Ward16aafcd2000-04-09 04:06:44 +0000130\end{verbatim}
Greg Ward1d8f57a2000-08-05 00:43:11 +0000131will create an executable installer, \file{Foo-1.0.win32.exe}, in the
132current directory.
Greg Ward16aafcd2000-04-09 04:06:44 +0000133
Greg Ward1d8f57a2000-08-05 00:43:11 +0000134\XXX{not implemented yet}
Greg Ward59d382e2000-05-26 01:04:47 +0000135(Another way to create executable installers for Windows is with the
136\command{bdist\_wise} command, which uses Wise---the commercial
137installer-generator used to create Python's own installer---to create
138the installer. Wise-based installers are more appropriate for large,
139industrial-strength applications that need the full capabilities of a
140``real'' installer. \command{bdist\_wininst} creates a self-extracting
141zip file with a minimal user interface, which is enough for small- to
142medium-sized module collections. You'll need to have version XXX of
Greg Ward370248d2000-06-24 01:45:47 +0000143Wise installed on your system for the \command{bdist\_wise} command to
144work; it's available from \url{http://foo/bar/baz}.)
Greg Ward59d382e2000-05-26 01:04:47 +0000145
Greg Ward1d8f57a2000-08-05 00:43:11 +0000146Currently (Distutils 0.9.1), the are only other useful built
147distribution format is RPM, implemented by the \command{bdist\_rpm}
148command. For example, the following command will create an RPM file
149called \file{Foo-1.0.noarch.rpm}:
150\begin{verbatim}
151python setup.py bdist_rpm
152\end{verbatim}
153(This uses the \command{rpm} command, so has to be run on an RPM-based
154system such as Red Hat Linux, SuSE Linux, or Mandrake Linux.)
155
156You can find out what distribution formats are available at any time by
157running
158\begin{verbatim}
159python setup.py bdist --help-formats
160\end{verbatim}
Greg Ward16aafcd2000-04-09 04:06:44 +0000161
162
163\subsection{General Python terminology}
Greg Warde78298a2000-04-28 17:12:24 +0000164\label{python-terms}
Greg Ward16aafcd2000-04-09 04:06:44 +0000165
166If you're reading this document, you probably have a good idea of what
167modules, extensions, and so forth are. Nevertheless, just to be sure
168that everyone is operating from a common starting point, we offer the
169following glossary of common Python terms:
170\begin{description}
171\item[module] the basic unit of code reusability in Python: a block of
Greg Ward1d8f57a2000-08-05 00:43:11 +0000172 code imported by some other code. Three types of modules concern us
173 here: pure Python modules, extension modules, and packages.
Greg Ward16aafcd2000-04-09 04:06:44 +0000174\item[pure Python module] a module written in Python and contained in a
175 single \file{.py} file (and possibly associated \file{.pyc} and/or
176 \file{.pyo} files). Sometimes referred to as a ``pure module.''
177\item[extension module] a module written in the low-level language of
178 the Python implemention: C/C++ for CPython, Java for JPython.
179 Typically contained in a single dynamically loadable pre-compiled
180 file, e.g. a shared object (\file{.so}) file for CPython extensions on
181 Unix, a DLL (given the \file{.pyd} extension) for CPython extensions
Greg Ward1bbe3292000-06-25 03:14:13 +0000182 on Windows, or a Java class file for JPython extensions. (Note that
183 currently, the Distutils only handles C/C++ extensions for CPython.)
Greg Ward16aafcd2000-04-09 04:06:44 +0000184\item[package] a module that contains other modules; typically contained
185 in a directory in the filesystem and distinguished from other
186 directories by the presence of a file \file{\_\_init\_\_.py}.
Greg Ward6153fa12000-05-26 02:24:28 +0000187\item[root package] the root of the hierarchy of packages. (This isn't
188 really a package, since it doesn't have an \file{\_\_init\_\_.py}
189 file. But we have to call it something.) The vast majority of the
190 standard library is in the root package, as are many small, standalone
191 third-party modules that don't belong to a larger module collection.
192 Unlike regular packages, modules in the root package can be found in
193 many directories: in fact, every directory listed in \code{sys.path}
194 can contribute modules to the root package.
Greg Ward16aafcd2000-04-09 04:06:44 +0000195\end{description}
196
197
198\subsection{Distutils-specific terminology}
Greg Warde78298a2000-04-28 17:12:24 +0000199\label{distutils-term}
Greg Ward16aafcd2000-04-09 04:06:44 +0000200
201The following terms apply more specifically to the domain of
202distributing Python modules using the Distutils:
203\begin{description}
204\item[module distribution] a collection of Python modules distributed
205 together as a single downloadable resource and meant to be installed
206 \emph{en masse}. Examples of some well-known module distributions are
207 Numeric Python, PyXML, PIL (the Python Imaging Library), or
208 mxDateTime. (This would be called a \emph{package}, except that term
Greg Ward59d382e2000-05-26 01:04:47 +0000209 is already taken in the Python context: a single module distribution
210 may contain zero, one, or many Python packages.)
Greg Ward16aafcd2000-04-09 04:06:44 +0000211\item[pure module distribution] a module distribution that contains only
212 pure Python modules and packages. Sometimes referred to as a ``pure
213 distribution.''
214\item[non-pure module distribution] a module distribution that contains
215 at least one extension module. Sometimes referred to as a ``non-pure
216 distribution.''
217\item[distribution root] the top-level directory of your source tree (or
218 source distribution); the directory where \file{setup.py} exists and
219 is run from
220\end{description}
221
222
223\section{Writing the Setup Script}
Greg Warde78298a2000-04-28 17:12:24 +0000224\label{setup-script}
Greg Ward16aafcd2000-04-09 04:06:44 +0000225
226The setup script is the centre of all activity in building,
227distributing, and installing modules using the Distutils. The main
228purpose of the setup script is to describe your module distribution to
Greg Wardd5767a52000-04-19 22:48:09 +0000229the Distutils, so that the various commands that operate on your modules
Greg Ward59d382e2000-05-26 01:04:47 +0000230do the right thing. As we saw in section~\ref{simple-example} above,
231the setup script consists mainly of a call to \function{setup()}, and
Greg Ward1bbe3292000-06-25 03:14:13 +0000232most information supplied to the Distutils by the module developer is
233supplied as keyword arguments to \function{setup()}.
Greg Ward16aafcd2000-04-09 04:06:44 +0000234
235Here's a slightly more involved example, which we'll follow for the next
236couple of sections: the Distutils' own setup script. (Keep in mind that
Greg Ward1d8f57a2000-08-05 00:43:11 +0000237although the Distutils are included with Python 1.6 and later, they also
238have an independent existence so that Python 1.5.2 users can use them to
239install other module distributions. The Distutils' own setup script,
240shown here, is used to install the package into Python 1.5.2.)
Greg Ward16aafcd2000-04-09 04:06:44 +0000241
242\begin{verbatim}
243#!/usr/bin/env python
244
245from distutils.core import setup
246
247setup (name = "Distutils",
248 version = "1.0",
Greg Ward1d8f57a2000-08-05 00:43:11 +0000249 description = "Python Distribution Utilities",
Greg Ward16aafcd2000-04-09 04:06:44 +0000250 author = "Greg Ward",
251 author_email = "gward@python.net",
252 url = "http://www.python.org/sigs/distutils-sig/",
253
254 packages = ['distutils', 'distutils.command'],
255 )
256\end{verbatim}
257There are only two differences between this and the trivial one-file
Greg Warde78298a2000-04-28 17:12:24 +0000258distribution presented in section~\ref{simple-example}: more
Greg Ward16aafcd2000-04-09 04:06:44 +0000259meta-data, and the specification of pure Python modules by package,
260rather than by module. This is important since the Distutils consist of
261a couple of dozen modules split into (so far) two packages; an explicit
262list of every module would be tedious to generate and difficult to
263maintain.
264
Greg Ward46b98e32000-04-14 01:53:36 +0000265Note that any pathnames (files or directories) supplied in the setup
266script should be written using the Unix convention, i.e.
267slash-separated. The Distutils will take care of converting this
Greg Ward59d382e2000-05-26 01:04:47 +0000268platform-neutral representation into whatever is appropriate on your
Greg Ward46b98e32000-04-14 01:53:36 +0000269current platform before actually using the pathname. This makes your
270setup script portable across operating systems, which of course is one
271of the major goals of the Distutils. In this spirit, all pathnames in
Greg Ward59d382e2000-05-26 01:04:47 +0000272this document are slash-separated (Mac OS programmers should keep in
273mind that the \emph{absence} of a leading slash indicates a relative
274path, the opposite of the Mac OS convention with colons).
Greg Ward46b98e32000-04-14 01:53:36 +0000275
Greg Ward16aafcd2000-04-09 04:06:44 +0000276
Greg Ward2afffd42000-08-06 20:37:24 +0000277\subsection{Listing whole packages}
278\label{listing-packages}
Greg Ward16aafcd2000-04-09 04:06:44 +0000279
280The \option{packages} option tells the Distutils to process (build,
281distribute, install, etc.) all pure Python modules found in each package
282mentioned in the \option{packages} list. In order to do this, of
283course, there has to be a correspondence between package names and
284directories in the filesystem. The default correspondence is the most
Greg Ward1ecc2512000-04-19 22:36:24 +0000285obvious one, i.e. package \module{distutils} is found in the directory
Greg Ward16aafcd2000-04-09 04:06:44 +0000286\file{distutils} relative to the distribution root. Thus, when you say
287\code{packages = ['foo']} in your setup script, you are promising that
288the Distutils will find a file \file{foo/\_\_init\_\_.py} (which might
289be spelled differently on your system, but you get the idea) relative to
290the directory where your setup script lives. (If you break this
291promise, the Distutils will issue a warning but process the broken
292package anyways.)
293
294If you use a different convention to lay out your source directory,
295that's no problem: you just have to supply the \option{package\_dir}
296option to tell the Distutils about your convention. For example, say
Greg Ward1d8f57a2000-08-05 00:43:11 +0000297you keep all Python source under \file{lib}, so that modules in the
298``root package'' (i.e., not in any package at all) are right in
299\file{lib}, modules in the \module{foo} package are in \file{lib/foo},
300and so forth. Then you would put
Greg Ward16aafcd2000-04-09 04:06:44 +0000301\begin{verbatim}
302package_dir = {'': 'lib'}
303\end{verbatim}
304in your setup script. (The keys to this dictionary are package names,
Greg Ward1d8f57a2000-08-05 00:43:11 +0000305and an empty package name stands for the root package. The values are
306directory names relative to your distribution root.) In this case, when
307you say \code{packages = ['foo']}, you are promising that the file
Greg Ward16aafcd2000-04-09 04:06:44 +0000308\file{lib/foo/\_\_init\_\_.py} exists.
309
Greg Ward1ecc2512000-04-19 22:36:24 +0000310Another possible convention is to put the \module{foo} package right in
311\file{lib}, the \module{foo.bar} package in \file{lib/bar}, etc. This
Greg Ward16aafcd2000-04-09 04:06:44 +0000312would be written in the setup script as
313\begin{verbatim}
314package_dir = {'foo': 'lib'}
315\end{verbatim}
Greg Ward59d382e2000-05-26 01:04:47 +0000316A \code{\var{package}: \var{dir}} entry in the \option{package\_dir}
317dictionary implicitly applies to all packages below \var{package}, so
318the \module{foo.bar} case is automatically handled here. In this
319example, having \code{packages = ['foo', 'foo.bar']} tells the Distutils
320to look for \file{lib/\_\_init\_\_.py} and
321\file{lib/bar/\_\_init\_\_.py}. (Keep in mind that although
322\option{package\_dir} applies recursively, you must explicitly list all
323packages in \option{packages}: the Distutils will \emph{not} recursively
324scan your source tree looking for any directory with an
325\file{\_\_init\_\_.py} file.)
Greg Ward16aafcd2000-04-09 04:06:44 +0000326
327
328\subsection{Listing individual modules}
Greg Warde78298a2000-04-28 17:12:24 +0000329\label{listing-modules}
Greg Ward16aafcd2000-04-09 04:06:44 +0000330
331For a small module distribution, you might prefer to list all modules
332rather than listing packages---especially the case of a single module
333that goes in the ``root package'' (i.e., no package at all). This
Greg Warde78298a2000-04-28 17:12:24 +0000334simplest case was shown in section~\ref{simple-example}; here is a
Greg Ward16aafcd2000-04-09 04:06:44 +0000335slightly more involved example:
336\begin{verbatim}
337py_modules = ['mod1', 'pkg.mod2']
338\end{verbatim}
339This describes two modules, one of them in the ``root'' package, the
Greg Wardd5767a52000-04-19 22:48:09 +0000340other in the \module{pkg} package. Again, the default package/directory
341layout implies that these two modules can be found in \file{mod1.py} and
342\file{pkg/mod2.py}, and that \file{pkg/\_\_init\_\_.py} exists as well.
Greg Ward2afffd42000-08-06 20:37:24 +0000343And again, you can override the package/directory correspondence using
344the \option{package\_dir} option.
Greg Ward59d382e2000-05-26 01:04:47 +0000345
346
347\subsection{Describing extension modules}
348\label{sec:describing-extensions}
349
Greg Ward2afffd42000-08-06 20:37:24 +0000350Just as writing Python extension modules is a bit more complicated than
351writing pure Python modules, describing them to the Distutils is a bit
352more complicated. Unlike pure modules, it's not enough just to list
353modules or packages and expect the Distutils to go out and find the
354right files; you have to specify the extension name, source file(s), and
355any compile/link requirements (include directories, libraries to link
356with, etc.).
357
358All of this is done through another keyword argument to
359\function{setup()}, the \option{extensions} option. \option{extensions}
360is just a list of \class{Extension} instances, each of which describes a
361single extension module. Suppose your distribution includes a single
362extension, called \module{foo} and implemented by \file{foo.c}. If no
363additional instructions to the compiler/linker are needed, describing
364this extension is quite simple:
365\begin{verbatim}
366Extension("foo", ["foo.c"])
367\end{verbatim}
368The \class{Extension} class can be imported from
369\module{distutils.core}, along with \function{setup()}. Thus, the setup
370script for a module distribution that contains only this one extension
371and nothing else might be:
372\begin{verbatim}
373from distutils.core import setup, Extension
374setup(name = "foo", version = "1.0",
375 extensions = [Extension("foo", ["foo.c"])])
376\end{verbatim}
377
378The \class{Extension} class (actually, the underlying extension-building
379machinery implemented by the \command{built\_ext} command) supports a
380great deal of flexibility in describing Python extensions, which is
381explained in the following sections.
382
383
384\subsubsection{Extension names and packages}
385
386The first argument to the \class{Extension} constructor is always the
387name of the extension, including any package names. For example,
388\begin{verbatim}
389Extension("foo", ["src/foo1.c", "src/foo2.c"])
390\end{verbatim}
391describes an extension that lives in the root package, while
392\begin{verbatim}
393Extension("pkg.foo", ["src/foo1.c", "src/foo2.c"])
394\end{verbatim}
395describes the same extension in the \module{pkg} package. The source
396files and resulting object code are identical in both cases; the only
397difference is where in the filesystem (and therefore where in Python's
398namespace hierarchy) the resulting extension lives.
399
400If you have a number of extensions all in the same package (or all under
401the same base package), use the \option{ext\_package} keyword argument
402to \function{setup()}. For example,
403\begin{verbatim}
404setup(...
405 ext_package = "pkg",
406 extensions = [Extension("foo", ["foo.c"]),
407 Extension("subpkg.bar", ["bar.c"])]
408 )
409\end{verbatim}
410will compile \file{foo.c} to the extension \module{pkg.foo}, and
411\file{bar.c} to \module{pkg.subpkg.bar}.
412
413
414\subsubsection{Extension source files}
415
416The second argument to the \class{Extension} constructor is a list of
417source files. Since the Distutils currently only support C/C++
418extensions, these are normally C/C++ source files. (Be sure to use
419appropriate extensions to distinguish C++ source files: \file{.cc} and
420\file{.cpp} seem to be recognized by both Unix and Windows compilers.)
421
422However, you can also include SWIG interface (\file{.i}) files in the
423list; the \command{build\_ext} command knows how to deal with SWIG
424extensions: it will run SWIG on the interface file and compile the
425resulting C/C++ file into your extension.
426
427\XXX{SWIG support is rough around the edges and largely untested;
428 especially SWIG support of C++ extensions! Explain in more detail
429 here when the interface firms up.}
430
431On some platforms, you can include non-source files that are processed
432by the compiler and included in your extension. Currently, this just
433means Windows resource files for Visual C++. \XXX{get more detail on
434 this feature from Thomas Heller!}
435
436
437\subsubsection{Preprocessor options}
438
439Three optional arguments to \class{Extension} will help if you need to
440specify include directories to search or preprocessor macros to
441define/undefine: \code{include\_dirs}, \code{define\_macros}, and
442\code{undef\_macros}.
443
444For example, if your extension requires header files in the
445\file{include} directory under your distribution root, use the
446\code{include\_dirs} option:
447\begin{verbatim}
448Extension("foo", ["foo.c"], include_dirs=["include"])
449\end{verbatim}
450
451You can specify absolute directories there; if you know that your
452extension will only be built on Unix systems with X11R6 installed to
453\file{/usr}, you can get away with
454\begin{verbatim}
455Extension("foo", ["foo.c"], include_dirs=["/usr/include/X11"])
456\end{verbatim}
457You should avoid this sort of non-portable usage if you plan to
458distribute your code: it's probably better to write your code to include
459(e.g.) \code{<X11/Xlib.h>}.
460
461If you need to include header files from some other Python extension,
462you can take advantage of the fact that the Distutils install extension
463header files in a consistent way. For example, the Numerical Python
464header files are installed (on a standard Unix installation) to
465\file{/usr/local/include/python1.5/Numerical}. (The exact location will
466differ according to your platform and Python installation.) Since the
467Python include directory---\file{/usr/local/include/python1.5} in this
468case---is always included in the search path when building Python
469extensions, the best approach is to include (e.g.)
470\code{<Numerical/arrayobject.h>}. If you insist on putting the
471\file{Numerical} include directory right into your header search path,
472though, you can find that directory using the Distutils
473\module{sysconfig} module:
474\begin{verbatim}
475from distutils.sysconfig import get_python_inc
476incdir = os.path.join(get_python_inc(plat_specific=1), "Numerical")
477setup(...,
478 Extension(..., include_dirs=[incdir]))
479\end{verbatim}
480Even though this is quite portable---it will work on any Python
481installation, regardless of platform---it's probably easier to just
482write your C code in the sensible way.
483
484You can define and undefine pre-processor macros with the
485\code{define\_macros} and \code{undef\_macros} options.
486\code{define\_macros} takes a list of \code{(name, value)} tuples, where
487\code{name} is the name of the macro to define (a string) and
488\code{value} is its value: either a string or \code{None}. (Defining a
489macro \code{FOO} to \code{None} is the equivalent of a bare
490\code{\#define FOO} in your C source: with most compilers, this sets
491\code{FOO} to the string \code{1}.) \code{undef\_macros} is just
492a list of macros to undefine.
493
494For example:
495\begin{verbatim}
496Extension(...,
497 define_macros=[('NDEBUG', '1')],
498 ('HAVE_STRFTIME', None),
499 undef_macros=['HAVE_FOO', 'HAVE_BAR'])
500\end{verbatim}
501is the equivalent of having this at the top of every C source file:
502\begin{verbatim}
503#define NDEBUG 1
504#define HAVE_STRFTIME
505#undef HAVE_FOO
506#undef HAVE_BAR
507\end{verbatim}
508
509
510\subsubsection{Library options}
511
512You can also specify the libraries to link against when building your
513extension, and the directories to search for those libraries. The
514\code{libraries} option is a list of libraries to link against,
515\code{library\_dirs} is a list of directories to search for libraries at
516link-time, and \code{runtime\_library\_dirs} is a list of directories to
517search for shared (dynamically loaded) libraries at run-time.
518
519For example, if you need to link against libraries known to be in the
520standard library search path on target systems
521\begin{verbatim}
522Extension(...,
523 libraries=["gdbm", "readline"])
524\end{verbatim}
525
526If you need to link with libraries in a non-standard location, you'll
527have to include the location in \code{library\_dirs}:
528\begin{verbatim}
529Extension(...,
530 library_dirs=["/usr/X11R6/lib"],
531 libraries=["X11", "Xt"])
532\end{verbatim}
533(Again, this sort of non-portable construct should be avoided if you
534intend to distribute your code.)
535
536\XXX{still undocumented: extra\_objects, extra\_compile\_args,
537 extra\_link\_args, export\_symbols---none of which are frequently
538 needed, some of which might be completely unnecessary!}
Greg Ward16aafcd2000-04-09 04:06:44 +0000539
540
541\section{Writing the Setup Configuration File}
Greg Warde78298a2000-04-28 17:12:24 +0000542\label{setup-config}
Greg Ward16aafcd2000-04-09 04:06:44 +0000543
Greg Ward16aafcd2000-04-09 04:06:44 +0000544Often, it's not possible to write down everything needed to build a
545distribution \emph{a priori}. You need to get some information from the
546user, or from the user's system, in order to proceed. For example, you
547might include an optional extension module that provides an interface to
548a particular C library. If that library is installed on the user's
549system, then you can build your optional extension---but you need to
550know where to find the header and library file. If it's not installed,
551you need to know this so you can omit your optional extension.
552
553The preferred way to do this, of course, would be for you to tell the
554Distutils which optional features (C libraries, system calls, external
555utilities, etc.) you're looking for, and it would inspect the user's
556system and try to find them. This functionality may appear in a future
557version of the Distutils, but it isn't there now. So, for the time
558being, we rely on the user building and installing your software to
559provide the necessary information. The vehicle for doing so is the
560setup configuration file, \file{setup.cfg}.
561
562\XXX{need more here!}
563
564
565\section{Creating a Source Distribution}
Greg Warde78298a2000-04-28 17:12:24 +0000566\label{source-dist}
Greg Ward16aafcd2000-04-09 04:06:44 +0000567
Greg Warde78298a2000-04-28 17:12:24 +0000568As shown in section~\ref{simple-example}, you use the
Greg Ward16aafcd2000-04-09 04:06:44 +0000569\command{sdist} command to create a source distribution. In the
570simplest case,
571\begin{verbatim}
572python setup.py sdist
573\end{verbatim}
Greg Ward19c67f82000-06-24 01:33:16 +0000574(assuming you haven't specified any \command{sdist} options in the setup
575script or config file), \command{sdist} creates the archive of the
Greg Ward16aafcd2000-04-09 04:06:44 +0000576default format for the current platform. The default formats are:
577\begin{tableii}{ll}{textrm}%
578 {Platform}{Default archive format for source distributions}
579 \lineii{Unix}{gzipped tar file (\file{.tar.gz})}
580 \lineii{Windows}{zip file}
581\end{tableii}
Greg Wardd5767a52000-04-19 22:48:09 +0000582You can specify as many formats as you like using the
583\longprogramopt{formats} option, for example:
Greg Ward16aafcd2000-04-09 04:06:44 +0000584\begin{verbatim}
585python setup.py sdist --formats=gztar,zip
586\end{verbatim}
587to create a gzipped tarball and a zip file. The available formats are:
Greg Ward46b98e32000-04-14 01:53:36 +0000588\begin{tableiii}{l|l|c}{code}%
589 {Format}{Description}{Notes}
590 \lineiii{zip}{zip file (\file{.zip})}{(1)}
591 \lineiii{gztar}{gzipped tar file (\file{.tar.gz})}{(2)}
592 \lineiii{ztar}{compressed tar file (\file{.tar.Z})}{}
593 \lineiii{tar}{tar file (\file{.tar})}{}
594\end{tableiii}
595
596\noindent Notes:
597\begin{description}
598\item[(1)] default on Windows
599\item[(2)] default on Unix
600\end{description}
Greg Ward16aafcd2000-04-09 04:06:44 +0000601
602
603\subsection{The manifest and manifest template}
Greg Warde78298a2000-04-28 17:12:24 +0000604\label{manifest}
Greg Ward16aafcd2000-04-09 04:06:44 +0000605
606Without any additional information, the \command{sdist} command puts a
607minimal set of files into the source distribution:
608\begin{itemize}
Greg Wardfacb8db2000-04-09 04:32:40 +0000609\item all Python source files implied by the \option{py\_modules} and
Greg Ward16aafcd2000-04-09 04:06:44 +0000610 \option{packages} options
Greg Wardfacb8db2000-04-09 04:32:40 +0000611\item all C source files mentioned in the \option{ext\_modules} or
Greg Ward16aafcd2000-04-09 04:06:44 +0000612 \option{libraries} options (\XXX{getting C library sources currently
Greg Wardfacb8db2000-04-09 04:32:40 +0000613 broken -- no get\_source\_files() method in build\_clib.py!})
Greg Ward16aafcd2000-04-09 04:06:44 +0000614\item anything that looks like a test script: \file{test/test*.py}
615 (currently, the Distutils don't do anything with test scripts except
616 include them in source distributions, but in the future there will be
617 a standard for testing Python module distributions)
618\item \file{README.txt} (or \file{README}) and \file{setup.py}
619\end{itemize}
620Sometimes this is enough, but usually you will want to specify
621additional files to distribute. The typical way to do this is to write
622a \emph{manifest template}, called \file{MANIFEST.in} by default. The
623\command{sdist} command processes this template and generates a manifest
624file, \file{MANIFEST}. (If you prefer, you can skip the manifest
625template and generate the manifest yourself: it just lists one file per
626line.)
627
628The manifest template has one command per line, where each command
629specifies a set of files to include or exclude from the source
630distribution. For an example, again we turn to the Distutils' own
631manifest template:
632\begin{verbatim}
633include *.txt
Greg Ward87da1ea2000-04-21 04:35:25 +0000634recursive-include examples *.txt *.py
Greg Ward16aafcd2000-04-09 04:06:44 +0000635prune examples/sample?/build
636\end{verbatim}
637The meanings should be fairly clear: include all files in the
638distribution root matching \code{*.txt}, all files anywhere under the
639\file{examples} directory matching \code{*.txt} or \code{*.py}, and
640exclude all directories matching \code{examples/sample?/build}. There
641are several other commands available in the manifest template
Greg Warde78298a2000-04-28 17:12:24 +0000642mini-language; see section~\ref{sdist-cmd}.
Greg Ward16aafcd2000-04-09 04:06:44 +0000643
644The order of commands in the manifest template very much matters:
645initially, we have the list of default files as described above, and
646each command in the template adds to or removes from that list of files.
647When we have fully processed the manifest template, we have our complete
648list of files. This list is written to the manifest for future
649reference, and then used to build the source distribution archive(s).
650
Greg Ward46b98e32000-04-14 01:53:36 +0000651Following the Distutils' own manifest template, let's trace how the
652\command{sdist} command will build the list of files to include in the
653Distutils source distribution:
Greg Ward16aafcd2000-04-09 04:06:44 +0000654\begin{enumerate}
655\item include all Python source files in the \file{distutils} and
656 \file{distutils/command} subdirectories (because packages
657 corresponding to those two directories were mentioned in the
658 \option{packages} option in the setup script)
659\item include \file{test/test*.py} (always included)
660\item include \file{README.txt} and \file{setup.py} (always included)
661\item include \file{*.txt} in the distribution root (this will find
662 \file{README.txt} a second time, but such redundancies are weeded out
663 later)
664\item in the sub-tree under \file{examples}, include anything matching
665 \file{*.txt}
666\item in the sub-tree under \file{examples}, include anything matching
667 \file{*.py}
668\item remove all files in the sub-trees starting at directories matching
669 \file{examples/sample?/build}---this may exclude files included by the
670 previous two steps, so it's important that the \code{prune} command in
671 the manifest template comes after the two \code{recursive-include}
672 commands
Greg Wardfacb8db2000-04-09 04:32:40 +0000673\end{enumerate}
Greg Ward16aafcd2000-04-09 04:06:44 +0000674
Greg Ward46b98e32000-04-14 01:53:36 +0000675Just like in the setup script, file and directory names in the manifest
676template should always be slash-separated; the Distutils will take care
677of converting them to the standard representation on your platform.
678That way, the manifest template is portable across operating systems.
679
Greg Ward16aafcd2000-04-09 04:06:44 +0000680
681\subsection{Manifest-related options}
Greg Warde78298a2000-04-28 17:12:24 +0000682\label{manifest-options}
Greg Ward16aafcd2000-04-09 04:06:44 +0000683
684The normal course of operations for the \command{sdist} command is as
685follows:
686\begin{itemize}
Greg Ward46b98e32000-04-14 01:53:36 +0000687\item if the manifest file, \file{MANIFEST} doesn't exist, read
688 \file{MANIFEST.in} and create the manifest
Greg Ward1d8f57a2000-08-05 00:43:11 +0000689\item if either \file{MANIFEST.in} or the setup script (\file{setup.py})
690 are more recent than \file{MANIFEST}, recreate \file{MANIFEST} by
691 reading \file{MANIFEST.in}
Greg Ward16aafcd2000-04-09 04:06:44 +0000692\item use the list of files now in \file{MANIFEST} (either just
693 generated or read in) to create the source distribution archive(s)
694\end{itemize}
695There are a couple of options that modify this behaviour.
696
697First, you might want to force the manifest to be regenerated---for
698example, if you have added or removed files or directories that match an
699existing pattern in the manifest template, you should regenerate the
700manifest:
701\begin{verbatim}
702python setup.py sdist --force-manifest
703\end{verbatim}
Greg Ward16aafcd2000-04-09 04:06:44 +0000704
705Or, you might just want to (re)generate the manifest, but not create a
706source distribution:
707\begin{verbatim}
708python setup.py sdist --manifest-only
709\end{verbatim}
Greg Warda021aca2000-04-19 22:34:11 +0000710(\longprogramopt{manifest-only} implies \longprogramopt{force-manifest}.)
Greg Ward16aafcd2000-04-09 04:06:44 +0000711
712If you don't want to use the default file set, you can supply the
Greg Wardd5767a52000-04-19 22:48:09 +0000713\longprogramopt{no-defaults} option. If you use
714\longprogramopt{no-defaults} and don't supply a manifest template (or
715it's empty, or nothing matches the patterns in it), then your source
716distribution will be empty.
Greg Ward16aafcd2000-04-09 04:06:44 +0000717
718
719\section{Creating Built Distributions}
Greg Warde78298a2000-04-28 17:12:24 +0000720\label{built-dist}
Greg Ward16aafcd2000-04-09 04:06:44 +0000721
Greg Ward46b98e32000-04-14 01:53:36 +0000722A ``built distribution'' is what you're probably used to thinking of
723either as a ``binary package'' or an ``installer'' (depending on your
724background). It's not necessarily binary, though, because it might
725contain only Python source code and/or byte-code; and we don't call it a
726package, because that word is already spoken for in Python. (And
727``installer'' is a term specific to the Windows world. \XXX{do Mac
728 people use it?})
Greg Ward16aafcd2000-04-09 04:06:44 +0000729
Greg Ward46b98e32000-04-14 01:53:36 +0000730A built distribution is how you make life as easy as possible for
731installers of your module distribution: for users of RPM-based Linux
732systems, it's a binary RPM; for Windows users, it's an executable
733installer; for Debian-based Linux users, it's a Debian package; and so
734forth. Obviously, no one person will be able to create built
735distributions for every platform under the sun, so the Distutils is
736designed to enable module developers to concentrate on their
737specialty---writing code and creating source distributions---while an
738intermediary species of \emph{packager} springs up to turn source
Greg Ward19c67f82000-06-24 01:33:16 +0000739distributions into built distributions for as many platforms as there
Greg Ward46b98e32000-04-14 01:53:36 +0000740are packagers.
741
742Of course, the module developer could be his own packager; or the
743packager could be a volunteer ``out there'' somewhere who has access to
744a platform which the original developer does not; or it could be
745software periodically grabbing new source distributions and turning them
746into built distributions for as many platforms as the software has
747access to. Regardless of the nature of the beast, a packager uses the
748setup script and the \command{bdist} command family to generate built
749distributions.
750
751As a simple example, if I run the following command in the Distutils
752source tree:
753\begin{verbatim}
754python setup.py bdist
755\end{verbatim}
756then the Distutils builds my module distribution (the Distutils itself
757in this case), does a ``fake'' installation (also in the \file{build}
758directory), and creates the default type of built distribution for my
Greg Ward1d8f57a2000-08-05 00:43:11 +0000759platform. Currently, the default format for built distributions is a
760``dumb'' archive---tarball on Unix, ZIP file on Windows. (These are
761called ``dumb'' built distributions, because they must be unpacked in a
762specific location to work.)
763
764Thus, the above command on a Unix system creates
765\file{Distutils-0.9.1.\filevar{plat}.tar.gz}; unpacking this tarball
766from the root of the filesystemq installs the Distutils just as though
767you had downloaded the source distribution and run \code{python setup.py
768 install}. (Assuming that the target system has their Python
769installation laid out the same as you do---another reason these are
770called ``dumb'' distributions.) Obviously, for pure Python
771distributions, this isn't a huge win---but for non-pure distributions,
772which include extensions that would need to be compiled, it can mean the
773difference between someone being able to use your extensions or not.
Greg Ward46b98e32000-04-14 01:53:36 +0000774
775\XXX{filenames are inaccurate here!}
776
Greg Wardd5767a52000-04-19 22:48:09 +0000777The \command{bdist} command has a \longprogramopt{format} option,
Greg Ward1d8f57a2000-08-05 00:43:11 +0000778similar to the \command{sdist} command, which you can use to select the
779types of built distribution to generate: for example,
Greg Ward46b98e32000-04-14 01:53:36 +0000780\begin{verbatim}
781python setup.py bdist --format=zip
782\end{verbatim}
783would, when run on a Unix system, create
Greg Ward1d8f57a2000-08-05 00:43:11 +0000784\file{Distutils-0.8.\filevar{plat}.zip}---again, this archive would be
785unpacked from the root directory to install the Distutils.
Greg Ward46b98e32000-04-14 01:53:36 +0000786
787The available formats for built distributions are:
788\begin{tableiii}{l|l|c}{code}%
789 {Format}{Description}{Notes}
Greg Ward1d8f57a2000-08-05 00:43:11 +0000790 \lineiii{zip}{zip file (\file{.zip})}{}
791 \lineiii{gztar}{gzipped tar file (\file{.tar.gz})}{(1)}
Greg Ward46b98e32000-04-14 01:53:36 +0000792 \lineiii{ztar}{compressed tar file (\file{.tar.Z})}{}
793 \lineiii{tar}{tar file (\file{.tar})}{}
Greg Ward1d8f57a2000-08-05 00:43:11 +0000794 \lineiii{rpm}{RPM}{}
795 \lineiii{srpm}{source RPM}{\XXX{to do!}}
796 \lineiii{wininst}{self-extracting ZIP file for Windows}{(2)}
797 %\lineiii{wise}{Wise installer for Windows}{(3)}
Greg Ward46b98e32000-04-14 01:53:36 +0000798\end{tableiii}
799
800\noindent Notes:
801\begin{description}
Greg Ward1d8f57a2000-08-05 00:43:11 +0000802\item[(1)] default on Unix
803\item[(2)] default on Windows \XXX{to-do!}
804%\item[(3)] not implemented yet
Greg Ward46b98e32000-04-14 01:53:36 +0000805\end{description}
806
807You don't have to use the \command{bdist} command with the
Greg Wardd5767a52000-04-19 22:48:09 +0000808\longprogramopt{formats} option; you can also use the command that
Greg Ward1d8f57a2000-08-05 00:43:11 +0000809directly implements the format you're interested in. Some of these
Greg Ward46b98e32000-04-14 01:53:36 +0000810\command{bdist} ``sub-commands'' actually generate several similar
811formats; for instance, the \command{bdist\_dumb} command generates all
812the ``dumb'' archive formats (\code{tar}, \code{ztar}, \code{gztar}, and
813\code{zip}), and \command{bdist\_rpm} generates both binary and source
814RPMs. The \command{bdist} sub-commands, and the formats generated by
815each, are:
816\begin{tableii}{l|l}{command}%
817 {Command}{Formats}
818 \lineii{bdist\_dumb}{tar, ztar, gztar, zip}
819 \lineii{bdist\_rpm}{rpm, srpm}
Greg Ward1d8f57a2000-08-05 00:43:11 +0000820 \lineii{bdist\_wininst}{wininst}
821 %\lineii{bdist\_wise}{wise}
Greg Ward46b98e32000-04-14 01:53:36 +0000822\end{tableii}
Greg Ward16aafcd2000-04-09 04:06:44 +0000823
824\section{Examples}
Greg Warde78298a2000-04-28 17:12:24 +0000825\label{examples}
Greg Ward16aafcd2000-04-09 04:06:44 +0000826
827
828\subsection{Pure Python distribution (by module)}
Greg Warde78298a2000-04-28 17:12:24 +0000829\label{pure-mod}
Greg Ward16aafcd2000-04-09 04:06:44 +0000830
831
832\subsection{Pure Python distribution (by package)}
Greg Warde78298a2000-04-28 17:12:24 +0000833\label{pure-pkg}
Greg Ward16aafcd2000-04-09 04:06:44 +0000834
835
836\subsection{Single extension module}
Greg Warde78298a2000-04-28 17:12:24 +0000837\label{single-ext}
Greg Ward16aafcd2000-04-09 04:06:44 +0000838
839
840\subsection{Multiple extension modules}
Greg Warde78298a2000-04-28 17:12:24 +0000841\label{multiple-ext}
Greg Ward16aafcd2000-04-09 04:06:44 +0000842
843
844\subsection{Putting it all together}
845
846
Greg Ward4a9e7222000-04-25 02:57:36 +0000847
848\section{Extending the Distutils}
Greg Warde78298a2000-04-28 17:12:24 +0000849\label{extending}
Greg Ward4a9e7222000-04-25 02:57:36 +0000850
851
852\subsection{Extending existing commands}
Greg Warde78298a2000-04-28 17:12:24 +0000853\label{extend-existing}
Greg Ward4a9e7222000-04-25 02:57:36 +0000854
855
856\subsection{Writing new commands}
Greg Warde78298a2000-04-28 17:12:24 +0000857\label{new-commands}
Greg Ward4a9e7222000-04-25 02:57:36 +0000858
859
860
Greg Ward16aafcd2000-04-09 04:06:44 +0000861\section{Reference}
Greg Warde78298a2000-04-28 17:12:24 +0000862\label{ref}
Greg Ward16aafcd2000-04-09 04:06:44 +0000863
864
Greg Wardfacb8db2000-04-09 04:32:40 +0000865\subsection{Building modules: the \protect\command{build} command family}
Greg Warde78298a2000-04-28 17:12:24 +0000866\label{build-cmds}
Greg Ward16aafcd2000-04-09 04:06:44 +0000867
Greg Wardfacb8db2000-04-09 04:32:40 +0000868\subsubsection{\protect\command{build}}
Greg Warde78298a2000-04-28 17:12:24 +0000869\label{build-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000870
Greg Wardfacb8db2000-04-09 04:32:40 +0000871\subsubsection{\protect\command{build\_py}}
Greg Warde78298a2000-04-28 17:12:24 +0000872\label{build-py-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000873
Greg Wardfacb8db2000-04-09 04:32:40 +0000874\subsubsection{\protect\command{build\_ext}}
Greg Warde78298a2000-04-28 17:12:24 +0000875\label{build-ext-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000876
Greg Wardfacb8db2000-04-09 04:32:40 +0000877\subsubsection{\protect\command{build\_clib}}
Greg Warde78298a2000-04-28 17:12:24 +0000878\label{build-clib-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000879
880
Greg Wardfacb8db2000-04-09 04:32:40 +0000881\subsection{Installing modules: the \protect\command{install} command family}
Greg Warde78298a2000-04-28 17:12:24 +0000882\label{install-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000883
Gregory P. Smith147e5f32000-05-12 00:58:18 +0000884The install command ensures that the build commands have been run and then
885runs the subcommands \command{install\_lib},
886\command{install\_data} and
887\command{install\_scripts}.
888
889\subsubsection{\protect\command{install\_lib}}
890\label{sec:install-lib-cmd}
891
892\subsubsection{\protect\command{install\_data}}
893\label{sec:install-data-cmd}
894This command installs all data files provided with the distribution.
895
896\subsubsection{\protect\command{install\_scripts}}
897\label{sec:install-scripts-cmd}
898This command installs all (Python) scripts in the distribution.
899
Greg Ward16aafcd2000-04-09 04:06:44 +0000900
Greg Wardfacb8db2000-04-09 04:32:40 +0000901\subsection{Cleaning up: the \protect\command{clean} command}
Greg Warde78298a2000-04-28 17:12:24 +0000902\label{clean-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000903
904
Greg Wardfacb8db2000-04-09 04:32:40 +0000905\subsection{Creating a source distribution: the \protect\command{sdist} command}
Greg Warde78298a2000-04-28 17:12:24 +0000906\label{sdist-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000907
908
909\XXX{fragment moved down from above: needs context!}
910The manifest template commands are:
911\begin{tableii}{ll}{command}{Command}{Description}
Greg Ward87da1ea2000-04-21 04:35:25 +0000912 \lineii{include \var{pat1} \var{pat2} ... }
913 {include all files matching any of the listed patterns}
914 \lineii{exclude \var{pat1} \var{pat2} ... }
915 {exclude all files matching any of the listed patterns}
916 \lineii{recursive-include \var{dir} \var{pat1} \var{pat2} ... }
917 {include all files under \var{dir} matching any of the listed patterns}
918 \lineii{recursive-exclude \var{dir} \var{pat1} \var{pat2} ...}
919 {exclude all files under \var{dir} matching any of the listed patterns}
920 \lineii{global-include \var{pat1} \var{pat2} ...}
Greg Ward1bbe3292000-06-25 03:14:13 +0000921 {include all files anywhere in the source tree matching\\&
Greg Ward87da1ea2000-04-21 04:35:25 +0000922 any of the listed patterns}
923 \lineii{global-exclude \var{pat1} \var{pat2} ...}
Greg Ward1bbe3292000-06-25 03:14:13 +0000924 {exclude all files anywhere in the source tree matching\\&
Greg Ward87da1ea2000-04-21 04:35:25 +0000925 any of the listed patterns}
Greg Ward16aafcd2000-04-09 04:06:44 +0000926 \lineii{prune \var{dir}}{exclude all files under \var{dir}}
927 \lineii{graft \var{dir}}{include all files under \var{dir}}
928\end{tableii}
929The patterns here are Unix-style ``glob'' patterns: \code{*} matches any
930sequence of regular filename characters, \code{?} matches any single
931regular filename character, and \code{[\var{range}]} matches any of the
932characters in \var{range} (e.g., \code{a-z}, \code{a-zA-Z},
Greg Wardfacb8db2000-04-09 04:32:40 +0000933\code{a-f0-9\_.}). The definition of ``regular filename character'' is
Greg Ward16aafcd2000-04-09 04:06:44 +0000934platform-specific: on Unix it is anything except slash; on Windows
935anything except backslash or colon; on Mac OS anything except colon.
936\XXX{Windows and Mac OS support not there yet}
937
938
Greg Wardd5767a52000-04-19 22:48:09 +0000939\subsection{Creating a ``built'' distribution: the
940 \protect\command{bdist} command family}
Greg Warde78298a2000-04-28 17:12:24 +0000941\label{bdist-cmds}
Greg Ward16aafcd2000-04-09 04:06:44 +0000942
943
Greg Wardfacb8db2000-04-09 04:32:40 +0000944\subsubsection{\protect\command{blib}}
Greg Ward16aafcd2000-04-09 04:06:44 +0000945
Greg Wardfacb8db2000-04-09 04:32:40 +0000946\subsubsection{\protect\command{blib\_dumb}}
Greg Ward16aafcd2000-04-09 04:06:44 +0000947
Greg Wardfacb8db2000-04-09 04:32:40 +0000948\subsubsection{\protect\command{blib\_rpm}}
Greg Ward16aafcd2000-04-09 04:06:44 +0000949
Greg Wardfacb8db2000-04-09 04:32:40 +0000950\subsubsection{\protect\command{blib\_wise}}
Greg Ward16aafcd2000-04-09 04:06:44 +0000951
952
953
954
955
956
957
958
Greg Wardabc52162000-02-26 00:52:48 +0000959\end{document}