Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 1 | \documentclass{howto} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 2 | \usepackage{distutils} |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 3 | |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 4 | % $Id$ |
| 5 | |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 6 | % TODO |
| 7 | % Document extension.read_setup_file |
| 8 | % Document build_clib command |
| 9 | % |
| 10 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 11 | \title{Distributing Python Modules} |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 12 | |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 13 | \author{Greg Ward} |
Fred Drake | 17f690f | 2001-07-14 02:14:42 +0000 | [diff] [blame] | 14 | \authoraddress{Email: \email{gward@python.net}} |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 15 | |
Greg Ward | e3cca26 | 2000-08-31 16:36:31 +0000 | [diff] [blame] | 16 | \makeindex |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 17 | |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 18 | \begin{document} |
| 19 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 20 | \maketitle |
Greg Ward | e3cca26 | 2000-08-31 16:36:31 +0000 | [diff] [blame] | 21 | \begin{abstract} |
| 22 | \noindent |
| 23 | This document describes the Python Distribution Utilities |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 24 | (``Distutils'') from the module developer's point of view, describing |
Greg Ward | e3cca26 | 2000-08-31 16:36:31 +0000 | [diff] [blame] | 25 | how to use the Distutils to make Python modules and extensions easily |
| 26 | available to a wider audience with very little overhead for |
| 27 | build/release/install mechanics. |
| 28 | \end{abstract} |
| 29 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 30 | % The ugly "%begin{latexonly}" pseudo-environment supresses the table |
| 31 | % of contents for HTML generation. |
| 32 | % |
| 33 | %begin{latexonly} |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 34 | \tableofcontents |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 35 | %end{latexonly} |
| 36 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 37 | |
| 38 | \section{Introduction} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 39 | \label{intro} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 40 | |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 41 | This document covers using the Distutils to distribute your Python |
| 42 | modules, concentrating on the role of developer/distributor: if |
Fred Drake | 01df453 | 2000-06-30 03:36:41 +0000 | [diff] [blame] | 43 | you're looking for information on installing Python modules, you |
| 44 | should refer to the \citetitle[../inst/inst.html]{Installing Python |
| 45 | Modules} manual. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 46 | |
| 47 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 48 | \section{Concepts \& Terminology} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 49 | \label{concepts} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 50 | |
| 51 | Using the Distutils is quite simple, both for module developers and for |
| 52 | users/administrators installing third-party modules. As a developer, |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 53 | your responsibilities (apart from writing solid, well-documented and |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 54 | well-tested code, of course!) are: |
| 55 | \begin{itemize} |
| 56 | \item write a setup script (\file{setup.py} by convention) |
| 57 | \item (optional) write a setup configuration file |
| 58 | \item create a source distribution |
| 59 | \item (optional) create one or more built (binary) distributions |
| 60 | \end{itemize} |
| 61 | Each of these tasks is covered in this document. |
| 62 | |
| 63 | Not all module developers have access to a multitude of platforms, so |
| 64 | it's not always feasible to expect them to create a multitude of built |
| 65 | distributions. It is hoped that a class of intermediaries, called |
Greg Ward | 19c67f8 | 2000-06-24 01:33:16 +0000 | [diff] [blame] | 66 | \emph{packagers}, will arise to address this need. Packagers will take |
| 67 | source distributions released by module developers, build them on one or |
| 68 | more platforms, and release the resulting built distributions. Thus, |
| 69 | users on the most popular platforms will be able to install most popular |
| 70 | Python module distributions in the most natural way for their platform, |
| 71 | without having to run a single setup script or compile a line of code. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 72 | |
| 73 | |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 74 | \subsection{A Simple Example} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 75 | \label{simple-example} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 76 | |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 77 | The setup script is usually quite simple, although since it's written |
| 78 | in Python, there are no arbitrary limits to what you can do with it, |
| 79 | though you should be careful about putting arbitrarily expensive |
| 80 | operations in your setup script. Unlike, say, Autoconf-style configure |
| 81 | scripts, the setup script may be run multiple times in the course of |
| 82 | building and installing your module distribution. If you need to |
| 83 | insert potentially expensive processing steps into the Distutils |
| 84 | chain, see section~\ref{extending} on extending the Distutils. |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 85 | |
| 86 | If all you want to do is distribute a module called \module{foo}, |
| 87 | contained in a file \file{foo.py}, then your setup script can be as |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 88 | simple as this: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 89 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 90 | \begin{verbatim} |
| 91 | from distutils.core import setup |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 92 | setup(name="foo", |
| 93 | version="1.0", |
| 94 | py_modules=["foo"]) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 95 | \end{verbatim} |
Greg Ward | 370248d | 2000-06-24 01:45:47 +0000 | [diff] [blame] | 96 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 97 | Some observations: |
| 98 | \begin{itemize} |
Greg Ward | 370248d | 2000-06-24 01:45:47 +0000 | [diff] [blame] | 99 | \item most information that you supply to the Distutils is supplied as |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 100 | keyword arguments to the \function{setup()} function |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 101 | \item those keyword arguments fall into two categories: package |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 102 | metadata (name, version number) and information about what's in the |
Greg Ward | 370248d | 2000-06-24 01:45:47 +0000 | [diff] [blame] | 103 | package (a list of pure Python modules, in this case) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 104 | \item modules are specified by module name, not filename (the same will |
| 105 | hold true for packages and extensions) |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 106 | \item it's recommended that you supply a little more metadata, in |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 107 | particular your name, email address and a URL for the project |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 108 | (see section~\ref{setup-script} for an example) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 109 | \end{itemize} |
| 110 | |
Greg Ward | 370248d | 2000-06-24 01:45:47 +0000 | [diff] [blame] | 111 | To create a source distribution for this module, you would create a |
| 112 | setup script, \file{setup.py}, containing the above code, and run: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 113 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 114 | \begin{verbatim} |
| 115 | python setup.py sdist |
| 116 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 117 | |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 118 | which will create an archive file (e.g., tarball on \UNIX, ZIP file on |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 119 | Windows) containing your setup script \file{setup.py}, and your module |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 120 | \file{foo.py}. The archive file will be named \file{foo-1.0.tar.gz} (or |
| 121 | \file{.zip}), and will unpack into a directory \file{foo-1.0}. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 122 | |
| 123 | If an end-user wishes to install your \module{foo} module, all she has |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 124 | to do is download \file{foo-1.0.tar.gz} (or \file{.zip}), unpack it, |
| 125 | and---from the \file{foo-1.0} directory---run |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 126 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 127 | \begin{verbatim} |
| 128 | python setup.py install |
| 129 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 130 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 131 | which will ultimately copy \file{foo.py} to the appropriate directory |
| 132 | for third-party modules in their Python installation. |
| 133 | |
| 134 | This simple example demonstrates some fundamental concepts of the |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 135 | Distutils. First, both developers and installers have the same basic |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 136 | user interface, i.e. the setup script. The difference is which |
| 137 | Distutils \emph{commands} they use: the \command{sdist} command is |
| 138 | almost exclusively for module developers, while \command{install} is |
| 139 | more often for installers (although most developers will want to install |
| 140 | their own code occasionally). |
| 141 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 142 | If you want to make things really easy for your users, you can create |
| 143 | one or more built distributions for them. For instance, if you are |
| 144 | running on a Windows machine, and want to make things easy for other |
| 145 | Windows users, you can create an executable installer (the most |
| 146 | appropriate type of built distribution for this platform) with the |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 147 | \command{bdist\_wininst} command. For example: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 148 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 149 | \begin{verbatim} |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 150 | python setup.py bdist_wininst |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 151 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 152 | |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 153 | will create an executable installer, \file{foo-1.0.win32.exe}, in the |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 154 | current directory. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 155 | |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 156 | Other useful built distribution formats are RPM, implemented by the |
| 157 | \command{bdist\_rpm} command, Solaris \program{pkgtool} |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 158 | (\command{bdist\_pkgtool}), and HP-UX \program{swinstall} |
| 159 | (\command{bdist_sdux}). For example, the following command will |
| 160 | create an RPM file called \file{foo-1.0.noarch.rpm}: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 161 | |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 162 | \begin{verbatim} |
| 163 | python setup.py bdist_rpm |
| 164 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 165 | |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 166 | (The \command{bdist\_rpm} command uses the \command{rpm} executable, |
| 167 | therefore this has to be run on an RPM-based system such as Red Hat |
| 168 | Linux, SuSE Linux, or Mandrake Linux.) |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 169 | |
| 170 | You can find out what distribution formats are available at any time by |
| 171 | running |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 172 | |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 173 | \begin{verbatim} |
| 174 | python setup.py bdist --help-formats |
| 175 | \end{verbatim} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 176 | |
| 177 | |
| 178 | \subsection{General Python terminology} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 179 | \label{python-terms} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 180 | |
| 181 | If you're reading this document, you probably have a good idea of what |
| 182 | modules, extensions, and so forth are. Nevertheless, just to be sure |
| 183 | that everyone is operating from a common starting point, we offer the |
| 184 | following glossary of common Python terms: |
| 185 | \begin{description} |
| 186 | \item[module] the basic unit of code reusability in Python: a block of |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 187 | code imported by some other code. Three types of modules concern us |
| 188 | here: pure Python modules, extension modules, and packages. |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 189 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 190 | \item[pure Python module] a module written in Python and contained in a |
| 191 | single \file{.py} file (and possibly associated \file{.pyc} and/or |
| 192 | \file{.pyo} files). Sometimes referred to as a ``pure module.'' |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 193 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 194 | \item[extension module] a module written in the low-level language of |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 195 | the Python implementation: C/C++ for Python, Java for Jython. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 196 | Typically contained in a single dynamically loadable pre-compiled |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 197 | file, e.g. a shared object (\file{.so}) file for Python extensions on |
| 198 | \UNIX, a DLL (given the \file{.pyd} extension) for Python extensions |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 199 | on Windows, or a Java class file for Jython extensions. (Note that |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 200 | currently, the Distutils only handles C/C++ extensions for Python.) |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 201 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 202 | \item[package] a module that contains other modules; typically contained |
| 203 | in a directory in the filesystem and distinguished from other |
| 204 | directories by the presence of a file \file{\_\_init\_\_.py}. |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 205 | |
Greg Ward | 6153fa1 | 2000-05-26 02:24:28 +0000 | [diff] [blame] | 206 | \item[root package] the root of the hierarchy of packages. (This isn't |
| 207 | really a package, since it doesn't have an \file{\_\_init\_\_.py} |
| 208 | file. But we have to call it something.) The vast majority of the |
| 209 | standard library is in the root package, as are many small, standalone |
| 210 | third-party modules that don't belong to a larger module collection. |
| 211 | Unlike regular packages, modules in the root package can be found in |
| 212 | many directories: in fact, every directory listed in \code{sys.path} |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 213 | contributes modules to the root package. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 214 | \end{description} |
| 215 | |
| 216 | |
| 217 | \subsection{Distutils-specific terminology} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 218 | \label{distutils-term} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 219 | |
| 220 | The following terms apply more specifically to the domain of |
| 221 | distributing Python modules using the Distutils: |
| 222 | \begin{description} |
| 223 | \item[module distribution] a collection of Python modules distributed |
| 224 | together as a single downloadable resource and meant to be installed |
| 225 | \emph{en masse}. Examples of some well-known module distributions are |
| 226 | Numeric Python, PyXML, PIL (the Python Imaging Library), or |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 227 | mxBase. (This would be called a \emph{package}, except that term |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 228 | is already taken in the Python context: a single module distribution |
| 229 | may contain zero, one, or many Python packages.) |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 230 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 231 | \item[pure module distribution] a module distribution that contains only |
| 232 | pure Python modules and packages. Sometimes referred to as a ``pure |
| 233 | distribution.'' |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 234 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 235 | \item[non-pure module distribution] a module distribution that contains |
| 236 | at least one extension module. Sometimes referred to as a ``non-pure |
| 237 | distribution.'' |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 238 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 239 | \item[distribution root] the top-level directory of your source tree (or |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 240 | source distribution); the directory where \file{setup.py} exists. Generally |
| 241 | \file{setup.py} will be run from this directory. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 242 | \end{description} |
| 243 | |
| 244 | |
| 245 | \section{Writing the Setup Script} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 246 | \label{setup-script} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 247 | |
| 248 | The setup script is the centre of all activity in building, |
| 249 | distributing, and installing modules using the Distutils. The main |
| 250 | purpose of the setup script is to describe your module distribution to |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 251 | the Distutils, so that the various commands that operate on your modules |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 252 | do the right thing. As we saw in section~\ref{simple-example} above, |
| 253 | the setup script consists mainly of a call to \function{setup()}, and |
Greg Ward | 1bbe329 | 2000-06-25 03:14:13 +0000 | [diff] [blame] | 254 | most information supplied to the Distutils by the module developer is |
| 255 | supplied as keyword arguments to \function{setup()}. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 256 | |
| 257 | Here's a slightly more involved example, which we'll follow for the next |
| 258 | couple of sections: the Distutils' own setup script. (Keep in mind that |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 259 | although the Distutils are included with Python 1.6 and later, they also |
| 260 | have an independent existence so that Python 1.5.2 users can use them to |
| 261 | install other module distributions. The Distutils' own setup script, |
| 262 | shown here, is used to install the package into Python 1.5.2.) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 263 | |
| 264 | \begin{verbatim} |
| 265 | #!/usr/bin/env python |
| 266 | |
| 267 | from distutils.core import setup |
| 268 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 269 | setup(name="Distutils", |
| 270 | version="1.0", |
| 271 | description="Python Distribution Utilities", |
| 272 | author="Greg Ward", |
| 273 | author_email="gward@python.net", |
| 274 | url="http://www.python.org/sigs/distutils-sig/", |
| 275 | packages=['distutils', 'distutils.command'], |
| 276 | ) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 277 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 278 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 279 | There are only two differences between this and the trivial one-file |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 280 | distribution presented in section~\ref{simple-example}: more |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 281 | metadata, and the specification of pure Python modules by package, |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 282 | rather than by module. This is important since the Distutils consist of |
| 283 | a couple of dozen modules split into (so far) two packages; an explicit |
| 284 | list of every module would be tedious to generate and difficult to |
Andrew M. Kuchling | d15f4e3 | 2003-01-03 15:42:14 +0000 | [diff] [blame^] | 285 | maintain. For more information on the additional meta-data, see |
| 286 | section~\ref{meta-data}. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 287 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 288 | Note that any pathnames (files or directories) supplied in the setup |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 289 | script should be written using the \UNIX{} convention, i.e. |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 290 | slash-separated. The Distutils will take care of converting this |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 291 | platform-neutral representation into whatever is appropriate on your |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 292 | current platform before actually using the pathname. This makes your |
| 293 | setup script portable across operating systems, which of course is one |
| 294 | of the major goals of the Distutils. In this spirit, all pathnames in |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 295 | this document are slash-separated. (MacOS programmers should keep in |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 296 | mind that the \emph{absence} of a leading slash indicates a relative |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 297 | path, the opposite of the MacOS convention with colons.) |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 298 | |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 299 | This, of course, only applies to pathnames given to Distutils |
| 300 | functions. If you, for example, use standard python functions such as |
| 301 | \function{glob.glob} or \function{os.listdir} to specify files, you |
| 302 | should be careful to write portable code instead of hardcoding path |
| 303 | separators: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 304 | |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 305 | \begin{verbatim} |
| 306 | glob.glob(os.path.join('mydir', 'subdir', '*.html')) |
| 307 | os.listdir(os.path.join('mydir', 'subdir')) |
| 308 | \end{verbatim} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 309 | |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 310 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 311 | \subsection{Listing whole packages} |
| 312 | \label{listing-packages} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 313 | |
| 314 | The \option{packages} option tells the Distutils to process (build, |
| 315 | distribute, install, etc.) all pure Python modules found in each package |
| 316 | mentioned in the \option{packages} list. In order to do this, of |
| 317 | course, there has to be a correspondence between package names and |
| 318 | directories in the filesystem. The default correspondence is the most |
Greg Ward | 1ecc251 | 2000-04-19 22:36:24 +0000 | [diff] [blame] | 319 | obvious one, i.e. package \module{distutils} is found in the directory |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 320 | \file{distutils} relative to the distribution root. Thus, when you say |
| 321 | \code{packages = ['foo']} in your setup script, you are promising that |
| 322 | the Distutils will find a file \file{foo/\_\_init\_\_.py} (which might |
| 323 | be spelled differently on your system, but you get the idea) relative to |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 324 | the directory where your setup script lives. If you break this |
| 325 | promise, the Distutils will issue a warning but still process the broken |
| 326 | package anyways. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 327 | |
| 328 | If you use a different convention to lay out your source directory, |
| 329 | that's no problem: you just have to supply the \option{package\_dir} |
| 330 | option to tell the Distutils about your convention. For example, say |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 331 | you keep all Python source under \file{lib}, so that modules in the |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 332 | ``root package'' (i.e., not in any package at all) are in |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 333 | \file{lib}, modules in the \module{foo} package are in \file{lib/foo}, |
| 334 | and so forth. Then you would put |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 335 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 336 | \begin{verbatim} |
| 337 | package_dir = {'': 'lib'} |
| 338 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 339 | |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 340 | in your setup script. The keys to this dictionary are package names, |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 341 | and an empty package name stands for the root package. The values are |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 342 | directory names relative to your distribution root. In this case, when |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 343 | you say \code{packages = ['foo']}, you are promising that the file |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 344 | \file{lib/foo/\_\_init\_\_.py} exists. |
| 345 | |
Greg Ward | 1ecc251 | 2000-04-19 22:36:24 +0000 | [diff] [blame] | 346 | Another possible convention is to put the \module{foo} package right in |
| 347 | \file{lib}, the \module{foo.bar} package in \file{lib/bar}, etc. This |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 348 | would be written in the setup script as |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 349 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 350 | \begin{verbatim} |
| 351 | package_dir = {'foo': 'lib'} |
| 352 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 353 | |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 354 | A \code{\var{package}: \var{dir}} entry in the \option{package\_dir} |
| 355 | dictionary implicitly applies to all packages below \var{package}, so |
| 356 | the \module{foo.bar} case is automatically handled here. In this |
| 357 | example, having \code{packages = ['foo', 'foo.bar']} tells the Distutils |
| 358 | to look for \file{lib/\_\_init\_\_.py} and |
| 359 | \file{lib/bar/\_\_init\_\_.py}. (Keep in mind that although |
| 360 | \option{package\_dir} applies recursively, you must explicitly list all |
| 361 | packages in \option{packages}: the Distutils will \emph{not} recursively |
| 362 | scan your source tree looking for any directory with an |
| 363 | \file{\_\_init\_\_.py} file.) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 364 | |
| 365 | |
| 366 | \subsection{Listing individual modules} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 367 | \label{listing-modules} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 368 | |
| 369 | For a small module distribution, you might prefer to list all modules |
| 370 | rather than listing packages---especially the case of a single module |
| 371 | that goes in the ``root package'' (i.e., no package at all). This |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 372 | simplest case was shown in section~\ref{simple-example}; here is a |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 373 | slightly more involved example: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 374 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 375 | \begin{verbatim} |
| 376 | py_modules = ['mod1', 'pkg.mod2'] |
| 377 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 378 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 379 | This describes two modules, one of them in the ``root'' package, the |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 380 | other in the \module{pkg} package. Again, the default package/directory |
| 381 | layout implies that these two modules can be found in \file{mod1.py} and |
| 382 | \file{pkg/mod2.py}, and that \file{pkg/\_\_init\_\_.py} exists as well. |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 383 | And again, you can override the package/directory correspondence using |
| 384 | the \option{package\_dir} option. |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 385 | |
| 386 | |
| 387 | \subsection{Describing extension modules} |
Greg Ward | 1365a30 | 2000-08-31 14:47:05 +0000 | [diff] [blame] | 388 | \label{describing-extensions} |
Greg Ward | 59d382e | 2000-05-26 01:04:47 +0000 | [diff] [blame] | 389 | |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 390 | % XXX read over this section |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 391 | Just as writing Python extension modules is a bit more complicated than |
| 392 | writing pure Python modules, describing them to the Distutils is a bit |
| 393 | more complicated. Unlike pure modules, it's not enough just to list |
| 394 | modules or packages and expect the Distutils to go out and find the |
| 395 | right files; you have to specify the extension name, source file(s), and |
| 396 | any compile/link requirements (include directories, libraries to link |
| 397 | with, etc.). |
| 398 | |
| 399 | All of this is done through another keyword argument to |
| 400 | \function{setup()}, the \option{extensions} option. \option{extensions} |
| 401 | is just a list of \class{Extension} instances, each of which describes a |
| 402 | single extension module. Suppose your distribution includes a single |
| 403 | extension, called \module{foo} and implemented by \file{foo.c}. If no |
| 404 | additional instructions to the compiler/linker are needed, describing |
| 405 | this extension is quite simple: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 406 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 407 | \begin{verbatim} |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 408 | uExtension("foo", ["foo.c"]) |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 409 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 410 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 411 | The \class{Extension} class can be imported from |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 412 | \module{distutils.core} along with \function{setup()}. Thus, the setup |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 413 | script for a module distribution that contains only this one extension |
| 414 | and nothing else might be: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 415 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 416 | \begin{verbatim} |
| 417 | from distutils.core import setup, Extension |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 418 | setup(name="foo", version="1.0", |
| 419 | ext_modules=[Extension("foo", ["foo.c"])]) |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 420 | \end{verbatim} |
| 421 | |
| 422 | The \class{Extension} class (actually, the underlying extension-building |
Andrew M. Kuchling | da23c4f | 2001-02-17 00:38:48 +0000 | [diff] [blame] | 423 | machinery implemented by the \command{build\_ext} command) supports a |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 424 | great deal of flexibility in describing Python extensions, which is |
| 425 | explained in the following sections. |
| 426 | |
| 427 | |
| 428 | \subsubsection{Extension names and packages} |
| 429 | |
| 430 | The first argument to the \class{Extension} constructor is always the |
| 431 | name of the extension, including any package names. For example, |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 432 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 433 | \begin{verbatim} |
| 434 | Extension("foo", ["src/foo1.c", "src/foo2.c"]) |
| 435 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 436 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 437 | describes an extension that lives in the root package, while |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 438 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 439 | \begin{verbatim} |
| 440 | Extension("pkg.foo", ["src/foo1.c", "src/foo2.c"]) |
| 441 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 442 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 443 | describes the same extension in the \module{pkg} package. The source |
| 444 | files and resulting object code are identical in both cases; the only |
| 445 | difference is where in the filesystem (and therefore where in Python's |
| 446 | namespace hierarchy) the resulting extension lives. |
| 447 | |
| 448 | If you have a number of extensions all in the same package (or all under |
| 449 | the same base package), use the \option{ext\_package} keyword argument |
| 450 | to \function{setup()}. For example, |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 451 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 452 | \begin{verbatim} |
| 453 | setup(... |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 454 | ext_package="pkg", |
| 455 | ext_modules=[Extension("foo", ["foo.c"]), |
| 456 | Extension("subpkg.bar", ["bar.c"])] |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 457 | ) |
| 458 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 459 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 460 | will compile \file{foo.c} to the extension \module{pkg.foo}, and |
| 461 | \file{bar.c} to \module{pkg.subpkg.bar}. |
| 462 | |
| 463 | |
| 464 | \subsubsection{Extension source files} |
| 465 | |
| 466 | The second argument to the \class{Extension} constructor is a list of |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 467 | source files. Since the Distutils currently only support C, \Cpp, and |
| 468 | Objective-C extensions, these are normally C/\Cpp/Objective-C source |
| 469 | files. (Be sure to use appropriate extensions to distinguish \Cpp\ |
| 470 | source files: \file{.cc} and \file{.cpp} seem to be recognized by both |
| 471 | \UNIX{} and Windows compilers.) |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 472 | |
| 473 | However, you can also include SWIG interface (\file{.i}) files in the |
| 474 | list; the \command{build\_ext} command knows how to deal with SWIG |
| 475 | extensions: it will run SWIG on the interface file and compile the |
| 476 | resulting C/C++ file into your extension. |
| 477 | |
| 478 | \XXX{SWIG support is rough around the edges and largely untested; |
| 479 | especially SWIG support of C++ extensions! Explain in more detail |
| 480 | here when the interface firms up.} |
| 481 | |
| 482 | On some platforms, you can include non-source files that are processed |
| 483 | by the compiler and included in your extension. Currently, this just |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 484 | means Windows message text (\file{.mc}) files and resource definition |
| 485 | (\file{.rc}) files for Visual C++. These will be compiled to binary resource |
| 486 | (\file{.res}) files and linked into the executable. |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 487 | |
| 488 | |
| 489 | \subsubsection{Preprocessor options} |
| 490 | |
| 491 | Three optional arguments to \class{Extension} will help if you need to |
| 492 | specify include directories to search or preprocessor macros to |
| 493 | define/undefine: \code{include\_dirs}, \code{define\_macros}, and |
| 494 | \code{undef\_macros}. |
| 495 | |
| 496 | For example, if your extension requires header files in the |
| 497 | \file{include} directory under your distribution root, use the |
| 498 | \code{include\_dirs} option: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 499 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 500 | \begin{verbatim} |
| 501 | Extension("foo", ["foo.c"], include_dirs=["include"]) |
| 502 | \end{verbatim} |
| 503 | |
| 504 | You can specify absolute directories there; if you know that your |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 505 | extension will only be built on \UNIX{} systems with X11R6 installed to |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 506 | \file{/usr}, you can get away with |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 507 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 508 | \begin{verbatim} |
| 509 | Extension("foo", ["foo.c"], include_dirs=["/usr/include/X11"]) |
| 510 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 511 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 512 | You should avoid this sort of non-portable usage if you plan to |
Greg Ward | 58437f2 | 2002-05-10 14:40:22 +0000 | [diff] [blame] | 513 | distribute your code: it's probably better to write C code like |
| 514 | \begin{verbatim} |
| 515 | #include <X11/Xlib.h> |
| 516 | \end{verbatim} |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 517 | |
| 518 | If you need to include header files from some other Python extension, |
Greg Ward | 58437f2 | 2002-05-10 14:40:22 +0000 | [diff] [blame] | 519 | you can take advantage of the fact that header files are installed in a |
| 520 | consistent way by the Distutils \command{install\_header} command. For |
| 521 | example, the Numerical Python header files are installed (on a standard |
| 522 | Unix installation) to \file{/usr/local/include/python1.5/Numerical}. |
| 523 | (The exact location will differ according to your platform and Python |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 524 | installation.) Since the Python include |
Greg Ward | 58437f2 | 2002-05-10 14:40:22 +0000 | [diff] [blame] | 525 | directory---\file{/usr/local/include/python1.5} in this case---is always |
| 526 | included in the search path when building Python extensions, the best |
| 527 | approach is to write C code like |
| 528 | \begin{verbatim} |
| 529 | #include <Numerical/arrayobject.h> |
| 530 | \end{verbatim} |
| 531 | If you must put the \file{Numerical} include directory right into your |
| 532 | header search path, though, you can find that directory using the |
| 533 | Distutils \module{sysconfig} module: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 534 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 535 | \begin{verbatim} |
| 536 | from distutils.sysconfig import get_python_inc |
| 537 | incdir = os.path.join(get_python_inc(plat_specific=1), "Numerical") |
| 538 | setup(..., |
| 539 | Extension(..., include_dirs=[incdir])) |
| 540 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 541 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 542 | Even though this is quite portable---it will work on any Python |
| 543 | installation, regardless of platform---it's probably easier to just |
| 544 | write your C code in the sensible way. |
| 545 | |
| 546 | You can define and undefine pre-processor macros with the |
| 547 | \code{define\_macros} and \code{undef\_macros} options. |
| 548 | \code{define\_macros} takes a list of \code{(name, value)} tuples, where |
| 549 | \code{name} is the name of the macro to define (a string) and |
| 550 | \code{value} is its value: either a string or \code{None}. (Defining a |
| 551 | macro \code{FOO} to \code{None} is the equivalent of a bare |
| 552 | \code{\#define FOO} in your C source: with most compilers, this sets |
| 553 | \code{FOO} to the string \code{1}.) \code{undef\_macros} is just |
| 554 | a list of macros to undefine. |
| 555 | |
| 556 | For example: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 557 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 558 | \begin{verbatim} |
| 559 | Extension(..., |
| 560 | define_macros=[('NDEBUG', '1')], |
| 561 | ('HAVE_STRFTIME', None), |
| 562 | undef_macros=['HAVE_FOO', 'HAVE_BAR']) |
| 563 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 564 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 565 | is the equivalent of having this at the top of every C source file: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 566 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 567 | \begin{verbatim} |
| 568 | #define NDEBUG 1 |
| 569 | #define HAVE_STRFTIME |
| 570 | #undef HAVE_FOO |
| 571 | #undef HAVE_BAR |
| 572 | \end{verbatim} |
| 573 | |
| 574 | |
| 575 | \subsubsection{Library options} |
| 576 | |
| 577 | You can also specify the libraries to link against when building your |
| 578 | extension, and the directories to search for those libraries. The |
| 579 | \code{libraries} option is a list of libraries to link against, |
| 580 | \code{library\_dirs} is a list of directories to search for libraries at |
| 581 | link-time, and \code{runtime\_library\_dirs} is a list of directories to |
| 582 | search for shared (dynamically loaded) libraries at run-time. |
| 583 | |
| 584 | For example, if you need to link against libraries known to be in the |
| 585 | standard library search path on target systems |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 586 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 587 | \begin{verbatim} |
| 588 | Extension(..., |
| 589 | libraries=["gdbm", "readline"]) |
| 590 | \end{verbatim} |
| 591 | |
| 592 | If you need to link with libraries in a non-standard location, you'll |
| 593 | have to include the location in \code{library\_dirs}: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 594 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 595 | \begin{verbatim} |
| 596 | Extension(..., |
| 597 | library_dirs=["/usr/X11R6/lib"], |
| 598 | libraries=["X11", "Xt"]) |
| 599 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 600 | |
Greg Ward | 2afffd4 | 2000-08-06 20:37:24 +0000 | [diff] [blame] | 601 | (Again, this sort of non-portable construct should be avoided if you |
| 602 | intend to distribute your code.) |
| 603 | |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 604 | \XXX{Should mention clib libraries here or somewhere else!} |
| 605 | |
| 606 | \subsubsection{Other options} |
| 607 | |
| 608 | There are still some other options which can be used to handle special |
| 609 | cases. |
| 610 | |
| 611 | The \option{extra\_objects} option is a list of object files to be passed |
| 612 | to the linker. These files must not have extensions, as the default |
| 613 | extension for the compiler is used. |
| 614 | |
| 615 | \option{extra\_compile\_args} and \option{extra\_link\_args} can be used |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 616 | to specify additional command line options for the respective compiler and |
| 617 | linker command lines. |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 618 | |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 619 | \option{export\_symbols} is only useful on Windows. It can contain a list |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 620 | of symbols (functions or variables) to be exported. This option |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 621 | is not needed when building compiled extensions: Distutils |
| 622 | will automatically add \code{initmodule} |
| 623 | to the list of exported symbols. |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 624 | |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 625 | \subsection{Installing Scripts} |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 626 | So far we have been dealing with pure and non-pure Python modules, |
| 627 | which are usually not run by themselves but imported by scripts. |
| 628 | |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 629 | Scripts are files containing Python source code, intended to be |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 630 | started from the command line. Scripts don't require Distutils to do |
| 631 | anything very complicated. The only clever feature is that if the |
| 632 | first line of the script starts with \code{\#!} and contains the word |
| 633 | ``python'', the Distutils will adjust the first line to refer to the |
| 634 | current interpreter location. |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 635 | |
| 636 | The \option{scripts} option simply is a list of files to be handled |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 637 | in this way. From the PyXML setup script: |
| 638 | |
| 639 | \begin{verbatim} |
| 640 | setup (... |
| 641 | scripts = ['scripts/xmlproc_parse', 'scripts/xmlproc_val'] |
| 642 | ) |
| 643 | \end{verbatim} |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 644 | |
| 645 | |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 646 | \subsection{Installing Additional Files} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 647 | |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 648 | The \option{data\_files} option can be used to specify additional |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 649 | files needed by the module distribution: configuration files, message |
| 650 | catalogs, data files, anything which doesn't fit in the previous |
| 651 | categories. |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 652 | |
Fred Drake | 632bda3 | 2002-03-08 22:02:06 +0000 | [diff] [blame] | 653 | \option{data\_files} specifies a sequence of (\var{directory}, |
| 654 | \var{files}) pairs in the following way: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 655 | |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 656 | \begin{verbatim} |
| 657 | setup(... |
| 658 | data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']), |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 659 | ('config', ['cfg/data.cfg']), |
| 660 | ('/etc/init.d', ['init-script'])] |
| 661 | ) |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 662 | \end{verbatim} |
| 663 | |
| 664 | Note that you can specify the directory names where the data files |
| 665 | will be installed, but you cannot rename the data files themselves. |
| 666 | |
Fred Drake | 632bda3 | 2002-03-08 22:02:06 +0000 | [diff] [blame] | 667 | Each (\var{directory}, \var{files}) pair in the sequence specifies the |
| 668 | installation directory and the files to install there. If |
| 669 | \var{directory} is a relative path, it is interpreted relative to the |
| 670 | installation prefix (Python's \code{sys.prefix} for pure-Python |
| 671 | packages, \code{sys.exec_prefix} for packages that contain extension |
| 672 | modules). Each file name in \var{files} is interpreted relative to |
| 673 | the \file{setup.py} script at the top of the package source |
| 674 | distribution. No directory information from \var{files} is used to |
| 675 | determine the final location of the installed file; only the name of |
| 676 | the file is used. |
| 677 | |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 678 | You can specify the \option{data\_files} options as a simple sequence |
| 679 | of files without specifying a target directory, but this is not recommended, |
| 680 | and the \command{install} command will print a warning in this case. |
| 681 | To install data files directly in the target directory, an empty |
| 682 | string should be given as the directory. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 683 | |
Andrew M. Kuchling | d15f4e3 | 2003-01-03 15:42:14 +0000 | [diff] [blame^] | 684 | \subsection{Additional meta-data} |
| 685 | \label{meta-data} |
| 686 | |
| 687 | The setup script may include additional meta-data beyond the name and |
| 688 | version. This information includes: |
| 689 | |
| 690 | \begin{tableiii}{l|l|c}{code}% |
| 691 | {Meta-Data}{Description}{Notes} |
| 692 | \lineiii{name}{the name of the package}{(1)} |
| 693 | \lineiii{version}{the version of this release}{(1)} |
| 694 | \lineiii{author}{package author's name}{(2)} |
| 695 | \lineiii{author_email}{email address of the package author}{(2)} |
| 696 | \lineiii{maintainer}{package maintainer's name}{(2)} |
| 697 | \lineiii{maintainer_email}{email address of the package maintainer}{(2)} |
| 698 | \lineiii{home_page}{a URL}{(1)} |
| 699 | \lineiii{license}{the terms the package is released under}{} |
| 700 | \lineiii{description}{a short, summary description of the package}{} |
| 701 | \lineiii{long_description}{a longer description of the package}{} |
| 702 | \lineiii{keywords}{some keywords appropriate to the package}{} |
| 703 | \lineiii{platform}{a list of the target platforms}{} |
| 704 | \lineiii{classifiers}{a list of Trove classifiers}{(2)} |
| 705 | \end{tableiii} |
| 706 | |
| 707 | \noindent Notes: |
| 708 | \begin{description} |
| 709 | \item[(1)] these fields are required |
| 710 | \item[(2)] either the author or the maintainer must be nominated |
| 711 | \item[(3)] should not be used if your package is to be compatible with |
| 712 | Python versions prior to 2.2.3 or 2.3. The list is available from the |
| 713 | PyPI website. |
| 714 | \end{description} |
| 715 | |
| 716 | \option{classifiers} are specified in a python list: |
| 717 | |
| 718 | \begin{verbatim} |
| 719 | setup(... |
| 720 | classifiers = [ |
| 721 | 'Development Status :: 4 - Beta', |
| 722 | 'Environment :: Console', |
| 723 | 'Environment :: Web Environment', |
| 724 | 'Intended Audience :: End Users/Desktop', |
| 725 | 'Intended Audience :: Developers', |
| 726 | 'Intended Audience :: System Administrators', |
| 727 | 'License :: OSI Approved :: Python Software Foundation License', |
| 728 | 'Operating System :: MacOS :: MacOS X', |
| 729 | 'Operating System :: Microsoft :: Windows', |
| 730 | 'Operating System :: POSIX', |
| 731 | 'Programming Language :: Python', |
| 732 | 'Topic :: Communications :: Email', |
| 733 | 'Topic :: Office/Business', |
| 734 | 'Topic :: Software Development :: Bug Tracking', |
| 735 | ], |
| 736 | ... |
| 737 | ) |
| 738 | \end{verbatim} |
| 739 | |
| 740 | If you wish to include classifiers in your \file{setup.py} file and also |
| 741 | wish to remain backwards-compatible with Python releases prior to 2.2.3, |
| 742 | then you can include the following code fragment in your \file{setup.py} |
| 743 | before the \code{setup()} call. |
| 744 | |
| 745 | \begin{verbatim} |
| 746 | # patch distutils if it can't cope with the "classifiers" keyword |
| 747 | if sys.version < '2.2.3': |
| 748 | from distutils.dist import DistributionMetadata |
| 749 | DistributionMetadata.classifiers = None |
| 750 | \end{verbatim} |
| 751 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 752 | |
| 753 | \section{Writing the Setup Configuration File} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 754 | \label{setup-config} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 755 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 756 | Often, it's not possible to write down everything needed to build a |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 757 | distribution \emph{a priori}: you may need to get some information from |
| 758 | the user, or from the user's system, in order to proceed. As long as |
| 759 | that information is fairly simple---a list of directories to search for |
| 760 | C header files or libraries, for example---then providing a |
| 761 | configuration file, \file{setup.cfg}, for users to edit is a cheap and |
| 762 | easy way to solicit it. Configuration files also let you provide |
| 763 | default values for any command option, which the installer can then |
| 764 | override either on the command-line or by editing the config file. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 765 | |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 766 | % (If you have more advanced needs, such as determining which extensions |
| 767 | % to build based on what capabilities are present on the target system, |
| 768 | % then you need the Distutils ``auto-configuration'' facility. This |
| 769 | % started to appear in Distutils 0.9 but, as of this writing, isn't mature |
| 770 | % or stable enough yet for real-world use.) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 771 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 772 | The setup configuration file is a useful middle-ground between the setup |
| 773 | script---which, ideally, would be opaque to installers\footnote{This |
| 774 | ideal probably won't be achieved until auto-configuration is fully |
| 775 | supported by the Distutils.}---and the command-line to the setup |
| 776 | script, which is outside of your control and entirely up to the |
| 777 | installer. In fact, \file{setup.cfg} (and any other Distutils |
| 778 | configuration files present on the target system) are processed after |
| 779 | the contents of the setup script, but before the command-line. This has |
| 780 | several useful consequences: |
| 781 | \begin{itemize} |
| 782 | \item installers can override some of what you put in \file{setup.py} by |
| 783 | editing \file{setup.cfg} |
| 784 | \item you can provide non-standard defaults for options that are not |
| 785 | easily set in \file{setup.py} |
| 786 | \item installers can override anything in \file{setup.cfg} using the |
| 787 | command-line options to \file{setup.py} |
| 788 | \end{itemize} |
| 789 | |
| 790 | The basic syntax of the configuration file is simple: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 791 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 792 | \begin{verbatim} |
| 793 | [command] |
| 794 | option=value |
| 795 | ... |
| 796 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 797 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 798 | where \var{command} is one of the Distutils commands (e.g. |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 799 | \command{build\_py}, \command{install}), and \var{option} is one of |
| 800 | the options that command supports. Any number of options can be |
| 801 | supplied for each command, and any number of command sections can be |
| 802 | included in the file. Blank lines are ignored, as are comments, which |
| 803 | run from a \character{\#} character until the end of the line. Long |
| 804 | option values can be split across multiple lines simply by indenting |
| 805 | the continuation lines. |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 806 | |
| 807 | You can find out the list of options supported by a particular command |
| 808 | with the universal \longprogramopt{help} option, e.g. |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 809 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 810 | \begin{verbatim} |
| 811 | > python setup.py --help build_ext |
| 812 | [...] |
| 813 | Options for 'build_ext' command: |
| 814 | --build-lib (-b) directory for compiled extension modules |
| 815 | --build-temp (-t) directory for temporary files (build by-products) |
| 816 | --inplace (-i) ignore build-lib and put compiled extensions into the |
| 817 | source directory alongside your pure Python modules |
| 818 | --include-dirs (-I) list of directories to search for header files |
| 819 | --define (-D) C preprocessor macros to define |
| 820 | --undef (-U) C preprocessor macros to undefine |
| 821 | [...] |
| 822 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 823 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 824 | Note that an option spelled \longprogramopt{foo-bar} on the command-line |
| 825 | is spelled \option{foo\_bar} in configuration files. |
| 826 | |
| 827 | For example, say you want your extensions to be built |
| 828 | ``in-place''---that is, you have an extension \module{pkg.ext}, and you |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 829 | want the compiled extension file (\file{ext.so} on \UNIX, say) to be put |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 830 | in the same source directory as your pure Python modules |
| 831 | \module{pkg.mod1} and \module{pkg.mod2}. You can always use the |
| 832 | \longprogramopt{inplace} option on the command-line to ensure this: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 833 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 834 | \begin{verbatim} |
| 835 | python setup.py build_ext --inplace |
| 836 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 837 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 838 | But this requires that you always specify the \command{build\_ext} |
| 839 | command explicitly, and remember to provide \longprogramopt{inplace}. |
| 840 | An easier way is to ``set and forget'' this option, by encoding it in |
| 841 | \file{setup.cfg}, the configuration file for this distribution: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 842 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 843 | \begin{verbatim} |
| 844 | [build_ext] |
| 845 | inplace=1 |
| 846 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 847 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 848 | This will affect all builds of this module distribution, whether or not |
| 849 | you explcitly specify \command{build\_ext}. If you include |
| 850 | \file{setup.cfg} in your source distribution, it will also affect |
| 851 | end-user builds---which is probably a bad idea for this option, since |
| 852 | always building extensions in-place would break installation of the |
| 853 | module distribution. In certain peculiar cases, though, modules are |
| 854 | built right in their installation directory, so this is conceivably a |
| 855 | useful ability. (Distributing extensions that expect to be built in |
| 856 | their installation directory is almost always a bad idea, though.) |
| 857 | |
| 858 | Another example: certain commands take a lot of options that don't |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 859 | change from run to run; for example, \command{bdist\_rpm} needs to know |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 860 | everything required to generate a ``spec'' file for creating an RPM |
| 861 | distribution. Some of this information comes from the setup script, and |
| 862 | some is automatically generated by the Distutils (such as the list of |
| 863 | files installed). But some of it has to be supplied as options to |
| 864 | \command{bdist\_rpm}, which would be very tedious to do on the |
| 865 | command-line for every run. Hence, here is a snippet from the |
| 866 | Distutils' own \file{setup.cfg}: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 867 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 868 | \begin{verbatim} |
| 869 | [bdist_rpm] |
| 870 | release = 1 |
| 871 | packager = Greg Ward <gward@python.net> |
| 872 | doc_files = CHANGES.txt |
| 873 | README.txt |
| 874 | USAGE.txt |
| 875 | doc/ |
| 876 | examples/ |
| 877 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 878 | |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 879 | Note that the \option{doc\_files} option is simply a |
| 880 | whitespace-separated string split across multiple lines for readability. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 881 | |
| 882 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 883 | \begin{seealso} |
| 884 | \seetitle[../inst/config-syntax.html]{Installing Python |
| 885 | Modules}{More information on the configuration files is |
| 886 | available in the manual for system administrators.} |
| 887 | \end{seealso} |
| 888 | |
| 889 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 890 | \section{Creating a Source Distribution} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 891 | \label{source-dist} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 892 | |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 893 | As shown in section~\ref{simple-example}, you use the |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 894 | \command{sdist} command to create a source distribution. In the |
| 895 | simplest case, |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 896 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 897 | \begin{verbatim} |
| 898 | python setup.py sdist |
| 899 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 900 | |
Greg Ward | 19c67f8 | 2000-06-24 01:33:16 +0000 | [diff] [blame] | 901 | (assuming you haven't specified any \command{sdist} options in the setup |
| 902 | script or config file), \command{sdist} creates the archive of the |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 903 | default format for the current platform. The default format is a gzip'ed |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 904 | tar file (\file{.tar.gz}) on \UNIX, and ZIP file on Windows. |
| 905 | \XXX{no MacOS support here} |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 906 | |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 907 | You can specify as many formats as you like using the |
| 908 | \longprogramopt{formats} option, for example: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 909 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 910 | \begin{verbatim} |
| 911 | python setup.py sdist --formats=gztar,zip |
| 912 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 913 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 914 | to create a gzipped tarball and a zip file. The available formats are: |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 915 | \begin{tableiii}{l|l|c}{code}% |
| 916 | {Format}{Description}{Notes} |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 917 | \lineiii{zip}{zip file (\file{.zip})}{(1),(3)} |
| 918 | \lineiii{gztar}{gzip'ed tar file (\file{.tar.gz})}{(2),(4)} |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 919 | \lineiii{bztar}{bzip2'ed tar file (\file{.tar.bz2})}{(4)} |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 920 | \lineiii{ztar}{compressed tar file (\file{.tar.Z})}{(4)} |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 921 | \lineiii{tar}{tar file (\file{.tar})}{(4)} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 922 | \end{tableiii} |
| 923 | |
| 924 | \noindent Notes: |
| 925 | \begin{description} |
| 926 | \item[(1)] default on Windows |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 927 | \item[(2)] default on \UNIX |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 928 | \item[(3)] requires either external \program{zip} utility or |
Greg Ward | 954ce8b | 2002-05-10 14:42:10 +0000 | [diff] [blame] | 929 | \module{zipfile} module (part of the standard Python library since |
| 930 | Python~1.6) |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 931 | \item[(4)] requires external utilities: \program{tar} and possibly one |
| 932 | of \program{gzip}, \program{bzip2}, or \program{compress} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 933 | \end{description} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 934 | |
| 935 | |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 936 | |
| 937 | \subsection{Specifying the files to distribute} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 938 | \label{manifest} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 939 | |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 940 | If you don't supply an explicit list of files (or instructions on how to |
| 941 | generate one), the \command{sdist} command puts a minimal default set |
| 942 | into the source distribution: |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 943 | \begin{itemize} |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 944 | \item all Python source files implied by the \option{py\_modules} and |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 945 | \option{packages} options |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 946 | \item all C source files mentioned in the \option{ext\_modules} or |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 947 | \option{libraries} options (\XXX{getting C library sources currently |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 948 | broken -- no get\_source\_files() method in build\_clib.py!}) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 949 | \item anything that looks like a test script: \file{test/test*.py} |
| 950 | (currently, the Distutils don't do anything with test scripts except |
| 951 | include them in source distributions, but in the future there will be |
| 952 | a standard for testing Python module distributions) |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 953 | \item \file{README.txt} (or \file{README}), \file{setup.py} (or whatever |
| 954 | you called your setup script), and \file{setup.cfg} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 955 | \end{itemize} |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 956 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 957 | Sometimes this is enough, but usually you will want to specify |
| 958 | additional files to distribute. The typical way to do this is to write |
| 959 | a \emph{manifest template}, called \file{MANIFEST.in} by default. The |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 960 | manifest template is just a list of instructions for how to generate |
| 961 | your manifest file, \file{MANIFEST}, which is the exact list of files to |
| 962 | include in your source distribution. The \command{sdist} command |
| 963 | processes this template and generates a manifest based on its |
| 964 | instructions and what it finds in the filesystem. |
| 965 | |
| 966 | If you prefer to roll your own manifest file, the format is simple: one |
| 967 | filename per line, regular files (or symlinks to them) only. If you do |
| 968 | supply your own \file{MANIFEST}, you must specify everything: the |
| 969 | default set of files described above does not apply in this case. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 970 | |
| 971 | The manifest template has one command per line, where each command |
| 972 | specifies a set of files to include or exclude from the source |
| 973 | distribution. For an example, again we turn to the Distutils' own |
| 974 | manifest template: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 975 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 976 | \begin{verbatim} |
| 977 | include *.txt |
Greg Ward | 87da1ea | 2000-04-21 04:35:25 +0000 | [diff] [blame] | 978 | recursive-include examples *.txt *.py |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 979 | prune examples/sample?/build |
| 980 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 981 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 982 | The meanings should be fairly clear: include all files in the |
| 983 | distribution root matching \code{*.txt}, all files anywhere under the |
| 984 | \file{examples} directory matching \code{*.txt} or \code{*.py}, and |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 985 | exclude all directories matching \code{examples/sample?/build}. All of |
| 986 | this is done \emph{after} the standard include set, so you can exclude |
| 987 | files from the standard set with explicit instructions in the manifest |
| 988 | template. (Or, you can use the \longprogramopt{no-defaults} option to |
| 989 | disable the standard set entirely.) There are several other commands |
| 990 | available in the manifest template mini-language; see |
| 991 | section~\ref{sdist-cmd}. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 992 | |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 993 | The order of commands in the manifest template matters: initially, we |
| 994 | have the list of default files as described above, and each command in |
| 995 | the template adds to or removes from that list of files. Once we have |
| 996 | fully processed the manifest template, we remove files that should not |
| 997 | be included in the source distribution: |
| 998 | \begin{itemize} |
| 999 | \item all files in the Distutils ``build'' tree (default \file{build/}) |
| 1000 | \item all files in directories named \file{RCS} or \file{CVS} |
| 1001 | \end{itemize} |
| 1002 | Now we have our complete list of files, which is written to the manifest |
| 1003 | for future reference, and then used to build the source distribution |
| 1004 | archive(s). |
| 1005 | |
| 1006 | You can disable the default set of included files with the |
| 1007 | \longprogramopt{no-defaults} option, and you can disable the standard |
| 1008 | exclude set with \longprogramopt{no-prune}. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1009 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1010 | Following the Distutils' own manifest template, let's trace how the |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 1011 | \command{sdist} command builds the list of files to include in the |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1012 | Distutils source distribution: |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1013 | \begin{enumerate} |
| 1014 | \item include all Python source files in the \file{distutils} and |
| 1015 | \file{distutils/command} subdirectories (because packages |
| 1016 | corresponding to those two directories were mentioned in the |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 1017 | \option{packages} option in the setup script---see |
| 1018 | section~\ref{setup-script}) |
| 1019 | \item include \file{README.txt}, \file{setup.py}, and \file{setup.cfg} |
| 1020 | (standard files) |
| 1021 | \item include \file{test/test*.py} (standard files) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1022 | \item include \file{*.txt} in the distribution root (this will find |
| 1023 | \file{README.txt} a second time, but such redundancies are weeded out |
| 1024 | later) |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 1025 | \item include anything matching \file{*.txt} or \file{*.py} in the |
| 1026 | sub-tree under \file{examples}, |
| 1027 | \item exclude all files in the sub-trees starting at directories |
| 1028 | matching \file{examples/sample?/build}---this may exclude files |
| 1029 | included by the previous two steps, so it's important that the |
| 1030 | \code{prune} command in the manifest template comes after the |
| 1031 | \code{recursive-include} command |
| 1032 | \item exclude the entire \file{build} tree, and any \file{RCS} or |
| 1033 | \file{CVS} directories |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1034 | \end{enumerate} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1035 | Just like in the setup script, file and directory names in the manifest |
| 1036 | template should always be slash-separated; the Distutils will take care |
| 1037 | of converting them to the standard representation on your platform. |
| 1038 | That way, the manifest template is portable across operating systems. |
| 1039 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1040 | |
| 1041 | \subsection{Manifest-related options} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 1042 | \label{manifest-options} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1043 | |
| 1044 | The normal course of operations for the \command{sdist} command is as |
| 1045 | follows: |
| 1046 | \begin{itemize} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1047 | \item if the manifest file, \file{MANIFEST} doesn't exist, read |
| 1048 | \file{MANIFEST.in} and create the manifest |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 1049 | \item if neither \file{MANIFEST} nor \file{MANIFEST.in} exist, create a |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1050 | manifest with just the default file set |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 1051 | \item if either \file{MANIFEST.in} or the setup script (\file{setup.py}) |
| 1052 | are more recent than \file{MANIFEST}, recreate \file{MANIFEST} by |
| 1053 | reading \file{MANIFEST.in} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1054 | \item use the list of files now in \file{MANIFEST} (either just |
| 1055 | generated or read in) to create the source distribution archive(s) |
| 1056 | \end{itemize} |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 1057 | There are a couple of options that modify this behaviour. First, use |
| 1058 | the \longprogramopt{no-defaults} and \longprogramopt{no-prune} to |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1059 | disable the standard ``include'' and ``exclude'' sets. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1060 | |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 1061 | Second, you might want to force the manifest to be regenerated---for |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1062 | example, if you have added or removed files or directories that match an |
| 1063 | existing pattern in the manifest template, you should regenerate the |
| 1064 | manifest: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1065 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1066 | \begin{verbatim} |
| 1067 | python setup.py sdist --force-manifest |
| 1068 | \end{verbatim} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1069 | |
| 1070 | Or, you might just want to (re)generate the manifest, but not create a |
| 1071 | source distribution: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1072 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1073 | \begin{verbatim} |
| 1074 | python setup.py sdist --manifest-only |
| 1075 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1076 | |
Greg Ward | 54589d4 | 2000-09-06 01:37:35 +0000 | [diff] [blame] | 1077 | \longprogramopt{manifest-only} implies \longprogramopt{force-manifest}. |
| 1078 | \programopt{-o} is a shortcut for \longprogramopt{manifest-only}, and |
| 1079 | \programopt{-f} for \longprogramopt{force-manifest}. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1080 | |
| 1081 | |
| 1082 | \section{Creating Built Distributions} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 1083 | \label{built-dist} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1084 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1085 | A ``built distribution'' is what you're probably used to thinking of |
| 1086 | either as a ``binary package'' or an ``installer'' (depending on your |
| 1087 | background). It's not necessarily binary, though, because it might |
| 1088 | contain only Python source code and/or byte-code; and we don't call it a |
| 1089 | package, because that word is already spoken for in Python. (And |
| 1090 | ``installer'' is a term specific to the Windows world. \XXX{do Mac |
| 1091 | people use it?}) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1092 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1093 | A built distribution is how you make life as easy as possible for |
| 1094 | installers of your module distribution: for users of RPM-based Linux |
| 1095 | systems, it's a binary RPM; for Windows users, it's an executable |
| 1096 | installer; for Debian-based Linux users, it's a Debian package; and so |
| 1097 | forth. Obviously, no one person will be able to create built |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1098 | distributions for every platform under the sun, so the Distutils are |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1099 | designed to enable module developers to concentrate on their |
| 1100 | specialty---writing code and creating source distributions---while an |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1101 | intermediary species called \emph{packagers} springs up to turn source |
Greg Ward | 19c67f8 | 2000-06-24 01:33:16 +0000 | [diff] [blame] | 1102 | distributions into built distributions for as many platforms as there |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1103 | are packagers. |
| 1104 | |
| 1105 | Of course, the module developer could be his own packager; or the |
| 1106 | packager could be a volunteer ``out there'' somewhere who has access to |
| 1107 | a platform which the original developer does not; or it could be |
| 1108 | software periodically grabbing new source distributions and turning them |
| 1109 | into built distributions for as many platforms as the software has |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1110 | access to. Regardless of who they are, a packager uses the |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1111 | setup script and the \command{bdist} command family to generate built |
| 1112 | distributions. |
| 1113 | |
| 1114 | As a simple example, if I run the following command in the Distutils |
| 1115 | source tree: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1116 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1117 | \begin{verbatim} |
| 1118 | python setup.py bdist |
| 1119 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1120 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1121 | then the Distutils builds my module distribution (the Distutils itself |
| 1122 | in this case), does a ``fake'' installation (also in the \file{build} |
| 1123 | directory), and creates the default type of built distribution for my |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1124 | platform. The default format for built distributions is a ``dumb'' tar |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1125 | file on \UNIX, and a simple executable installer on Windows. (That tar |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1126 | file is considered ``dumb'' because it has to be unpacked in a specific |
| 1127 | location to work.) |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 1128 | |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 1129 | Thus, the above command on a \UNIX{} system creates |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1130 | \file{Distutils-1.0.\filevar{plat}.tar.gz}; unpacking this tarball |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1131 | from the right place installs the Distutils just as though you had |
| 1132 | downloaded the source distribution and run \code{python setup.py |
| 1133 | install}. (The ``right place'' is either the root of the filesystem or |
| 1134 | Python's \filevar{prefix} directory, depending on the options given to |
| 1135 | the \command{bdist\_dumb} command; the default is to make dumb |
| 1136 | distributions relative to \filevar{prefix}.) |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1137 | |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1138 | Obviously, for pure Python distributions, this isn't any simpler than |
| 1139 | just running \code{python setup.py install}---but for non-pure |
| 1140 | distributions, which include extensions that would need to be |
| 1141 | compiled, it can mean the difference between someone being able to use |
| 1142 | your extensions or not. And creating ``smart'' built distributions, |
| 1143 | such as an RPM package or an executable installer for Windows, is far |
| 1144 | more convenient for users even if your distribution doesn't include |
| 1145 | any extensions. |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1146 | |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1147 | The \command{bdist} command has a \longprogramopt{formats} option, |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 1148 | similar to the \command{sdist} command, which you can use to select the |
| 1149 | types of built distribution to generate: for example, |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1150 | |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1151 | \begin{verbatim} |
| 1152 | python setup.py bdist --format=zip |
| 1153 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1154 | |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 1155 | would, when run on a \UNIX{} system, create |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1156 | \file{Distutils-1.0.\filevar{plat}.zip}---again, this archive would be |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 1157 | unpacked from the root directory to install the Distutils. |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1158 | |
| 1159 | The available formats for built distributions are: |
| 1160 | \begin{tableiii}{l|l|c}{code}% |
| 1161 | {Format}{Description}{Notes} |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1162 | \lineiii{gztar}{gzipped tar file (\file{.tar.gz})}{(1),(3)} |
| 1163 | \lineiii{ztar}{compressed tar file (\file{.tar.Z})}{(3)} |
| 1164 | \lineiii{tar}{tar file (\file{.tar})}{(3)} |
| 1165 | \lineiii{zip}{zip file (\file{.zip})}{(4)} |
| 1166 | \lineiii{rpm}{RPM}{(5)} |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1167 | \lineiii{pkgtool}{Solaris \program{pkgtool}}{} |
| 1168 | \lineiii{sdux}{HP-UX \program{swinstall}}{} |
| 1169 | \lineiii{rpm}{RPM}{(5)} |
| 1170 | % \lineiii{srpm}{source RPM}{(5) \XXX{to do!}} |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 1171 | \lineiii{wininst}{self-extracting ZIP file for Windows}{(2),(4)} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1172 | \end{tableiii} |
| 1173 | |
| 1174 | \noindent Notes: |
| 1175 | \begin{description} |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 1176 | \item[(1)] default on \UNIX |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 1177 | \item[(2)] default on Windows \XXX{to-do!} |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1178 | \item[(3)] requires external utilities: \program{tar} and possibly one |
| 1179 | of \program{gzip}, \program{bzip2}, or \program{compress} |
| 1180 | \item[(4)] requires either external \program{zip} utility or |
Greg Ward | 954ce8b | 2002-05-10 14:42:10 +0000 | [diff] [blame] | 1181 | \module{zipfile} module (part of the standard Python library since |
| 1182 | Python~1.6) |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1183 | \item[(5)] requires external \program{rpm} utility, version 3.0.4 or |
| 1184 | better (use \code{rpm --version} to find out which version you have) |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1185 | \end{description} |
| 1186 | |
| 1187 | You don't have to use the \command{bdist} command with the |
Greg Ward | d5767a5 | 2000-04-19 22:48:09 +0000 | [diff] [blame] | 1188 | \longprogramopt{formats} option; you can also use the command that |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 1189 | directly implements the format you're interested in. Some of these |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1190 | \command{bdist} ``sub-commands'' actually generate several similar |
| 1191 | formats; for instance, the \command{bdist\_dumb} command generates all |
| 1192 | the ``dumb'' archive formats (\code{tar}, \code{ztar}, \code{gztar}, and |
| 1193 | \code{zip}), and \command{bdist\_rpm} generates both binary and source |
| 1194 | RPMs. The \command{bdist} sub-commands, and the formats generated by |
| 1195 | each, are: |
| 1196 | \begin{tableii}{l|l}{command}% |
| 1197 | {Command}{Formats} |
| 1198 | \lineii{bdist\_dumb}{tar, ztar, gztar, zip} |
| 1199 | \lineii{bdist\_rpm}{rpm, srpm} |
Greg Ward | 1d8f57a | 2000-08-05 00:43:11 +0000 | [diff] [blame] | 1200 | \lineii{bdist\_wininst}{wininst} |
Greg Ward | 46b98e3 | 2000-04-14 01:53:36 +0000 | [diff] [blame] | 1201 | \end{tableii} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1202 | |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1203 | The following sections give details on the individual \command{bdist\_*} |
| 1204 | commands. |
| 1205 | |
| 1206 | |
| 1207 | \subsection{Creating dumb built distributions} |
| 1208 | \label{creating-dumb} |
| 1209 | |
| 1210 | \XXX{Need to document absolute vs. prefix-relative packages here, but |
| 1211 | first I have to implement it!} |
| 1212 | |
| 1213 | |
| 1214 | \subsection{Creating RPM packages} |
| 1215 | \label{creating-rpms} |
| 1216 | |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1217 | The RPM format is used by many popular Linux distributions, including |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1218 | Red Hat, SuSE, and Mandrake. If one of these (or any of the other |
| 1219 | RPM-based Linux distributions) is your usual environment, creating RPM |
| 1220 | packages for other users of that same distribution is trivial. |
| 1221 | Depending on the complexity of your module distribution and differences |
| 1222 | between Linux distributions, you may also be able to create RPMs that |
| 1223 | work on different RPM-based distributions. |
| 1224 | |
| 1225 | The usual way to create an RPM of your module distribution is to run the |
| 1226 | \command{bdist\_rpm} command: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1227 | |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1228 | \begin{verbatim} |
| 1229 | python setup.py bdist_rpm |
| 1230 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1231 | |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1232 | or the \command{bdist} command with the \longprogramopt{format} option: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1233 | |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1234 | \begin{verbatim} |
| 1235 | python setup.py bdist --formats=rpm |
| 1236 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1237 | |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1238 | The former allows you to specify RPM-specific options; the latter allows |
| 1239 | you to easily specify multiple formats in one run. If you need to do |
| 1240 | both, you can explicitly specify multiple \command{bdist\_*} commands |
| 1241 | and their options: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1242 | |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1243 | \begin{verbatim} |
| 1244 | python setup.py bdist_rpm --packager="John Doe <jdoe@python.net>" \ |
| 1245 | bdist_wininst --target_version="2.0" |
| 1246 | \end{verbatim} |
| 1247 | |
| 1248 | Creating RPM packages is driven by a \file{.spec} file, much as using |
| 1249 | the Distutils is driven by the setup script. To make your life easier, |
| 1250 | the \command{bdist\_rpm} command normally creates a \file{.spec} file |
| 1251 | based on the information you supply in the setup script, on the command |
| 1252 | line, and in any Distutils configuration files. Various options and |
Andrew M. Kuchling | da23c4f | 2001-02-17 00:38:48 +0000 | [diff] [blame] | 1253 | sections in the \file{.spec} file are derived from options in the setup |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1254 | script as follows: |
| 1255 | \begin{tableii}{l|l}{textrm}% |
| 1256 | {RPM \file{.spec} file option or section}{Distutils setup script option} |
| 1257 | \lineii{Name}{\option{name}} |
| 1258 | \lineii{Summary (in preamble)}{\option{description}} |
| 1259 | \lineii{Version}{\option{version}} |
| 1260 | \lineii{Vendor}{\option{author} and \option{author\_email}, or \\& |
| 1261 | \option{maintainer} and \option{maintainer\_email}} |
| 1262 | \lineii{Copyright}{\option{licence}} |
| 1263 | \lineii{Url}{\option{url}} |
| 1264 | \lineii{\%description (section)}{\option{long\_description}} |
| 1265 | \end{tableii} |
| 1266 | |
| 1267 | Additionally, there many options in \file{.spec} files that don't have |
| 1268 | corresponding options in the setup script. Most of these are handled |
| 1269 | through options to the \command{bdist\_rpm} command as follows: |
| 1270 | \begin{tableiii}{l|l|l}{textrm}% |
| 1271 | {RPM \file{.spec} file option or section}% |
| 1272 | {\command{bdist\_rpm} option}% |
| 1273 | {default value} |
| 1274 | \lineiii{Release}{\option{release}}{``1''} |
| 1275 | \lineiii{Group}{\option{group}}{``Development/Libraries''} |
| 1276 | \lineiii{Vendor}{\option{vendor}}{(see above)} |
Andrew M. Kuchling | da23c4f | 2001-02-17 00:38:48 +0000 | [diff] [blame] | 1277 | \lineiii{Packager}{\option{packager}}{(none)} |
| 1278 | \lineiii{Provides}{\option{provides}}{(none)} |
| 1279 | \lineiii{Requires}{\option{requires}}{(none)} |
| 1280 | \lineiii{Conflicts}{\option{conflicts}}{(none)} |
| 1281 | \lineiii{Obsoletes}{\option{obsoletes}}{(none)} |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1282 | \lineiii{Distribution}{\option{distribution\_name}}{(none)} |
| 1283 | \lineiii{BuildRequires}{\option{build\_requires}}{(none)} |
| 1284 | \lineiii{Icon}{\option{icon}}{(none)} |
| 1285 | \end{tableiii} |
| 1286 | Obviously, supplying even a few of these options on the command-line |
| 1287 | would be tedious and error-prone, so it's usually best to put them in |
| 1288 | the setup configuration file, \file{setup.cfg}---see |
| 1289 | section~\ref{setup-config}. If you distribute or package many Python |
| 1290 | module distributions, you might want to put options that apply to all of |
| 1291 | them in your personal Distutils configuration file |
| 1292 | (\file{\textasciitilde/.pydistutils.cfg}). |
| 1293 | |
| 1294 | There are three steps to building a binary RPM package, all of which are |
| 1295 | handled automatically by the Distutils: |
| 1296 | \begin{enumerate} |
| 1297 | \item create a \file{.spec} file, which describes the package (analogous |
| 1298 | to the Distutils setup script; in fact, much of the information in the |
| 1299 | setup script winds up in the \file{.spec} file) |
| 1300 | \item create the source RPM |
| 1301 | \item create the ``binary'' RPM (which may or may not contain binary |
| 1302 | code, depending on whether your module distribution contains Python |
| 1303 | extensions) |
| 1304 | \end{enumerate} |
| 1305 | Normally, RPM bundles the last two steps together; when you use the |
| 1306 | Distutils, all three steps are typically bundled together. |
| 1307 | |
| 1308 | If you wish, you can separate these three steps. You can use the |
| 1309 | \longprogramopt{spec-only} option to make \command{bdist\_rpm} just |
| 1310 | create the \file{.spec} file and exit; in this case, the \file{.spec} |
| 1311 | file will be written to the ``distribution directory''---normally |
| 1312 | \file{dist/}, but customizable with the \longprogramopt{dist-dir} |
| 1313 | option. (Normally, the \file{.spec} file winds up deep in the ``build |
| 1314 | tree,'' in a temporary directory created by \command{bdist\_rpm}.) |
| 1315 | |
| 1316 | \XXX{this isn't implemented yet---is it needed?!} |
| 1317 | You can also specify a custom \file{.spec} file with the |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 1318 | \longprogramopt{spec-file} option; used in conjunction with |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1319 | \longprogramopt{spec-only}, this gives you an opportunity to customize |
| 1320 | the \file{.spec} file manually: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1321 | |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1322 | \begin{verbatim} |
| 1323 | > python setup.py bdist_rpm --spec-only |
| 1324 | # ...edit dist/FooBar-1.0.spec |
| 1325 | > python setup.py bdist_rpm --spec-file=dist/FooBar-1.0.spec |
| 1326 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1327 | |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1328 | (Although a better way to do this is probably to override the standard |
| 1329 | \command{bdist\_rpm} command with one that writes whatever else you want |
| 1330 | to the \file{.spec} file; see section~\ref{extending} for information on |
| 1331 | extending the Distutils.) |
| 1332 | |
| 1333 | |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1334 | \subsection{Creating Windows Installers} |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1335 | \label{creating-wininst} |
| 1336 | |
Thomas Heller | e61f365 | 2002-11-15 20:13:26 +0000 | [diff] [blame] | 1337 | Executable installers are the natural format for binary distributions |
| 1338 | on Windows. They display a nice graphical user interface, display |
| 1339 | some information about the module distribution to be installed taken |
Andrew M. Kuchling | d7abe2a | 2002-05-29 17:33:48 +0000 | [diff] [blame] | 1340 | from the metadata in the setup script, let the user select a few |
Thomas Heller | e61f365 | 2002-11-15 20:13:26 +0000 | [diff] [blame] | 1341 | options, and start or cancel the installation. |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1342 | |
Thomas Heller | e61f365 | 2002-11-15 20:13:26 +0000 | [diff] [blame] | 1343 | Since the metadata is taken from the setup script, creating Windows |
| 1344 | installers is usually as easy as running: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1345 | |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 1346 | \begin{verbatim} |
| 1347 | python setup.py bdist_wininst |
| 1348 | \end{verbatim} |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1349 | |
Thomas Heller | 36343f6 | 2002-11-15 19:20:56 +0000 | [diff] [blame] | 1350 | or the \command{bdist} command with the \longprogramopt{formats} option: |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1351 | |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 1352 | \begin{verbatim} |
| 1353 | python setup.py bdist --formats=wininst |
| 1354 | \end{verbatim} |
| 1355 | |
Thomas Heller | e61f365 | 2002-11-15 20:13:26 +0000 | [diff] [blame] | 1356 | If you have a pure module distribution (only containing pure Python |
| 1357 | modules and packages), the resulting installer will be version |
| 1358 | independent and have a name like \file{foo-1.0.win32.exe}. These |
| 1359 | installers can even be created on \UNIX{} or MacOS platforms. |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 1360 | |
| 1361 | If you have a non-pure distribution, the extensions can only be |
Andrew M. Kuchling | 40df710 | 2002-05-08 13:39:03 +0000 | [diff] [blame] | 1362 | created on a Windows platform, and will be Python version dependent. |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 1363 | The installer filename will reflect this and now has the form |
Thomas Heller | e61f365 | 2002-11-15 20:13:26 +0000 | [diff] [blame] | 1364 | \file{foo-1.0.win32-py2.0.exe}. You have to create a separate installer |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 1365 | for every Python version you want to support. |
| 1366 | |
| 1367 | The installer will try to compile pure modules into bytecode after |
Thomas Heller | e61f365 | 2002-11-15 20:13:26 +0000 | [diff] [blame] | 1368 | installation on the target system in normal and optimizing mode. If |
| 1369 | you don't want this to happen for some reason, you can run the |
Fred Drake | 0e9bfa3 | 2002-11-15 20:34:52 +0000 | [diff] [blame] | 1370 | \command{bdist_wininst} command with the |
| 1371 | \longprogramopt{no-target-compile} and/or the |
| 1372 | \longprogramopt{no-target-optimize} option. |
Thomas Heller | e61f365 | 2002-11-15 20:13:26 +0000 | [diff] [blame] | 1373 | |
Fred Drake | 0e9bfa3 | 2002-11-15 20:34:52 +0000 | [diff] [blame] | 1374 | By default the installer will display the cool ``Python Powered'' logo |
Thomas Heller | e61f365 | 2002-11-15 20:13:26 +0000 | [diff] [blame] | 1375 | when it is run, but you can also supply your own bitmap which must be |
Fred Drake | 0e9bfa3 | 2002-11-15 20:34:52 +0000 | [diff] [blame] | 1376 | a Windows \file{.bmp} file with the \longprogramopt{bitmap} option. |
Thomas Heller | e61f365 | 2002-11-15 20:13:26 +0000 | [diff] [blame] | 1377 | |
| 1378 | The installer will also display a large title on the desktop |
| 1379 | background window when it is run, which is constructed from the name |
| 1380 | of your distribution and the version number. This can be changed to |
| 1381 | another text by using the \longprogramopt{title} option. |
| 1382 | |
| 1383 | The installer file will be written to the ``distribution directory'' |
| 1384 | --- normally \file{dist/}, but customizable with the |
| 1385 | \longprogramopt{dist-dir} option. |
| 1386 | |
Thomas Heller | 2c3bfc2 | 2002-12-12 18:54:19 +0000 | [diff] [blame] | 1387 | \subsubsection{The Postinstallation script} |
| 1388 | \label{postinstallation-script} |
| 1389 | |
| 1390 | Starting with Python 2.3, a postinstallation script can be specified |
| 1391 | which the \longprogramopt{install-script} option. The basename of the |
| 1392 | script must be specified, and the script filename must also be listed |
| 1393 | in the scripts argument to the setup function. |
| 1394 | |
| 1395 | This script will be run at installation time on the target system |
| 1396 | after all the files have been copied, with argv[1] set to '-install', |
| 1397 | and again at uninstallation time before the files are removed with argv[1] |
| 1398 | set to '-remove'. |
| 1399 | |
| 1400 | The installation script runs embedded in the windows installer, every |
| 1401 | output (sys.stdout, sys.stderr) is redirected into a buffer and will |
| 1402 | be displayed in the GUI after the script has finished. |
| 1403 | |
| 1404 | Some functions especially useful in this context are available in the |
| 1405 | installation script. |
| 1406 | |
| 1407 | \begin{verbatim} |
| 1408 | dir_created(pathname) |
| 1409 | file_created(pathname) |
| 1410 | \end{verbatim} |
| 1411 | |
| 1412 | These functions should be called when a directory or file is created |
| 1413 | by the postinstall script at installation time. It will register the |
| 1414 | pathname with the uninstaller, so that it will be removed when the |
| 1415 | distribution is uninstalled. To be safe, directories are only removed |
| 1416 | if they are empty. |
| 1417 | |
| 1418 | \begin{verbatim} |
| 1419 | get_special_folder_path(csidl_string) |
| 1420 | \end{verbatim} |
| 1421 | |
| 1422 | This function can be used to retrieve special folder locations on |
| 1423 | Windows like the Start Menu or the Desktop. It returns the full path |
| 1424 | to the folder. 'csidl_string' must be on of the following strings: |
| 1425 | |
| 1426 | \begin{verbatim} |
| 1427 | "CSIDL_APPDATA" |
| 1428 | |
| 1429 | "CSIDL_COMMON_STARTMENU" |
| 1430 | "CSIDL_STARTMENU" |
| 1431 | |
| 1432 | "CSIDL_COMMON_DESKTOPDIRECTORY" |
| 1433 | "CSIDL_DESKTOPDIRECTORY" |
| 1434 | |
| 1435 | "CSIDL_COMMON_STARTUP" |
| 1436 | "CSIDL_STARTUP" |
| 1437 | |
| 1438 | "CSIDL_COMMON_PROGRAMS" |
| 1439 | "CSIDL_PROGRAMS" |
| 1440 | |
| 1441 | "CSIDL_FONTS" |
| 1442 | \end{verbatim} |
| 1443 | |
| 1444 | If the folder cannot be retrieved, OSError is raised. |
| 1445 | |
| 1446 | Which folders are available depends on the exact Windows version, and probably |
| 1447 | also the configuration. For details refer to Microsoft's documentation of the |
Thomas Heller | 63b4dd3 | 2002-12-12 19:35:00 +0000 | [diff] [blame] | 1448 | \code{SHGetSpecialFolderPath} function. |
Thomas Heller | 2c3bfc2 | 2002-12-12 18:54:19 +0000 | [diff] [blame] | 1449 | |
| 1450 | \begin{verbatim} |
| 1451 | create_shortcut(target, description, filename[, arguments[, |
| 1452 | workdir[, iconpath[, iconindex]]]]) |
| 1453 | \end{verbatim} |
| 1454 | |
| 1455 | This function creates a shortcut. |
Thomas Heller | 63b4dd3 | 2002-12-12 19:35:00 +0000 | [diff] [blame] | 1456 | \var{target} is the path to the program to be started by the shortcut. |
| 1457 | \var{description} is the description of the sortcut. |
| 1458 | \var{filename} is the title of the shortcut that the user will see. |
| 1459 | \var{arguments} specifies the command line arguments, if any. |
| 1460 | \var{workdir} is the working directory for the program. |
| 1461 | \var{iconpath} is the file containing the icon for the shortcut, |
| 1462 | and \var{iconindex} is the index of the icon in the file |
| 1463 | \var{iconpath}. Again, for details consult the Microsoft |
| 1464 | documentation for the \code{IShellLink} interface. |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1465 | |
Andrew M. Kuchling | d15f4e3 | 2003-01-03 15:42:14 +0000 | [diff] [blame^] | 1466 | \section{Registering with the Package Index} |
| 1467 | \label{package-index} |
| 1468 | |
| 1469 | The Python Package Index (PyPI) holds meta-data describing distributions |
| 1470 | packaged with distutils. The distutils command \command{register} is |
| 1471 | used to submit your distribution's meta-data to the index. It is invoked |
| 1472 | as follows: |
| 1473 | |
| 1474 | \begin{verbatim} |
| 1475 | python setup.py register |
| 1476 | \end{verbatim} |
| 1477 | |
| 1478 | Distutils will respond with the following prompt: |
| 1479 | |
| 1480 | \begin{verbatim} |
| 1481 | running register |
| 1482 | We need to know who you are, so please choose either: |
| 1483 | 1. use your existing login, |
| 1484 | 2. register as a new user, |
| 1485 | 3. have the server generate a new password for you (and email it to you), or |
| 1486 | 4. quit |
| 1487 | Your selection [default 1]: |
| 1488 | \end{verbatim} |
| 1489 | |
| 1490 | \noindent Note: if your username and password are saved locally, you will |
| 1491 | not see this menu. |
| 1492 | |
| 1493 | If you have not registered with PyPI, then you will need to do so now. You |
| 1494 | should choose option 2, and enter your details as required. Soon after |
| 1495 | submitting your details, you will receive an email which will be used to |
| 1496 | confirm your registration. |
| 1497 | |
| 1498 | Once you are registered, you may choose option 1 from the menu. You will |
| 1499 | be prompted for your PyPI username and password, and \command{register} |
| 1500 | will then submit your meta-data to the index. |
| 1501 | |
| 1502 | You may submit any number of versions of your distribution to the index. If |
| 1503 | you alter the meta-data for a particular version, you may submit it again |
| 1504 | and the index will be updated. |
| 1505 | |
| 1506 | PyPI holds a record for each (name, version) combination submitted. The |
| 1507 | first user to submit information for a given name is designated the Owner |
| 1508 | of that name. They may submit changes through the \command{register} |
| 1509 | command or through the web interface. They may also designate other users |
| 1510 | as Owners or Maintainers. Maintainers may edit the package information, but |
| 1511 | not designate other Owners or Maintainers. |
| 1512 | |
| 1513 | By default PyPI will list all versions of a given package. To hide certain |
| 1514 | versions, the Hidden property should be set to yes. This must be edited |
| 1515 | through the web interface. |
| 1516 | |
| 1517 | |
| 1518 | |
Greg Ward | 007c04a | 2002-05-10 14:45:59 +0000 | [diff] [blame] | 1519 | \section{Examples} |
| 1520 | \label{examples} |
Andrew M. Kuchling | d15f4e3 | 2003-01-03 15:42:14 +0000 | [diff] [blame^] | 1521 | |
Greg Ward | 007c04a | 2002-05-10 14:45:59 +0000 | [diff] [blame] | 1522 | \subsection{Pure Python distribution (by module)} |
| 1523 | \label{pure-mod} |
| 1524 | |
| 1525 | If you're just distributing a couple of modules, especially if they |
| 1526 | don't live in a particular package, you can specify them individually |
| 1527 | using the \option{py\_modules} option in the setup script. |
| 1528 | |
| 1529 | In the simplest case, you'll have two files to worry about: a setup |
| 1530 | script and the single module you're distributing, \file{foo.py} in this |
| 1531 | example: |
| 1532 | \begin{verbatim} |
| 1533 | <root>/ |
| 1534 | setup.py |
| 1535 | foo.py |
| 1536 | \end{verbatim} |
| 1537 | (In all diagrams in this section, \verb|<root>| will refer to the |
| 1538 | distribution root directory.) A minimal setup script to describe this |
| 1539 | situation would be: |
| 1540 | \begin{verbatim} |
| 1541 | from distutils.core import setup |
| 1542 | setup(name = "foo", version = "1.0", |
| 1543 | py_modules = ["foo"]) |
| 1544 | \end{verbatim} |
| 1545 | Note that the name of the distribution is specified independently with |
| 1546 | the \option{name} option, and there's no rule that says it has to be the |
| 1547 | same as the name of the sole module in the distribution (although that's |
| 1548 | probably a good convention to follow). However, the distribution name |
| 1549 | is used to generate filenames, so you should stick to letters, digits, |
| 1550 | underscores, and hyphens. |
| 1551 | |
| 1552 | Since \option{py\_modules} is a list, you can of course specify multiple |
| 1553 | modules, eg. if you're distributing modules \module{foo} and |
| 1554 | \module{bar}, your setup might look like this: |
| 1555 | \begin{verbatim} |
| 1556 | <root>/ |
| 1557 | setup.py |
| 1558 | foo.py |
| 1559 | bar.py |
| 1560 | \end{verbatim} |
| 1561 | and the setup script might be |
| 1562 | \begin{verbatim} |
| 1563 | from distutils.core import setup |
| 1564 | setup(name = "foobar", version = "1.0", |
| 1565 | py_modules = ["foo", "bar"]) |
| 1566 | \end{verbatim} |
| 1567 | |
| 1568 | You can put module source files into another directory, but if you have |
| 1569 | enough modules to do that, it's probably easier to specify modules by |
| 1570 | package rather than listing them individually. |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1571 | |
| 1572 | |
Greg Ward | 007c04a | 2002-05-10 14:45:59 +0000 | [diff] [blame] | 1573 | \subsection{Pure Python distribution (by package)} |
| 1574 | \label{pure-pkg} |
| 1575 | |
| 1576 | If you have more than a couple of modules to distribute, especially if |
| 1577 | they are in multiple packages, it's probably easier to specify whole |
| 1578 | packages rather than individual modules. This works even if your |
| 1579 | modules are not in a package; you can just tell the Distutils to process |
| 1580 | modules from the root package, and that works the same as any other |
| 1581 | package (except that you don't have to have an \file{\_\_init\_\_.py} |
| 1582 | file). |
| 1583 | |
| 1584 | The setup script from the last example could also be written as |
| 1585 | \begin{verbatim} |
| 1586 | from distutils.core import setup |
| 1587 | setup(name = "foobar", version = "1.0", |
| 1588 | packages = [""]) |
| 1589 | \end{verbatim} |
| 1590 | (The empty string stands for the root package.) |
| 1591 | |
| 1592 | If those two files are moved into a subdirectory, but remain in the root |
| 1593 | package, e.g.: |
| 1594 | \begin{verbatim} |
| 1595 | <root>/ |
| 1596 | setup.py |
| 1597 | src/ foo.py |
| 1598 | bar.py |
| 1599 | \end{verbatim} |
| 1600 | then you would still specify the root package, but you have to tell the |
| 1601 | Distutils where source files in the root package live: |
| 1602 | \begin{verbatim} |
| 1603 | from distutils.core import setup |
| 1604 | setup(name = "foobar", version = "1.0", |
| 1605 | package_dir = {"": "src"}, |
| 1606 | packages = [""]) |
| 1607 | \end{verbatim} |
| 1608 | |
| 1609 | More typically, though, you will want to distribute multiple modules in |
| 1610 | the same package (or in sub-packages). For example, if the \module{foo} |
| 1611 | and \module{bar} modules belong in package \module{foobar}, one way to |
| 1612 | layout your source tree is |
| 1613 | \begin{verbatim} |
| 1614 | <root>/ |
| 1615 | setup.py |
| 1616 | foobar/ |
| 1617 | __init__.py |
| 1618 | foo.py |
| 1619 | bar.py |
| 1620 | \end{verbatim} |
| 1621 | This is in fact the default layout expected by the Distutils, and the |
| 1622 | one that requires the least work to describe in your setup script: |
| 1623 | \begin{verbatim} |
| 1624 | from distutils.core import setup |
| 1625 | setup(name = "foobar", version = "1.0", |
| 1626 | packages = ["foobar"]) |
| 1627 | \end{verbatim} |
| 1628 | |
| 1629 | If you want to put modules in directories not named for their package, |
| 1630 | then you need to use the \option{package\_dir} option again. For |
| 1631 | example, if the \file{src} directory holds modules in the |
| 1632 | \module{foobar} package: |
| 1633 | \begin{verbatim} |
| 1634 | <root>/ |
| 1635 | setup.py |
| 1636 | src/ |
| 1637 | __init__.py |
| 1638 | foo.py |
| 1639 | bar.py |
| 1640 | \end{verbatim} |
| 1641 | an appropriate setup script would be |
| 1642 | \begin{verbatim} |
| 1643 | from distutils.core import setup |
| 1644 | setup(name = "foobar", version = "1.0", |
| 1645 | package_dir = {"foobar" : "src"}, |
| 1646 | packages = ["foobar"]) |
| 1647 | \end{verbatim} |
| 1648 | |
| 1649 | Or, you might put modules from your main package right in the |
| 1650 | distribution root: |
| 1651 | \begin{verbatim} |
| 1652 | <root>/ |
| 1653 | setup.py |
| 1654 | __init__.py |
| 1655 | foo.py |
| 1656 | bar.py |
| 1657 | \end{verbatim} |
| 1658 | in which case your setup script would be |
| 1659 | \begin{verbatim} |
| 1660 | from distutils.core import setup |
| 1661 | setup(name = "foobar", version = "1.0", |
| 1662 | package_dir = {"foobar" : ""}, |
| 1663 | packages = ["foobar"]) |
| 1664 | \end{verbatim} |
| 1665 | (The empty string also stands for the current directory.) |
| 1666 | |
| 1667 | If you have sub-packages, they must be explicitly listed in |
| 1668 | \option{packages}, but any entries in \option{package\_dir} |
| 1669 | automatically extend to sub-packages. (In other words, the Distutils |
| 1670 | does \emph{not} scan your source tree, trying to figure out which |
| 1671 | directories correspond to Python packages by looking for |
| 1672 | \file{\_\_init\_\_.py} files.) Thus, if the default layout grows a |
| 1673 | sub-package: |
| 1674 | \begin{verbatim} |
| 1675 | <root>/ |
| 1676 | setup.py |
| 1677 | foobar/ |
| 1678 | __init__.py |
| 1679 | foo.py |
| 1680 | bar.py |
| 1681 | subfoo/ |
| 1682 | __init__.py |
| 1683 | blah.py |
| 1684 | \end{verbatim} |
| 1685 | then the corresponding setup script would be |
| 1686 | \begin{verbatim} |
| 1687 | from distutils.core import setup |
| 1688 | setup(name = "foobar", version = "1.0", |
| 1689 | packages = ["foobar", "foobar.subfoo"]) |
| 1690 | \end{verbatim} |
| 1691 | (Again, the empty string in \option{package\_dir} stands for the current |
| 1692 | directory.) |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1693 | |
| 1694 | |
Greg Ward | 007c04a | 2002-05-10 14:45:59 +0000 | [diff] [blame] | 1695 | \subsection{Single extension module} |
| 1696 | \label{single-ext} |
| 1697 | |
| 1698 | Extension modules are specified using the \option{ext\_modules} option. |
| 1699 | \option{package\_dir} has no effect on where extension source files are |
| 1700 | found; it only affects the source for pure Python modules. The simplest |
| 1701 | case, a single extension module in a single C source file, is: |
| 1702 | \begin{verbatim} |
| 1703 | <root>/ |
| 1704 | setup.py |
| 1705 | foo.c |
| 1706 | \end{verbatim} |
| 1707 | If the \module{foo} extension belongs in the root package, the setup |
| 1708 | script for this could be |
| 1709 | \begin{verbatim} |
| 1710 | from distutils.core import setup |
| 1711 | setup(name = "foobar", version = "1.0", |
| 1712 | ext_modules = [Extension("foo", ["foo.c"])]) |
| 1713 | \end{verbatim} |
| 1714 | |
| 1715 | If the extension actually belongs in a package, say \module{foopkg}, |
| 1716 | then |
| 1717 | |
| 1718 | With exactly the same source tree layout, this extension can be put in |
| 1719 | the \module{foopkg} package simply by changing the name of the |
| 1720 | extension: |
| 1721 | \begin{verbatim} |
| 1722 | from distutils.core import setup |
| 1723 | setup(name = "foobar", version = "1.0", |
| 1724 | ext_modules = [Extension("foopkg.foo", ["foo.c"])]) |
| 1725 | \end{verbatim} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1726 | |
| 1727 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1728 | %\subsection{Multiple extension modules} |
| 1729 | %\label{multiple-ext} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1730 | |
| 1731 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1732 | %\subsection{Putting it all together} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1733 | |
| 1734 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1735 | %\section{Extending the Distutils} |
| 1736 | %\label{extending} |
Greg Ward | 4a9e722 | 2000-04-25 02:57:36 +0000 | [diff] [blame] | 1737 | |
| 1738 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1739 | %\subsection{Extending existing commands} |
| 1740 | %\label{extend-existing} |
Greg Ward | 4a9e722 | 2000-04-25 02:57:36 +0000 | [diff] [blame] | 1741 | |
| 1742 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1743 | %\subsection{Writing new commands} |
| 1744 | %\label{new-commands} |
Greg Ward | 4a9e722 | 2000-04-25 02:57:36 +0000 | [diff] [blame] | 1745 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1746 | %\XXX{Would an uninstall command be a good example here?} |
Thomas Heller | 5f52f72 | 2001-02-19 17:48:03 +0000 | [diff] [blame] | 1747 | |
Greg Ward | 4a9e722 | 2000-04-25 02:57:36 +0000 | [diff] [blame] | 1748 | |
| 1749 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1750 | \section{Reference} |
Greg Ward | 47f99a6 | 2000-09-04 20:07:15 +0000 | [diff] [blame] | 1751 | \label{reference} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1752 | |
| 1753 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1754 | %\subsection{Building modules: the \protect\command{build} command family} |
| 1755 | %\label{build-cmds} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1756 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1757 | %\subsubsection{\protect\command{build}} |
| 1758 | %\label{build-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1759 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1760 | %\subsubsection{\protect\command{build\_py}} |
| 1761 | %\label{build-py-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1762 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1763 | %\subsubsection{\protect\command{build\_ext}} |
| 1764 | %\label{build-ext-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1765 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1766 | %\subsubsection{\protect\command{build\_clib}} |
| 1767 | %\label{build-clib-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1768 | |
| 1769 | |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1770 | \subsection{Installing modules: the \protect\command{install} command family} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 1771 | \label{install-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1772 | |
Gregory P. Smith | 147e5f3 | 2000-05-12 00:58:18 +0000 | [diff] [blame] | 1773 | The install command ensures that the build commands have been run and then |
| 1774 | runs the subcommands \command{install\_lib}, |
| 1775 | \command{install\_data} and |
| 1776 | \command{install\_scripts}. |
| 1777 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1778 | %\subsubsection{\protect\command{install\_lib}} |
| 1779 | %\label{install-lib-cmd} |
Gregory P. Smith | 147e5f3 | 2000-05-12 00:58:18 +0000 | [diff] [blame] | 1780 | |
| 1781 | \subsubsection{\protect\command{install\_data}} |
Greg Ward | 1365a30 | 2000-08-31 14:47:05 +0000 | [diff] [blame] | 1782 | \label{install-data-cmd} |
Gregory P. Smith | 147e5f3 | 2000-05-12 00:58:18 +0000 | [diff] [blame] | 1783 | This command installs all data files provided with the distribution. |
| 1784 | |
| 1785 | \subsubsection{\protect\command{install\_scripts}} |
Greg Ward | 1365a30 | 2000-08-31 14:47:05 +0000 | [diff] [blame] | 1786 | \label{install-scripts-cmd} |
Gregory P. Smith | 147e5f3 | 2000-05-12 00:58:18 +0000 | [diff] [blame] | 1787 | This command installs all (Python) scripts in the distribution. |
| 1788 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1789 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1790 | %\subsection{Cleaning up: the \protect\command{clean} command} |
| 1791 | %\label{clean-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1792 | |
| 1793 | |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 1794 | \subsection{Creating a source distribution: the |
| 1795 | \protect\command{sdist} command} |
Greg Ward | e78298a | 2000-04-28 17:12:24 +0000 | [diff] [blame] | 1796 | \label{sdist-cmd} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1797 | |
| 1798 | |
| 1799 | \XXX{fragment moved down from above: needs context!} |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1800 | |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1801 | The manifest template commands are: |
| 1802 | \begin{tableii}{ll}{command}{Command}{Description} |
Greg Ward | 87da1ea | 2000-04-21 04:35:25 +0000 | [diff] [blame] | 1803 | \lineii{include \var{pat1} \var{pat2} ... } |
| 1804 | {include all files matching any of the listed patterns} |
| 1805 | \lineii{exclude \var{pat1} \var{pat2} ... } |
| 1806 | {exclude all files matching any of the listed patterns} |
| 1807 | \lineii{recursive-include \var{dir} \var{pat1} \var{pat2} ... } |
| 1808 | {include all files under \var{dir} matching any of the listed patterns} |
| 1809 | \lineii{recursive-exclude \var{dir} \var{pat1} \var{pat2} ...} |
| 1810 | {exclude all files under \var{dir} matching any of the listed patterns} |
| 1811 | \lineii{global-include \var{pat1} \var{pat2} ...} |
Greg Ward | 1bbe329 | 2000-06-25 03:14:13 +0000 | [diff] [blame] | 1812 | {include all files anywhere in the source tree matching\\& |
Greg Ward | 87da1ea | 2000-04-21 04:35:25 +0000 | [diff] [blame] | 1813 | any of the listed patterns} |
| 1814 | \lineii{global-exclude \var{pat1} \var{pat2} ...} |
Greg Ward | 1bbe329 | 2000-06-25 03:14:13 +0000 | [diff] [blame] | 1815 | {exclude all files anywhere in the source tree matching\\& |
Greg Ward | 87da1ea | 2000-04-21 04:35:25 +0000 | [diff] [blame] | 1816 | any of the listed patterns} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1817 | \lineii{prune \var{dir}}{exclude all files under \var{dir}} |
| 1818 | \lineii{graft \var{dir}}{include all files under \var{dir}} |
| 1819 | \end{tableii} |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 1820 | The patterns here are \UNIX-style ``glob'' patterns: \code{*} matches any |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1821 | sequence of regular filename characters, \code{?} matches any single |
| 1822 | regular filename character, and \code{[\var{range}]} matches any of the |
| 1823 | characters in \var{range} (e.g., \code{a-z}, \code{a-zA-Z}, |
Greg Ward | facb8db | 2000-04-09 04:32:40 +0000 | [diff] [blame] | 1824 | \code{a-f0-9\_.}). The definition of ``regular filename character'' is |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 1825 | platform-specific: on \UNIX{} it is anything except slash; on Windows |
| 1826 | anything except backslash or colon; on MacOS anything except colon. |
Greg Ward | b652897 | 2000-09-07 02:40:37 +0000 | [diff] [blame] | 1827 | |
Fred Drake | eff9a87 | 2000-10-26 16:41:03 +0000 | [diff] [blame] | 1828 | \XXX{Windows and MacOS support not there yet} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1829 | |
| 1830 | |
Fred Drake | a09262e | 2001-03-01 18:35:43 +0000 | [diff] [blame] | 1831 | %\subsection{Creating a built distribution: the |
| 1832 | % \protect\command{bdist} command family} |
| 1833 | %\label{bdist-cmds} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1834 | |
| 1835 | |
Fred Drake | ab70b38 | 2001-08-02 15:13:15 +0000 | [diff] [blame] | 1836 | %\subsubsection{\protect\command{bdist}} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1837 | |
Fred Drake | ab70b38 | 2001-08-02 15:13:15 +0000 | [diff] [blame] | 1838 | %\subsubsection{\protect\command{bdist\_dumb}} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1839 | |
Fred Drake | ab70b38 | 2001-08-02 15:13:15 +0000 | [diff] [blame] | 1840 | %\subsubsection{\protect\command{bdist\_rpm}} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1841 | |
Fred Drake | ab70b38 | 2001-08-02 15:13:15 +0000 | [diff] [blame] | 1842 | %\subsubsection{\protect\command{bdist\_wininst}} |
| 1843 | |
| 1844 | |
| 1845 | \input{sysconfig} |
Greg Ward | 16aafcd | 2000-04-09 04:06:44 +0000 | [diff] [blame] | 1846 | |
| 1847 | |
Greg Ward | abc5216 | 2000-02-26 00:52:48 +0000 | [diff] [blame] | 1848 | \end{document} |