@@ -21,16 +21,16 @@ \section{Introduction}
2121support for distributing modules, nor have Python users had much support
2222for installing and maintaining third-party modules. With the
2323introduction of the Python Distribution Utilities (Distutils for short)
24- in Python 2.0 , this situation should start to improve.
24+ in Python 1.6 , this situation should start to improve.
2525
2626This document only covers using the Distutils to distribute your Python
27- modules. Using the Distutils does not tie you to Python 2.0 , though:
28- the Distutils work just fine with Python 1.5, and it is reasonable (and
29- expected to become commonplace) to expect users of Python 1.5 to
27+ modules. Using the Distutils does not tie you to Python 1.6 , though:
28+ the Distutils work just fine with Python 1.5.2 , and it is reasonable
29+ (and expected to become commonplace) to expect users of Python 1.5.2 to
3030download and install the Distutils separately before they can install
31- your modules. Python 2.0 users, of course, won't have to add anything
32- to their Python installation in order to use the Distutils to install
33- third-party modules.
31+ your modules. Python 1.6 (or later) users, of course, won't have to add
32+ anything to their Python installation in order to use the Distutils to
33+ install third-party modules.
3434
3535This document concentrates on the role of developer/distributor: if
3636you're looking for information on installing Python modules, you
@@ -68,9 +68,10 @@ \subsection{A simple example}
6868\label {simple-example }
6969
7070The setup script is usually quite simple, although since it's written in
71- Python, there are no arbitrary limits to what you can do. If all you
72- want to do is distribute a module called \module {foo}, contained in a
73- file \file {foo.py}, then your setup script can be as little as this:
71+ Python, there are no arbitrary limits to what you can do with it. If
72+ all you want to do is distribute a module called \module {foo}, contained
73+ in a file \file {foo.py}, then your setup script can be as little as
74+ this:
7475\begin {verbatim }
7576from distutils.core import setup
7677setup (name = "foo",
@@ -118,7 +119,6 @@ \subsection{A simple example}
118119more often for installers (although most developers will want to install
119120their own code occasionally).
120121
121- \XXX {only partially implemented}%
122122If you want to make things really easy for your users, you can create
123123one or more built distributions for them. For instance, if you are
124124running on a Windows machine, and want to make things easy for other
@@ -128,9 +128,10 @@ \subsection{A simple example}
128128\begin {verbatim }
129129python setup.py bdist_wininst
130130\end {verbatim }
131- will create an executable installer, \file {Foo-1\_ 0. exe}, in the current
132- directory.
131+ will create an executable installer, \file {Foo-1.0.win32. exe}, in the
132+ current directory.
133133
134+ \XXX {not implemented yet}
134135(Another way to create executable installers for Windows is with the
135136\command {bdist\_ wise} command, which uses Wise---the commercial
136137installer-generator used to create Python's own installer---to create
@@ -142,11 +143,21 @@ \subsection{A simple example}
142143Wise installed on your system for the \command {bdist\_ wise} command to
143144work; it's available from \url {http://foo/bar/baz}.)
144145
145- Other \command {bdist} commands exist for other platforms: for example,
146- \command {bdist\_ rpm} for RPM-based Linux systems, (\command {bdist\_ deb})
147- for Debian-based Linux systems, and so forth. See
148- section~\ref {bdist-cmds } for details on all the \command {bdist}
149- commands.
146+ Currently (Distutils 0.9.1), the are only other useful built
147+ distribution format is RPM, implemented by the \command {bdist\_ rpm}
148+ command. For example, the following command will create an RPM file
149+ called \file {Foo-1.0.noarch.rpm}:
150+ \begin {verbatim }
151+ python setup.py bdist_rpm
152+ \end {verbatim }
153+ (This uses the \command {rpm} command, so has to be run on an RPM-based
154+ system such as Red Hat Linux, SuSE Linux, or Mandrake Linux.)
155+
156+ You can find out what distribution formats are available at any time by
157+ running
158+ \begin {verbatim }
159+ python setup.py bdist --help-formats
160+ \end {verbatim }
150161
151162
152163\subsection {General Python terminology }
@@ -158,9 +169,8 @@ \subsection{General Python terminology}
158169following glossary of common Python terms:
159170\begin {description }
160171\item [module] the basic unit of code reusability in Python: a block of
161- code imported by some other code. There are three types of modules
162- that concern us here: pure Python modules, extension modules, and
163- packages.
172+ code imported by some other code. Three types of modules concern us
173+ here: pure Python modules, extension modules, and packages.
164174\item [pure Python module] a module written in Python and contained in a
165175 single \file {.py} file (and possibly associated \file {.pyc} and/or
166176 \file {.pyo} files). Sometimes referred to as a `` pure module.''
@@ -224,10 +234,10 @@ \section{Writing the Setup Script}
224234
225235Here's a slightly more involved example, which we'll follow for the next
226236couple of sections: the Distutils' own setup script. (Keep in mind that
227- although the Distutils are included with Python 2.0 , they also have an
228- independent existence so that Python 1.5 users can use them to install
229- other module distributions. The Distutils' own setup script is used to
230- install the package into Python 1.5.)
237+ although the Distutils are included with Python 1.6 and later , they also
238+ have an independent existence so that Python 1.5.2 users can use them to
239+ install other module distributions. The Distutils' own setup script,
240+ shown here, is used to install the package into Python 1.5.2 .)
231241
232242\begin {verbatim }
233243#!/usr/bin/env python
@@ -236,7 +246,7 @@ \section{Writing the Setup Script}
236246
237247setup (name = "Distutils",
238248 version = "1.0",
239- description = "Python Module Distribution Utilities",
249+ description = "Python Distribution Utilities",
240250 author = "Greg Ward",
241251 author_email = "[email protected] ", 242252 url = "http://www.python.org/sigs/distutils-sig/",
@@ -284,17 +294,17 @@ \subsection{Package directories}
284294If you use a different convention to lay out your source directory,
285295that's no problem: you just have to supply the \option {package\_ dir}
286296option to tell the Distutils about your convention. For example, say
287- you keep all Python source under \file {lib}, so that modules not in any
288- package are right in \file {lib}, modules in the \module {foo} package
289- are in \file {lib/foo}, and so forth. Then you would put
297+ you keep all Python source under \file {lib}, so that modules in the
298+ `` root package'' (i.e., not in any package at all) are right in
299+ \file {lib}, modules in the \module {foo} package are in \file {lib/foo},
300+ and so forth. Then you would put
290301\begin {verbatim }
291302package_dir = {'': 'lib'}
292303\end {verbatim }
293304in your setup script. (The keys to this dictionary are package names,
294- and an empty package name stands for the `` root package,'' i.e. no
295- package at all. The values are directory names relative to your
296- distribution root.) In this case, when you say
297- \code {packages = ['foo']}, you are promising that the file
305+ and an empty package name stands for the root package. The values are
306+ directory names relative to your distribution root.) In this case, when
307+ you say \code {packages = ['foo']}, you are promising that the file
298308\file {lib/foo/\_\_ init\_\_ .py} exists.
299309
300310Another possible convention is to put the \module {foo} package right in
@@ -337,15 +347,11 @@ \subsection{Listing individual modules}
337347\subsection {Describing extension modules }
338348\label {sec:describing-extensions }
339349
340- \XXX {be sure to describe the whole \code {build\_ info} dict, including
341- \code {extra\_ compile\_ args} and \code {extra\_ link\_ args}}
342350
343351
344352\section {Writing the Setup Configuration File }
345353\label {setup-config }
346354
347- \XXX {not implemented yet!}
348-
349355Often, it's not possible to write down everything needed to build a
350356distribution \emph {a priori }. You need to get some information from the
351357user, or from the user's system, in order to proceed. For example, you
@@ -491,8 +497,9 @@ \subsection{Manifest-related options}
491497\begin {itemize }
492498\item if the manifest file, \file {MANIFEST} doesn't exist, read
493499 \file {MANIFEST.in} and create the manifest
494- \item if \file {MANIFEST.in} is more recent than \file {MANIFEST},
495- recreate \file {MANIFEST} by reading \file {MANIFEST.in}
500+ \item if either \file {MANIFEST.in} or the setup script (\file {setup.py})
501+ are more recent than \file {MANIFEST}, recreate \file {MANIFEST} by
502+ reading \file {MANIFEST.in}
496503\item use the list of files now in \file {MANIFEST} (either just
497504 generated or read in) to create the source distribution archive(s)
498505\end {itemize }
@@ -505,8 +512,6 @@ \subsection{Manifest-related options}
505512\begin {verbatim }
506513python setup.py sdist --force-manifest
507514\end {verbatim }
508- \XXX {this is stupid, but is there a better way to do it without
509- reprocessing MANIFEST.in every single bloody time?}
510515
511516Or, you might just want to (re)generate the manifest, but not create a
512517source distribution:
@@ -562,54 +567,57 @@ \section{Creating Built Distributions}
562567then the Distutils builds my module distribution (the Distutils itself
563568in this case), does a `` fake'' installation (also in the \file {build}
564569directory), and creates the default type of built distribution for my
565- platform. In Distutils 0.8, only two types of built distribution are
566- supported: \code {gztar} (default on non-Linux Unix) and \code {zip}
567- (default on Windows). Thus, the above command on a Unix system creates
568- \file {Distutils-0.8.built-posix.tar.gz}; unpacking this tarball from
569- Python's \filevar {prefix} directory installs the Distutils just as
570- though you had downloaded the source distribution and run \code {python
571- setup.py install}. Obviously, for pure Python distributions, this
572- isn't a huge win---but for non-pure distributions, which include
573- extensions that would need to be compiled, it can mean the difference
574- between someone being able to use your extensions or not.
570+ platform. Currently, the default format for built distributions is a
571+ `` dumb'' archive---tarball on Unix, ZIP file on Windows. (These are
572+ called `` dumb'' built distributions, because they must be unpacked in a
573+ specific location to work.)
574+
575+ Thus, the above command on a Unix system creates
576+ \file {Distutils-0.9.1.\filevar {plat}.tar.gz}; unpacking this tarball
577+ from the root of the filesystemq installs the Distutils just as though
578+ you had downloaded the source distribution and run \code {python setup.py
579+ install}. (Assuming that the target system has their Python
580+ installation laid out the same as you do---another reason these are
581+ called `` dumb'' distributions.) Obviously, for pure Python
582+ distributions, this isn't a huge win---but for non-pure distributions,
583+ which include extensions that would need to be compiled, it can mean the
584+ difference between someone being able to use your extensions or not.
575585
576586\XXX {filenames are inaccurate here!}
577587
578588The \command {bdist} command has a \longprogramopt {format} option,
579- similar to the \command {sdist} command, that you can use to select which
580- formats to generate: for example,
589+ similar to the \command {sdist} command, which you can use to select the
590+ types of built distribution to generate: for example,
581591\begin {verbatim }
582592python setup.py bdist --format=zip
583593\end {verbatim }
584594would, when run on a Unix system, create
585- \file {Distutils-0.8.built-posix.tar.gz}---again, this archive would be
586- unpacked from Python's \filevar {prefix} directory to install the
587- Distutils.
595+ \file {Distutils-0.8.\filevar {plat}.zip}---again, this archive would be
596+ unpacked from the root directory to install the Distutils.
588597
589598The available formats for built distributions are:
590599\begin {tableiii }{l|l|c}{code}%
591600 {Format}{Description}{Notes}
592- \lineiii {zip}{zip file (\file {.zip})}{(1) }
593- \lineiii {gztar}{gzipped tar file (\file {.tar.gz})}{(2 )}
601+ \lineiii {zip}{zip file (\file {.zip})}{}
602+ \lineiii {gztar}{gzipped tar file (\file {.tar.gz})}{(1 )}
594603 \lineiii {ztar}{compressed tar file (\file {.tar.Z})}{}
595604 \lineiii {tar}{tar file (\file {.tar})}{}
596- \lineiii {rpm}{RPM}{(3)}
597- \lineiii {srpm}{source RPM}{}
598- \lineiii {wise}{Wise installer for Windows}{}
605+ \lineiii {rpm}{RPM}{}
606+ \lineiii {srpm}{source RPM}{\XXX {to do!}}
607+ \lineiii {wininst}{self-extracting ZIP file for Windows}{(2)}
608+ % \lineiii{wise}{Wise installer for Windows}{(3)}
599609\end {tableiii }
600610
601611\noindent Notes:
602612\begin {description }
603- \item [(1)] default on Windows
604- \item [(2)] default on Unix
605- \item [(3)] not implemented yet; will be default on RPM-based Linux
606- systems
607- \item [(5)] not implemented yet; will be default on Windows
613+ \item [(1)] default on Unix
614+ \item [(2)] default on Windows \XXX {to-do!}
615+ % \item[(3)] not implemented yet
608616\end {description }
609617
610618You don't have to use the \command {bdist} command with the
611619\longprogramopt {formats} option; you can also use the command that
612- directly implements the format you're interested in. Many of these
620+ directly implements the format you're interested in. Some of these
613621\command {bdist} `` sub-commands'' actually generate several similar
614622formats; for instance, the \command {bdist\_ dumb} command generates all
615623the `` dumb'' archive formats (\code {tar}, \code {ztar}, \code {gztar}, and
@@ -620,7 +628,8 @@ \section{Creating Built Distributions}
620628 {Command}{Formats}
621629 \lineii {bdist\_ dumb}{tar, ztar, gztar, zip}
622630 \lineii {bdist\_ rpm}{rpm, srpm}
623- \lineii {bdist\_ wise}{wise}
631+ \lineii {bdist\_ wininst}{wininst}
632+ % \lineii{bdist\_wise}{wise}
624633\end {tableii }
625634
626635\section {Examples }
0 commit comments