blob: 3f1001d04bd4c1842a7cca2877323343b5acced6 [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 Warde3cca262000-08-31 16:36:31 +000011\makeindex
Greg Ward16aafcd2000-04-09 04:06:44 +000012
Greg Wardabc52162000-02-26 00:52:48 +000013\begin{document}
14
Greg Wardfacb8db2000-04-09 04:32:40 +000015\maketitle
Greg Warde3cca262000-08-31 16:36:31 +000016\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 Wardfacb8db2000-04-09 04:32:40 +000025\tableofcontents
Greg Ward16aafcd2000-04-09 04:06:44 +000026
27\section{Introduction}
Greg Warde78298a2000-04-28 17:12:24 +000028\label{intro}
Greg Ward16aafcd2000-04-09 04:06:44 +000029
30In the past, Python module developers have not had much infrastructure
31support for distributing modules, nor have Python users had much support
32for installing and maintaining third-party modules. With the
33introduction of the Python Distribution Utilities (Distutils for short)
Greg Ward1d8f57a2000-08-05 00:43:11 +000034in Python 1.6, this situation should start to improve.
Greg Ward16aafcd2000-04-09 04:06:44 +000035
36This document only covers using the Distutils to distribute your Python
Greg Ward1d8f57a2000-08-05 00:43:11 +000037modules. Using the Distutils does not tie you to Python 1.6, though:
38the 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 Ward16aafcd2000-04-09 04:06:44 +000040download and install the Distutils separately before they can install
Greg Ward1d8f57a2000-08-05 00:43:11 +000041your modules. Python 1.6 (or later) users, of course, won't have to add
42anything to their Python installation in order to use the Distutils to
43install third-party modules.
Greg Ward16aafcd2000-04-09 04:06:44 +000044
45This document concentrates on the role of developer/distributor: if
Fred Drake01df4532000-06-30 03:36:41 +000046you're looking for information on installing Python modules, you
47should refer to the \citetitle[../inst/inst.html]{Installing Python
48Modules} manual.
Greg Ward16aafcd2000-04-09 04:06:44 +000049
50
Greg Wardfacb8db2000-04-09 04:32:40 +000051\section{Concepts \& Terminology}
Greg Warde78298a2000-04-28 17:12:24 +000052\label{concepts}
Greg Ward16aafcd2000-04-09 04:06:44 +000053
54Using the Distutils is quite simple, both for module developers and for
55users/administrators installing third-party modules. As a developer,
56your responsibilites (apart from writing solid, well-documented and
57well-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}
64Each of these tasks is covered in this document.
65
66Not all module developers have access to a multitude of platforms, so
67it's not always feasible to expect them to create a multitude of built
68distributions. It is hoped that a class of intermediaries, called
Greg Ward19c67f82000-06-24 01:33:16 +000069\emph{packagers}, will arise to address this need. Packagers will take
70source distributions released by module developers, build them on one or
71more platforms, and release the resulting built distributions. Thus,
72users on the most popular platforms will be able to install most popular
73Python module distributions in the most natural way for their platform,
74without having to run a single setup script or compile a line of code.
Greg Ward16aafcd2000-04-09 04:06:44 +000075
76
77\subsection{A simple example}
Greg Warde78298a2000-04-28 17:12:24 +000078\label{simple-example}
Greg Ward16aafcd2000-04-09 04:06:44 +000079
80The setup script is usually quite simple, although since it's written in
Greg Ward1d8f57a2000-08-05 00:43:11 +000081Python, there are no arbitrary limits to what you can do with it. If
82all you want to do is distribute a module called \module{foo}, contained
83in a file \file{foo.py}, then your setup script can be as little as
84this:
Greg Ward16aafcd2000-04-09 04:06:44 +000085\begin{verbatim}
86from distutils.core import setup
87setup (name = "foo",
88 version = "1.0",
89 py_modules = ["foo"])
90\end{verbatim}
Greg Ward370248d2000-06-24 01:45:47 +000091
Greg Ward16aafcd2000-04-09 04:06:44 +000092Some observations:
93\begin{itemize}
Greg Ward370248d2000-06-24 01:45:47 +000094\item most information that you supply to the Distutils is supplied as
Greg Wardfacb8db2000-04-09 04:32:40 +000095 keyword arguments to the \function{setup()} function
Greg Ward16aafcd2000-04-09 04:06:44 +000096\item those keyword arguments fall into two categories: package
97 meta-data (name, version number) and information about what's in the
Greg Ward370248d2000-06-24 01:45:47 +000098 package (a list of pure Python modules, in this case)
Greg Ward16aafcd2000-04-09 04:06:44 +000099\item modules are specified by module name, not filename (the same will
100 hold true for packages and extensions)
101\item it's recommended that you supply a little more meta-data, in
102 particular your name, email address and a URL for the project
103\end{itemize}
104
Greg Ward370248d2000-06-24 01:45:47 +0000105To create a source distribution for this module, you would create a
106setup script, \file{setup.py}, containing the above code, and run:
Greg Ward16aafcd2000-04-09 04:06:44 +0000107\begin{verbatim}
108python setup.py sdist
109\end{verbatim}
110which will create an archive file (e.g., tarball on Unix, zip file on
111Windows) containing your setup script, \file{setup.py}, and your module,
112\file{foo.py}. The archive file will be named \file{Foo-1.0.tar.gz} (or
113\file{.zip}), and will unpack into a directory \file{Foo-1.0}.
114
115If an end-user wishes to install your \module{foo} module, all she has
Greg Ward59d382e2000-05-26 01:04:47 +0000116to do is download \file{Foo-1.0.tar.gz} (or \file{.zip}), unpack it,
Greg Ward16aafcd2000-04-09 04:06:44 +0000117and---from the \file{Foo-1.0} directory---run
118\begin{verbatim}
119python setup.py install
120\end{verbatim}
121which will ultimately copy \file{foo.py} to the appropriate directory
122for third-party modules in their Python installation.
123
124This simple example demonstrates some fundamental concepts of the
125Distutils: first, both developers and installers have the same basic
126user interface, i.e. the setup script. The difference is which
127Distutils \emph{commands} they use: the \command{sdist} command is
128almost exclusively for module developers, while \command{install} is
129more often for installers (although most developers will want to install
130their own code occasionally).
131
Greg Ward16aafcd2000-04-09 04:06:44 +0000132If you want to make things really easy for your users, you can create
133one or more built distributions for them. For instance, if you are
134running on a Windows machine, and want to make things easy for other
135Windows users, you can create an executable installer (the most
136appropriate type of built distribution for this platform) with the
Greg Ward59d382e2000-05-26 01:04:47 +0000137\command{bdist\_wininst} command. For example:
Greg Ward16aafcd2000-04-09 04:06:44 +0000138\begin{verbatim}
Greg Ward59d382e2000-05-26 01:04:47 +0000139python setup.py bdist_wininst
Greg Ward16aafcd2000-04-09 04:06:44 +0000140\end{verbatim}
Greg Ward1d8f57a2000-08-05 00:43:11 +0000141will create an executable installer, \file{Foo-1.0.win32.exe}, in the
142current directory.
Greg Ward16aafcd2000-04-09 04:06:44 +0000143
Greg Ward1d8f57a2000-08-05 00:43:11 +0000144\XXX{not implemented yet}
Greg Ward59d382e2000-05-26 01:04:47 +0000145(Another way to create executable installers for Windows is with the
146\command{bdist\_wise} command, which uses Wise---the commercial
147installer-generator used to create Python's own installer---to create
148the installer. Wise-based installers are more appropriate for large,
149industrial-strength applications that need the full capabilities of a
150``real'' installer. \command{bdist\_wininst} creates a self-extracting
151zip file with a minimal user interface, which is enough for small- to
152medium-sized module collections. You'll need to have version XXX of
Greg Ward370248d2000-06-24 01:45:47 +0000153Wise installed on your system for the \command{bdist\_wise} command to
154work; it's available from \url{http://foo/bar/baz}.)
Greg Ward59d382e2000-05-26 01:04:47 +0000155
Greg Ward1d8f57a2000-08-05 00:43:11 +0000156Currently (Distutils 0.9.1), the are only other useful built
157distribution format is RPM, implemented by the \command{bdist\_rpm}
158command. For example, the following command will create an RPM file
159called \file{Foo-1.0.noarch.rpm}:
160\begin{verbatim}
161python setup.py bdist_rpm
162\end{verbatim}
163(This uses the \command{rpm} command, so has to be run on an RPM-based
164system such as Red Hat Linux, SuSE Linux, or Mandrake Linux.)
165
166You can find out what distribution formats are available at any time by
167running
168\begin{verbatim}
169python setup.py bdist --help-formats
170\end{verbatim}
Greg Ward16aafcd2000-04-09 04:06:44 +0000171
172
173\subsection{General Python terminology}
Greg Warde78298a2000-04-28 17:12:24 +0000174\label{python-terms}
Greg Ward16aafcd2000-04-09 04:06:44 +0000175
176If you're reading this document, you probably have a good idea of what
177modules, extensions, and so forth are. Nevertheless, just to be sure
178that everyone is operating from a common starting point, we offer the
179following glossary of common Python terms:
180\begin{description}
181\item[module] the basic unit of code reusability in Python: a block of
Greg Ward1d8f57a2000-08-05 00:43:11 +0000182 code imported by some other code. Three types of modules concern us
183 here: pure Python modules, extension modules, and packages.
Greg Ward16aafcd2000-04-09 04:06:44 +0000184\item[pure Python module] a module written in Python and contained in a
185 single \file{.py} file (and possibly associated \file{.pyc} and/or
186 \file{.pyo} files). Sometimes referred to as a ``pure module.''
187\item[extension module] a module written in the low-level language of
188 the Python implemention: C/C++ for CPython, Java for JPython.
189 Typically contained in a single dynamically loadable pre-compiled
190 file, e.g. a shared object (\file{.so}) file for CPython extensions on
191 Unix, a DLL (given the \file{.pyd} extension) for CPython extensions
Greg Ward1bbe3292000-06-25 03:14:13 +0000192 on Windows, or a Java class file for JPython extensions. (Note that
193 currently, the Distutils only handles C/C++ extensions for CPython.)
Greg Ward16aafcd2000-04-09 04:06:44 +0000194\item[package] a module that contains other modules; typically contained
195 in a directory in the filesystem and distinguished from other
196 directories by the presence of a file \file{\_\_init\_\_.py}.
Greg Ward6153fa12000-05-26 02:24:28 +0000197\item[root package] the root of the hierarchy of packages. (This isn't
198 really a package, since it doesn't have an \file{\_\_init\_\_.py}
199 file. But we have to call it something.) The vast majority of the
200 standard library is in the root package, as are many small, standalone
201 third-party modules that don't belong to a larger module collection.
202 Unlike regular packages, modules in the root package can be found in
203 many directories: in fact, every directory listed in \code{sys.path}
204 can contribute modules to the root package.
Greg Ward16aafcd2000-04-09 04:06:44 +0000205\end{description}
206
207
208\subsection{Distutils-specific terminology}
Greg Warde78298a2000-04-28 17:12:24 +0000209\label{distutils-term}
Greg Ward16aafcd2000-04-09 04:06:44 +0000210
211The following terms apply more specifically to the domain of
212distributing Python modules using the Distutils:
213\begin{description}
214\item[module distribution] a collection of Python modules distributed
215 together as a single downloadable resource and meant to be installed
216 \emph{en masse}. Examples of some well-known module distributions are
217 Numeric Python, PyXML, PIL (the Python Imaging Library), or
218 mxDateTime. (This would be called a \emph{package}, except that term
Greg Ward59d382e2000-05-26 01:04:47 +0000219 is already taken in the Python context: a single module distribution
220 may contain zero, one, or many Python packages.)
Greg Ward16aafcd2000-04-09 04:06:44 +0000221\item[pure module distribution] a module distribution that contains only
222 pure Python modules and packages. Sometimes referred to as a ``pure
223 distribution.''
224\item[non-pure module distribution] a module distribution that contains
225 at least one extension module. Sometimes referred to as a ``non-pure
226 distribution.''
227\item[distribution root] the top-level directory of your source tree (or
228 source distribution); the directory where \file{setup.py} exists and
229 is run from
230\end{description}
231
232
233\section{Writing the Setup Script}
Greg Warde78298a2000-04-28 17:12:24 +0000234\label{setup-script}
Greg Ward16aafcd2000-04-09 04:06:44 +0000235
236The setup script is the centre of all activity in building,
237distributing, and installing modules using the Distutils. The main
238purpose of the setup script is to describe your module distribution to
Greg Wardd5767a52000-04-19 22:48:09 +0000239the Distutils, so that the various commands that operate on your modules
Greg Ward59d382e2000-05-26 01:04:47 +0000240do the right thing. As we saw in section~\ref{simple-example} above,
241the setup script consists mainly of a call to \function{setup()}, and
Greg Ward1bbe3292000-06-25 03:14:13 +0000242most information supplied to the Distutils by the module developer is
243supplied as keyword arguments to \function{setup()}.
Greg Ward16aafcd2000-04-09 04:06:44 +0000244
245Here's a slightly more involved example, which we'll follow for the next
246couple of sections: the Distutils' own setup script. (Keep in mind that
Greg Ward1d8f57a2000-08-05 00:43:11 +0000247although the Distutils are included with Python 1.6 and later, they also
248have an independent existence so that Python 1.5.2 users can use them to
249install other module distributions. The Distutils' own setup script,
250shown here, is used to install the package into Python 1.5.2.)
Greg Ward16aafcd2000-04-09 04:06:44 +0000251
252\begin{verbatim}
253#!/usr/bin/env python
254
255from distutils.core import setup
256
257setup (name = "Distutils",
258 version = "1.0",
Greg Ward1d8f57a2000-08-05 00:43:11 +0000259 description = "Python Distribution Utilities",
Greg Ward16aafcd2000-04-09 04:06:44 +0000260 author = "Greg Ward",
261 author_email = "gward@python.net",
262 url = "http://www.python.org/sigs/distutils-sig/",
263
264 packages = ['distutils', 'distutils.command'],
265 )
266\end{verbatim}
267There are only two differences between this and the trivial one-file
Greg Warde78298a2000-04-28 17:12:24 +0000268distribution presented in section~\ref{simple-example}: more
Greg Ward16aafcd2000-04-09 04:06:44 +0000269meta-data, and the specification of pure Python modules by package,
270rather than by module. This is important since the Distutils consist of
271a couple of dozen modules split into (so far) two packages; an explicit
272list of every module would be tedious to generate and difficult to
273maintain.
274
Greg Ward46b98e32000-04-14 01:53:36 +0000275Note that any pathnames (files or directories) supplied in the setup
276script should be written using the Unix convention, i.e.
277slash-separated. The Distutils will take care of converting this
Greg Ward59d382e2000-05-26 01:04:47 +0000278platform-neutral representation into whatever is appropriate on your
Greg Ward46b98e32000-04-14 01:53:36 +0000279current platform before actually using the pathname. This makes your
280setup script portable across operating systems, which of course is one
281of the major goals of the Distutils. In this spirit, all pathnames in
Greg Ward59d382e2000-05-26 01:04:47 +0000282this document are slash-separated (Mac OS programmers should keep in
283mind that the \emph{absence} of a leading slash indicates a relative
284path, the opposite of the Mac OS convention with colons).
Greg Ward46b98e32000-04-14 01:53:36 +0000285
Greg Ward16aafcd2000-04-09 04:06:44 +0000286
Greg Ward2afffd42000-08-06 20:37:24 +0000287\subsection{Listing whole packages}
288\label{listing-packages}
Greg Ward16aafcd2000-04-09 04:06:44 +0000289
290The \option{packages} option tells the Distutils to process (build,
291distribute, install, etc.) all pure Python modules found in each package
292mentioned in the \option{packages} list. In order to do this, of
293course, there has to be a correspondence between package names and
294directories in the filesystem. The default correspondence is the most
Greg Ward1ecc2512000-04-19 22:36:24 +0000295obvious one, i.e. package \module{distutils} is found in the directory
Greg Ward16aafcd2000-04-09 04:06:44 +0000296\file{distutils} relative to the distribution root. Thus, when you say
297\code{packages = ['foo']} in your setup script, you are promising that
298the Distutils will find a file \file{foo/\_\_init\_\_.py} (which might
299be spelled differently on your system, but you get the idea) relative to
300the directory where your setup script lives. (If you break this
301promise, the Distutils will issue a warning but process the broken
302package anyways.)
303
304If you use a different convention to lay out your source directory,
305that's no problem: you just have to supply the \option{package\_dir}
306option to tell the Distutils about your convention. For example, say
Greg Ward1d8f57a2000-08-05 00:43:11 +0000307you keep all Python source under \file{lib}, so that modules in the
308``root package'' (i.e., not in any package at all) are right in
309\file{lib}, modules in the \module{foo} package are in \file{lib/foo},
310and so forth. Then you would put
Greg Ward16aafcd2000-04-09 04:06:44 +0000311\begin{verbatim}
312package_dir = {'': 'lib'}
313\end{verbatim}
314in your setup script. (The keys to this dictionary are package names,
Greg Ward1d8f57a2000-08-05 00:43:11 +0000315and an empty package name stands for the root package. The values are
316directory names relative to your distribution root.) In this case, when
317you say \code{packages = ['foo']}, you are promising that the file
Greg Ward16aafcd2000-04-09 04:06:44 +0000318\file{lib/foo/\_\_init\_\_.py} exists.
319
Greg Ward1ecc2512000-04-19 22:36:24 +0000320Another possible convention is to put the \module{foo} package right in
321\file{lib}, the \module{foo.bar} package in \file{lib/bar}, etc. This
Greg Ward16aafcd2000-04-09 04:06:44 +0000322would be written in the setup script as
323\begin{verbatim}
324package_dir = {'foo': 'lib'}
325\end{verbatim}
Greg Ward59d382e2000-05-26 01:04:47 +0000326A \code{\var{package}: \var{dir}} entry in the \option{package\_dir}
327dictionary implicitly applies to all packages below \var{package}, so
328the \module{foo.bar} case is automatically handled here. In this
329example, having \code{packages = ['foo', 'foo.bar']} tells the Distutils
330to look for \file{lib/\_\_init\_\_.py} and
331\file{lib/bar/\_\_init\_\_.py}. (Keep in mind that although
332\option{package\_dir} applies recursively, you must explicitly list all
333packages in \option{packages}: the Distutils will \emph{not} recursively
334scan your source tree looking for any directory with an
335\file{\_\_init\_\_.py} file.)
Greg Ward16aafcd2000-04-09 04:06:44 +0000336
337
338\subsection{Listing individual modules}
Greg Warde78298a2000-04-28 17:12:24 +0000339\label{listing-modules}
Greg Ward16aafcd2000-04-09 04:06:44 +0000340
341For a small module distribution, you might prefer to list all modules
342rather than listing packages---especially the case of a single module
343that goes in the ``root package'' (i.e., no package at all). This
Greg Warde78298a2000-04-28 17:12:24 +0000344simplest case was shown in section~\ref{simple-example}; here is a
Greg Ward16aafcd2000-04-09 04:06:44 +0000345slightly more involved example:
346\begin{verbatim}
347py_modules = ['mod1', 'pkg.mod2']
348\end{verbatim}
349This describes two modules, one of them in the ``root'' package, the
Greg Wardd5767a52000-04-19 22:48:09 +0000350other in the \module{pkg} package. Again, the default package/directory
351layout implies that these two modules can be found in \file{mod1.py} and
352\file{pkg/mod2.py}, and that \file{pkg/\_\_init\_\_.py} exists as well.
Greg Ward2afffd42000-08-06 20:37:24 +0000353And again, you can override the package/directory correspondence using
354the \option{package\_dir} option.
Greg Ward59d382e2000-05-26 01:04:47 +0000355
356
357\subsection{Describing extension modules}
Greg Ward1365a302000-08-31 14:47:05 +0000358\label{describing-extensions}
Greg Ward59d382e2000-05-26 01:04:47 +0000359
Greg Ward2afffd42000-08-06 20:37:24 +0000360Just as writing Python extension modules is a bit more complicated than
361writing pure Python modules, describing them to the Distutils is a bit
362more complicated. Unlike pure modules, it's not enough just to list
363modules or packages and expect the Distutils to go out and find the
364right files; you have to specify the extension name, source file(s), and
365any compile/link requirements (include directories, libraries to link
366with, etc.).
367
368All of this is done through another keyword argument to
369\function{setup()}, the \option{extensions} option. \option{extensions}
370is just a list of \class{Extension} instances, each of which describes a
371single extension module. Suppose your distribution includes a single
372extension, called \module{foo} and implemented by \file{foo.c}. If no
373additional instructions to the compiler/linker are needed, describing
374this extension is quite simple:
375\begin{verbatim}
376Extension("foo", ["foo.c"])
377\end{verbatim}
378The \class{Extension} class can be imported from
379\module{distutils.core}, along with \function{setup()}. Thus, the setup
380script for a module distribution that contains only this one extension
381and nothing else might be:
382\begin{verbatim}
383from distutils.core import setup, Extension
384setup(name = "foo", version = "1.0",
385 extensions = [Extension("foo", ["foo.c"])])
386\end{verbatim}
387
388The \class{Extension} class (actually, the underlying extension-building
389machinery implemented by the \command{built\_ext} command) supports a
390great deal of flexibility in describing Python extensions, which is
391explained in the following sections.
392
393
394\subsubsection{Extension names and packages}
395
396The first argument to the \class{Extension} constructor is always the
397name of the extension, including any package names. For example,
398\begin{verbatim}
399Extension("foo", ["src/foo1.c", "src/foo2.c"])
400\end{verbatim}
401describes an extension that lives in the root package, while
402\begin{verbatim}
403Extension("pkg.foo", ["src/foo1.c", "src/foo2.c"])
404\end{verbatim}
405describes the same extension in the \module{pkg} package. The source
406files and resulting object code are identical in both cases; the only
407difference is where in the filesystem (and therefore where in Python's
408namespace hierarchy) the resulting extension lives.
409
410If you have a number of extensions all in the same package (or all under
411the same base package), use the \option{ext\_package} keyword argument
412to \function{setup()}. For example,
413\begin{verbatim}
414setup(...
415 ext_package = "pkg",
416 extensions = [Extension("foo", ["foo.c"]),
417 Extension("subpkg.bar", ["bar.c"])]
418 )
419\end{verbatim}
420will compile \file{foo.c} to the extension \module{pkg.foo}, and
421\file{bar.c} to \module{pkg.subpkg.bar}.
422
423
424\subsubsection{Extension source files}
425
426The second argument to the \class{Extension} constructor is a list of
427source files. Since the Distutils currently only support C/C++
428extensions, these are normally C/C++ source files. (Be sure to use
429appropriate extensions to distinguish C++ source files: \file{.cc} and
430\file{.cpp} seem to be recognized by both Unix and Windows compilers.)
431
432However, you can also include SWIG interface (\file{.i}) files in the
433list; the \command{build\_ext} command knows how to deal with SWIG
434extensions: it will run SWIG on the interface file and compile the
435resulting C/C++ file into your extension.
436
437\XXX{SWIG support is rough around the edges and largely untested;
438 especially SWIG support of C++ extensions! Explain in more detail
439 here when the interface firms up.}
440
441On some platforms, you can include non-source files that are processed
442by the compiler and included in your extension. Currently, this just
443means Windows resource files for Visual C++. \XXX{get more detail on
444 this feature from Thomas Heller!}
445
446
447\subsubsection{Preprocessor options}
448
449Three optional arguments to \class{Extension} will help if you need to
450specify include directories to search or preprocessor macros to
451define/undefine: \code{include\_dirs}, \code{define\_macros}, and
452\code{undef\_macros}.
453
454For example, if your extension requires header files in the
455\file{include} directory under your distribution root, use the
456\code{include\_dirs} option:
457\begin{verbatim}
458Extension("foo", ["foo.c"], include_dirs=["include"])
459\end{verbatim}
460
461You can specify absolute directories there; if you know that your
462extension will only be built on Unix systems with X11R6 installed to
463\file{/usr}, you can get away with
464\begin{verbatim}
465Extension("foo", ["foo.c"], include_dirs=["/usr/include/X11"])
466\end{verbatim}
467You should avoid this sort of non-portable usage if you plan to
468distribute your code: it's probably better to write your code to include
469(e.g.) \code{<X11/Xlib.h>}.
470
471If you need to include header files from some other Python extension,
472you can take advantage of the fact that the Distutils install extension
473header files in a consistent way. For example, the Numerical Python
474header files are installed (on a standard Unix installation) to
475\file{/usr/local/include/python1.5/Numerical}. (The exact location will
476differ according to your platform and Python installation.) Since the
477Python include directory---\file{/usr/local/include/python1.5} in this
478case---is always included in the search path when building Python
479extensions, the best approach is to include (e.g.)
480\code{<Numerical/arrayobject.h>}. If you insist on putting the
481\file{Numerical} include directory right into your header search path,
482though, you can find that directory using the Distutils
483\module{sysconfig} module:
484\begin{verbatim}
485from distutils.sysconfig import get_python_inc
486incdir = os.path.join(get_python_inc(plat_specific=1), "Numerical")
487setup(...,
488 Extension(..., include_dirs=[incdir]))
489\end{verbatim}
490Even though this is quite portable---it will work on any Python
491installation, regardless of platform---it's probably easier to just
492write your C code in the sensible way.
493
494You can define and undefine pre-processor macros with the
495\code{define\_macros} and \code{undef\_macros} options.
496\code{define\_macros} takes a list of \code{(name, value)} tuples, where
497\code{name} is the name of the macro to define (a string) and
498\code{value} is its value: either a string or \code{None}. (Defining a
499macro \code{FOO} to \code{None} is the equivalent of a bare
500\code{\#define FOO} in your C source: with most compilers, this sets
501\code{FOO} to the string \code{1}.) \code{undef\_macros} is just
502a list of macros to undefine.
503
504For example:
505\begin{verbatim}
506Extension(...,
507 define_macros=[('NDEBUG', '1')],
508 ('HAVE_STRFTIME', None),
509 undef_macros=['HAVE_FOO', 'HAVE_BAR'])
510\end{verbatim}
511is the equivalent of having this at the top of every C source file:
512\begin{verbatim}
513#define NDEBUG 1
514#define HAVE_STRFTIME
515#undef HAVE_FOO
516#undef HAVE_BAR
517\end{verbatim}
518
519
520\subsubsection{Library options}
521
522You can also specify the libraries to link against when building your
523extension, and the directories to search for those libraries. The
524\code{libraries} option is a list of libraries to link against,
525\code{library\_dirs} is a list of directories to search for libraries at
526link-time, and \code{runtime\_library\_dirs} is a list of directories to
527search for shared (dynamically loaded) libraries at run-time.
528
529For example, if you need to link against libraries known to be in the
530standard library search path on target systems
531\begin{verbatim}
532Extension(...,
533 libraries=["gdbm", "readline"])
534\end{verbatim}
535
536If you need to link with libraries in a non-standard location, you'll
537have to include the location in \code{library\_dirs}:
538\begin{verbatim}
539Extension(...,
540 library_dirs=["/usr/X11R6/lib"],
541 libraries=["X11", "Xt"])
542\end{verbatim}
543(Again, this sort of non-portable construct should be avoided if you
544intend to distribute your code.)
545
546\XXX{still undocumented: extra\_objects, extra\_compile\_args,
547 extra\_link\_args, export\_symbols---none of which are frequently
548 needed, some of which might be completely unnecessary!}
Greg Ward16aafcd2000-04-09 04:06:44 +0000549
550
551\section{Writing the Setup Configuration File}
Greg Warde78298a2000-04-28 17:12:24 +0000552\label{setup-config}
Greg Ward16aafcd2000-04-09 04:06:44 +0000553
Greg Ward16aafcd2000-04-09 04:06:44 +0000554Often, it's not possible to write down everything needed to build a
555distribution \emph{a priori}. You need to get some information from the
556user, or from the user's system, in order to proceed. For example, you
557might include an optional extension module that provides an interface to
558a particular C library. If that library is installed on the user's
559system, then you can build your optional extension---but you need to
560know where to find the header and library file. If it's not installed,
561you need to know this so you can omit your optional extension.
562
563The preferred way to do this, of course, would be for you to tell the
564Distutils which optional features (C libraries, system calls, external
565utilities, etc.) you're looking for, and it would inspect the user's
566system and try to find them. This functionality may appear in a future
567version of the Distutils, but it isn't there now. So, for the time
568being, we rely on the user building and installing your software to
569provide the necessary information. The vehicle for doing so is the
570setup configuration file, \file{setup.cfg}.
571
572\XXX{need more here!}
573
574
575\section{Creating a Source Distribution}
Greg Warde78298a2000-04-28 17:12:24 +0000576\label{source-dist}
Greg Ward16aafcd2000-04-09 04:06:44 +0000577
Greg Warde78298a2000-04-28 17:12:24 +0000578As shown in section~\ref{simple-example}, you use the
Greg Ward16aafcd2000-04-09 04:06:44 +0000579\command{sdist} command to create a source distribution. In the
580simplest case,
581\begin{verbatim}
582python setup.py sdist
583\end{verbatim}
Greg Ward19c67f82000-06-24 01:33:16 +0000584(assuming you haven't specified any \command{sdist} options in the setup
585script or config file), \command{sdist} creates the archive of the
Greg Ward16aafcd2000-04-09 04:06:44 +0000586default format for the current platform. The default formats are:
587\begin{tableii}{ll}{textrm}%
588 {Platform}{Default archive format for source distributions}
589 \lineii{Unix}{gzipped tar file (\file{.tar.gz})}
590 \lineii{Windows}{zip file}
591\end{tableii}
Greg Wardd5767a52000-04-19 22:48:09 +0000592You can specify as many formats as you like using the
593\longprogramopt{formats} option, for example:
Greg Ward16aafcd2000-04-09 04:06:44 +0000594\begin{verbatim}
595python setup.py sdist --formats=gztar,zip
596\end{verbatim}
597to create a gzipped tarball and a zip file. The available formats are:
Greg Ward46b98e32000-04-14 01:53:36 +0000598\begin{tableiii}{l|l|c}{code}%
599 {Format}{Description}{Notes}
600 \lineiii{zip}{zip file (\file{.zip})}{(1)}
601 \lineiii{gztar}{gzipped tar file (\file{.tar.gz})}{(2)}
602 \lineiii{ztar}{compressed tar file (\file{.tar.Z})}{}
603 \lineiii{tar}{tar file (\file{.tar})}{}
604\end{tableiii}
605
606\noindent Notes:
607\begin{description}
608\item[(1)] default on Windows
609\item[(2)] default on Unix
610\end{description}
Greg Ward16aafcd2000-04-09 04:06:44 +0000611
612
613\subsection{The manifest and manifest template}
Greg Warde78298a2000-04-28 17:12:24 +0000614\label{manifest}
Greg Ward16aafcd2000-04-09 04:06:44 +0000615
616Without any additional information, the \command{sdist} command puts a
617minimal set of files into the source distribution:
618\begin{itemize}
Greg Wardfacb8db2000-04-09 04:32:40 +0000619\item all Python source files implied by the \option{py\_modules} and
Greg Ward16aafcd2000-04-09 04:06:44 +0000620 \option{packages} options
Greg Wardfacb8db2000-04-09 04:32:40 +0000621\item all C source files mentioned in the \option{ext\_modules} or
Greg Ward16aafcd2000-04-09 04:06:44 +0000622 \option{libraries} options (\XXX{getting C library sources currently
Greg Wardfacb8db2000-04-09 04:32:40 +0000623 broken -- no get\_source\_files() method in build\_clib.py!})
Greg Ward16aafcd2000-04-09 04:06:44 +0000624\item anything that looks like a test script: \file{test/test*.py}
625 (currently, the Distutils don't do anything with test scripts except
626 include them in source distributions, but in the future there will be
627 a standard for testing Python module distributions)
628\item \file{README.txt} (or \file{README}) and \file{setup.py}
629\end{itemize}
630Sometimes this is enough, but usually you will want to specify
631additional files to distribute. The typical way to do this is to write
632a \emph{manifest template}, called \file{MANIFEST.in} by default. The
633\command{sdist} command processes this template and generates a manifest
634file, \file{MANIFEST}. (If you prefer, you can skip the manifest
635template and generate the manifest yourself: it just lists one file per
636line.)
637
638The manifest template has one command per line, where each command
639specifies a set of files to include or exclude from the source
640distribution. For an example, again we turn to the Distutils' own
641manifest template:
642\begin{verbatim}
643include *.txt
Greg Ward87da1ea2000-04-21 04:35:25 +0000644recursive-include examples *.txt *.py
Greg Ward16aafcd2000-04-09 04:06:44 +0000645prune examples/sample?/build
646\end{verbatim}
647The meanings should be fairly clear: include all files in the
648distribution root matching \code{*.txt}, all files anywhere under the
649\file{examples} directory matching \code{*.txt} or \code{*.py}, and
650exclude all directories matching \code{examples/sample?/build}. There
651are several other commands available in the manifest template
Greg Warde78298a2000-04-28 17:12:24 +0000652mini-language; see section~\ref{sdist-cmd}.
Greg Ward16aafcd2000-04-09 04:06:44 +0000653
654The order of commands in the manifest template very much matters:
655initially, we have the list of default files as described above, and
656each command in the template adds to or removes from that list of files.
657When we have fully processed the manifest template, we have our complete
658list of files. This list is written to the manifest for future
659reference, and then used to build the source distribution archive(s).
660
Greg Ward46b98e32000-04-14 01:53:36 +0000661Following the Distutils' own manifest template, let's trace how the
662\command{sdist} command will build the list of files to include in the
663Distutils source distribution:
Greg Ward16aafcd2000-04-09 04:06:44 +0000664\begin{enumerate}
665\item include all Python source files in the \file{distutils} and
666 \file{distutils/command} subdirectories (because packages
667 corresponding to those two directories were mentioned in the
668 \option{packages} option in the setup script)
669\item include \file{test/test*.py} (always included)
670\item include \file{README.txt} and \file{setup.py} (always included)
671\item include \file{*.txt} in the distribution root (this will find
672 \file{README.txt} a second time, but such redundancies are weeded out
673 later)
674\item in the sub-tree under \file{examples}, include anything matching
675 \file{*.txt}
676\item in the sub-tree under \file{examples}, include anything matching
677 \file{*.py}
678\item remove all files in the sub-trees starting at directories matching
679 \file{examples/sample?/build}---this may exclude files included by the
680 previous two steps, so it's important that the \code{prune} command in
681 the manifest template comes after the two \code{recursive-include}
682 commands
Greg Wardfacb8db2000-04-09 04:32:40 +0000683\end{enumerate}
Greg Ward16aafcd2000-04-09 04:06:44 +0000684
Greg Ward46b98e32000-04-14 01:53:36 +0000685Just like in the setup script, file and directory names in the manifest
686template should always be slash-separated; the Distutils will take care
687of converting them to the standard representation on your platform.
688That way, the manifest template is portable across operating systems.
689
Greg Ward16aafcd2000-04-09 04:06:44 +0000690
691\subsection{Manifest-related options}
Greg Warde78298a2000-04-28 17:12:24 +0000692\label{manifest-options}
Greg Ward16aafcd2000-04-09 04:06:44 +0000693
694The normal course of operations for the \command{sdist} command is as
695follows:
696\begin{itemize}
Greg Ward46b98e32000-04-14 01:53:36 +0000697\item if the manifest file, \file{MANIFEST} doesn't exist, read
698 \file{MANIFEST.in} and create the manifest
Greg Ward1d8f57a2000-08-05 00:43:11 +0000699\item if either \file{MANIFEST.in} or the setup script (\file{setup.py})
700 are more recent than \file{MANIFEST}, recreate \file{MANIFEST} by
701 reading \file{MANIFEST.in}
Greg Ward16aafcd2000-04-09 04:06:44 +0000702\item use the list of files now in \file{MANIFEST} (either just
703 generated or read in) to create the source distribution archive(s)
704\end{itemize}
705There are a couple of options that modify this behaviour.
706
707First, you might want to force the manifest to be regenerated---for
708example, if you have added or removed files or directories that match an
709existing pattern in the manifest template, you should regenerate the
710manifest:
711\begin{verbatim}
712python setup.py sdist --force-manifest
713\end{verbatim}
Greg Ward16aafcd2000-04-09 04:06:44 +0000714
715Or, you might just want to (re)generate the manifest, but not create a
716source distribution:
717\begin{verbatim}
718python setup.py sdist --manifest-only
719\end{verbatim}
Greg Warda021aca2000-04-19 22:34:11 +0000720(\longprogramopt{manifest-only} implies \longprogramopt{force-manifest}.)
Greg Ward16aafcd2000-04-09 04:06:44 +0000721
722If you don't want to use the default file set, you can supply the
Greg Wardd5767a52000-04-19 22:48:09 +0000723\longprogramopt{no-defaults} option. If you use
724\longprogramopt{no-defaults} and don't supply a manifest template (or
725it's empty, or nothing matches the patterns in it), then your source
726distribution will be empty.
Greg Ward16aafcd2000-04-09 04:06:44 +0000727
728
729\section{Creating Built Distributions}
Greg Warde78298a2000-04-28 17:12:24 +0000730\label{built-dist}
Greg Ward16aafcd2000-04-09 04:06:44 +0000731
Greg Ward46b98e32000-04-14 01:53:36 +0000732A ``built distribution'' is what you're probably used to thinking of
733either as a ``binary package'' or an ``installer'' (depending on your
734background). It's not necessarily binary, though, because it might
735contain only Python source code and/or byte-code; and we don't call it a
736package, because that word is already spoken for in Python. (And
737``installer'' is a term specific to the Windows world. \XXX{do Mac
738 people use it?})
Greg Ward16aafcd2000-04-09 04:06:44 +0000739
Greg Ward46b98e32000-04-14 01:53:36 +0000740A built distribution is how you make life as easy as possible for
741installers of your module distribution: for users of RPM-based Linux
742systems, it's a binary RPM; for Windows users, it's an executable
743installer; for Debian-based Linux users, it's a Debian package; and so
744forth. Obviously, no one person will be able to create built
745distributions for every platform under the sun, so the Distutils is
746designed to enable module developers to concentrate on their
747specialty---writing code and creating source distributions---while an
748intermediary species of \emph{packager} springs up to turn source
Greg Ward19c67f82000-06-24 01:33:16 +0000749distributions into built distributions for as many platforms as there
Greg Ward46b98e32000-04-14 01:53:36 +0000750are packagers.
751
752Of course, the module developer could be his own packager; or the
753packager could be a volunteer ``out there'' somewhere who has access to
754a platform which the original developer does not; or it could be
755software periodically grabbing new source distributions and turning them
756into built distributions for as many platforms as the software has
757access to. Regardless of the nature of the beast, a packager uses the
758setup script and the \command{bdist} command family to generate built
759distributions.
760
761As a simple example, if I run the following command in the Distutils
762source tree:
763\begin{verbatim}
764python setup.py bdist
765\end{verbatim}
766then the Distutils builds my module distribution (the Distutils itself
767in this case), does a ``fake'' installation (also in the \file{build}
768directory), and creates the default type of built distribution for my
Greg Ward1d8f57a2000-08-05 00:43:11 +0000769platform. Currently, the default format for built distributions is a
770``dumb'' archive---tarball on Unix, ZIP file on Windows. (These are
771called ``dumb'' built distributions, because they must be unpacked in a
772specific location to work.)
773
774Thus, the above command on a Unix system creates
775\file{Distutils-0.9.1.\filevar{plat}.tar.gz}; unpacking this tarball
776from the root of the filesystemq installs the Distutils just as though
777you had downloaded the source distribution and run \code{python setup.py
778 install}. (Assuming that the target system has their Python
779installation laid out the same as you do---another reason these are
780called ``dumb'' distributions.) Obviously, for pure Python
781distributions, this isn't a huge win---but for non-pure distributions,
782which include extensions that would need to be compiled, it can mean the
783difference between someone being able to use your extensions or not.
Greg Ward46b98e32000-04-14 01:53:36 +0000784
785\XXX{filenames are inaccurate here!}
786
Greg Wardd5767a52000-04-19 22:48:09 +0000787The \command{bdist} command has a \longprogramopt{format} option,
Greg Ward1d8f57a2000-08-05 00:43:11 +0000788similar to the \command{sdist} command, which you can use to select the
789types of built distribution to generate: for example,
Greg Ward46b98e32000-04-14 01:53:36 +0000790\begin{verbatim}
791python setup.py bdist --format=zip
792\end{verbatim}
793would, when run on a Unix system, create
Greg Ward1d8f57a2000-08-05 00:43:11 +0000794\file{Distutils-0.8.\filevar{plat}.zip}---again, this archive would be
795unpacked from the root directory to install the Distutils.
Greg Ward46b98e32000-04-14 01:53:36 +0000796
797The available formats for built distributions are:
798\begin{tableiii}{l|l|c}{code}%
799 {Format}{Description}{Notes}
Greg Ward1d8f57a2000-08-05 00:43:11 +0000800 \lineiii{zip}{zip file (\file{.zip})}{}
801 \lineiii{gztar}{gzipped tar file (\file{.tar.gz})}{(1)}
Greg Ward46b98e32000-04-14 01:53:36 +0000802 \lineiii{ztar}{compressed tar file (\file{.tar.Z})}{}
803 \lineiii{tar}{tar file (\file{.tar})}{}
Greg Ward1d8f57a2000-08-05 00:43:11 +0000804 \lineiii{rpm}{RPM}{}
805 \lineiii{srpm}{source RPM}{\XXX{to do!}}
806 \lineiii{wininst}{self-extracting ZIP file for Windows}{(2)}
807 %\lineiii{wise}{Wise installer for Windows}{(3)}
Greg Ward46b98e32000-04-14 01:53:36 +0000808\end{tableiii}
809
810\noindent Notes:
811\begin{description}
Greg Ward1d8f57a2000-08-05 00:43:11 +0000812\item[(1)] default on Unix
813\item[(2)] default on Windows \XXX{to-do!}
814%\item[(3)] not implemented yet
Greg Ward46b98e32000-04-14 01:53:36 +0000815\end{description}
816
817You don't have to use the \command{bdist} command with the
Greg Wardd5767a52000-04-19 22:48:09 +0000818\longprogramopt{formats} option; you can also use the command that
Greg Ward1d8f57a2000-08-05 00:43:11 +0000819directly implements the format you're interested in. Some of these
Greg Ward46b98e32000-04-14 01:53:36 +0000820\command{bdist} ``sub-commands'' actually generate several similar
821formats; for instance, the \command{bdist\_dumb} command generates all
822the ``dumb'' archive formats (\code{tar}, \code{ztar}, \code{gztar}, and
823\code{zip}), and \command{bdist\_rpm} generates both binary and source
824RPMs. The \command{bdist} sub-commands, and the formats generated by
825each, are:
826\begin{tableii}{l|l}{command}%
827 {Command}{Formats}
828 \lineii{bdist\_dumb}{tar, ztar, gztar, zip}
829 \lineii{bdist\_rpm}{rpm, srpm}
Greg Ward1d8f57a2000-08-05 00:43:11 +0000830 \lineii{bdist\_wininst}{wininst}
831 %\lineii{bdist\_wise}{wise}
Greg Ward46b98e32000-04-14 01:53:36 +0000832\end{tableii}
Greg Ward16aafcd2000-04-09 04:06:44 +0000833
834\section{Examples}
Greg Warde78298a2000-04-28 17:12:24 +0000835\label{examples}
Greg Ward16aafcd2000-04-09 04:06:44 +0000836
837
838\subsection{Pure Python distribution (by module)}
Greg Warde78298a2000-04-28 17:12:24 +0000839\label{pure-mod}
Greg Ward16aafcd2000-04-09 04:06:44 +0000840
841
842\subsection{Pure Python distribution (by package)}
Greg Warde78298a2000-04-28 17:12:24 +0000843\label{pure-pkg}
Greg Ward16aafcd2000-04-09 04:06:44 +0000844
845
846\subsection{Single extension module}
Greg Warde78298a2000-04-28 17:12:24 +0000847\label{single-ext}
Greg Ward16aafcd2000-04-09 04:06:44 +0000848
849
850\subsection{Multiple extension modules}
Greg Warde78298a2000-04-28 17:12:24 +0000851\label{multiple-ext}
Greg Ward16aafcd2000-04-09 04:06:44 +0000852
853
854\subsection{Putting it all together}
855
856
Greg Ward4a9e7222000-04-25 02:57:36 +0000857
858\section{Extending the Distutils}
Greg Warde78298a2000-04-28 17:12:24 +0000859\label{extending}
Greg Ward4a9e7222000-04-25 02:57:36 +0000860
861
862\subsection{Extending existing commands}
Greg Warde78298a2000-04-28 17:12:24 +0000863\label{extend-existing}
Greg Ward4a9e7222000-04-25 02:57:36 +0000864
865
866\subsection{Writing new commands}
Greg Warde78298a2000-04-28 17:12:24 +0000867\label{new-commands}
Greg Ward4a9e7222000-04-25 02:57:36 +0000868
869
870
Greg Ward16aafcd2000-04-09 04:06:44 +0000871\section{Reference}
Greg Warde78298a2000-04-28 17:12:24 +0000872\label{ref}
Greg Ward16aafcd2000-04-09 04:06:44 +0000873
874
Greg Wardfacb8db2000-04-09 04:32:40 +0000875\subsection{Building modules: the \protect\command{build} command family}
Greg Warde78298a2000-04-28 17:12:24 +0000876\label{build-cmds}
Greg Ward16aafcd2000-04-09 04:06:44 +0000877
Greg Wardfacb8db2000-04-09 04:32:40 +0000878\subsubsection{\protect\command{build}}
Greg Warde78298a2000-04-28 17:12:24 +0000879\label{build-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000880
Greg Wardfacb8db2000-04-09 04:32:40 +0000881\subsubsection{\protect\command{build\_py}}
Greg Warde78298a2000-04-28 17:12:24 +0000882\label{build-py-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000883
Greg Wardfacb8db2000-04-09 04:32:40 +0000884\subsubsection{\protect\command{build\_ext}}
Greg Warde78298a2000-04-28 17:12:24 +0000885\label{build-ext-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000886
Greg Wardfacb8db2000-04-09 04:32:40 +0000887\subsubsection{\protect\command{build\_clib}}
Greg Warde78298a2000-04-28 17:12:24 +0000888\label{build-clib-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000889
890
Greg Wardfacb8db2000-04-09 04:32:40 +0000891\subsection{Installing modules: the \protect\command{install} command family}
Greg Warde78298a2000-04-28 17:12:24 +0000892\label{install-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000893
Gregory P. Smith147e5f32000-05-12 00:58:18 +0000894The install command ensures that the build commands have been run and then
895runs the subcommands \command{install\_lib},
896\command{install\_data} and
897\command{install\_scripts}.
898
899\subsubsection{\protect\command{install\_lib}}
Greg Ward1365a302000-08-31 14:47:05 +0000900\label{install-lib-cmd}
Gregory P. Smith147e5f32000-05-12 00:58:18 +0000901
902\subsubsection{\protect\command{install\_data}}
Greg Ward1365a302000-08-31 14:47:05 +0000903\label{install-data-cmd}
Gregory P. Smith147e5f32000-05-12 00:58:18 +0000904This command installs all data files provided with the distribution.
905
906\subsubsection{\protect\command{install\_scripts}}
Greg Ward1365a302000-08-31 14:47:05 +0000907\label{install-scripts-cmd}
Gregory P. Smith147e5f32000-05-12 00:58:18 +0000908This command installs all (Python) scripts in the distribution.
909
Greg Ward16aafcd2000-04-09 04:06:44 +0000910
Greg Wardfacb8db2000-04-09 04:32:40 +0000911\subsection{Cleaning up: the \protect\command{clean} command}
Greg Warde78298a2000-04-28 17:12:24 +0000912\label{clean-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000913
914
Greg Wardfacb8db2000-04-09 04:32:40 +0000915\subsection{Creating a source distribution: the \protect\command{sdist} command}
Greg Warde78298a2000-04-28 17:12:24 +0000916\label{sdist-cmd}
Greg Ward16aafcd2000-04-09 04:06:44 +0000917
918
919\XXX{fragment moved down from above: needs context!}
920The manifest template commands are:
921\begin{tableii}{ll}{command}{Command}{Description}
Greg Ward87da1ea2000-04-21 04:35:25 +0000922 \lineii{include \var{pat1} \var{pat2} ... }
923 {include all files matching any of the listed patterns}
924 \lineii{exclude \var{pat1} \var{pat2} ... }
925 {exclude all files matching any of the listed patterns}
926 \lineii{recursive-include \var{dir} \var{pat1} \var{pat2} ... }
927 {include all files under \var{dir} matching any of the listed patterns}
928 \lineii{recursive-exclude \var{dir} \var{pat1} \var{pat2} ...}
929 {exclude all files under \var{dir} matching any of the listed patterns}
930 \lineii{global-include \var{pat1} \var{pat2} ...}
Greg Ward1bbe3292000-06-25 03:14:13 +0000931 {include all files anywhere in the source tree matching\\&
Greg Ward87da1ea2000-04-21 04:35:25 +0000932 any of the listed patterns}
933 \lineii{global-exclude \var{pat1} \var{pat2} ...}
Greg Ward1bbe3292000-06-25 03:14:13 +0000934 {exclude all files anywhere in the source tree matching\\&
Greg Ward87da1ea2000-04-21 04:35:25 +0000935 any of the listed patterns}
Greg Ward16aafcd2000-04-09 04:06:44 +0000936 \lineii{prune \var{dir}}{exclude all files under \var{dir}}
937 \lineii{graft \var{dir}}{include all files under \var{dir}}
938\end{tableii}
939The patterns here are Unix-style ``glob'' patterns: \code{*} matches any
940sequence of regular filename characters, \code{?} matches any single
941regular filename character, and \code{[\var{range}]} matches any of the
942characters in \var{range} (e.g., \code{a-z}, \code{a-zA-Z},
Greg Wardfacb8db2000-04-09 04:32:40 +0000943\code{a-f0-9\_.}). The definition of ``regular filename character'' is
Greg Ward16aafcd2000-04-09 04:06:44 +0000944platform-specific: on Unix it is anything except slash; on Windows
945anything except backslash or colon; on Mac OS anything except colon.
946\XXX{Windows and Mac OS support not there yet}
947
948
Greg Wardd5767a52000-04-19 22:48:09 +0000949\subsection{Creating a ``built'' distribution: the
950 \protect\command{bdist} command family}
Greg Warde78298a2000-04-28 17:12:24 +0000951\label{bdist-cmds}
Greg Ward16aafcd2000-04-09 04:06:44 +0000952
953
Greg Wardfacb8db2000-04-09 04:32:40 +0000954\subsubsection{\protect\command{blib}}
Greg Ward16aafcd2000-04-09 04:06:44 +0000955
Greg Wardfacb8db2000-04-09 04:32:40 +0000956\subsubsection{\protect\command{blib\_dumb}}
Greg Ward16aafcd2000-04-09 04:06:44 +0000957
Greg Wardfacb8db2000-04-09 04:32:40 +0000958\subsubsection{\protect\command{blib\_rpm}}
Greg Ward16aafcd2000-04-09 04:06:44 +0000959
Greg Wardfacb8db2000-04-09 04:32:40 +0000960\subsubsection{\protect\command{blib\_wise}}
Greg Ward16aafcd2000-04-09 04:06:44 +0000961
962
963
964
965
966
967
968
Greg Wardabc52162000-02-26 00:52:48 +0000969\end{document}