@@ -234,6 +234,17 @@ \section{Writing the Setup Script}
234234list of every module would be tedious to generate and difficult to
235235maintain.
236236
237+ Note that any pathnames (files or directories) supplied in the setup
238+ script should be written using the Unix convention, i.e.
239+ slash-separated. The Distutils will take care of converting this
240+ platform-neutral representation to whatever is appropriate on your
241+ current platform before actually using the pathname. This makes your
242+ setup script portable across operating systems, which of course is one
243+ of the major goals of the Distutils. In this spirit, all pathnames in
244+ this document are slash-separated (Mac OS users should keep in mind that
245+ the \emph {absence } of a leading slash indicates a relative directory,
246+ the opposite of the Mac OS convention with colons).
247+
237248
238249\subsection {Package directories }
239250\label {sec:package-dirs }
@@ -351,13 +362,19 @@ \section{Creating a Source Distribution}
351362python setup.py sdist --formats=gztar,zip
352363\end {verbatim }
353364to create a gzipped tarball and a zip file. The available formats are:
354- \begin {tableii }{ll}{textrm}%
355- {Format}{Description}
356- \lineii {zip}{zip file (\file {.zip})}
357- \lineii {gztar}{gzipped tar file (\file {.tar.gz})}
358- \lineii {ztar}{compressed tar file (\file {.tar.Z})}
359- \lineii {tar}{tar file (\file {.tar})}
360- \end {tableii }
365+ \begin {tableiii }{l|l|c}{code}%
366+ {Format}{Description}{Notes}
367+ \lineiii {zip}{zip file (\file {.zip})}{(1)}
368+ \lineiii {gztar}{gzipped tar file (\file {.tar.gz})}{(2)}
369+ \lineiii {ztar}{compressed tar file (\file {.tar.Z})}{}
370+ \lineiii {tar}{tar file (\file {.tar})}{}
371+ \end {tableiii }
372+
373+ \noindent Notes:
374+ \begin {description }
375+ \item [(1)] default on Windows
376+ \item [(2)] default on Unix
377+ \end {description }
361378
362379
363380\subsection {The manifest and manifest template }
@@ -409,8 +426,9 @@ \subsection{The manifest and manifest template}
409426list of files. This list is written to the manifest for future
410427reference, and then used to build the source distribution archive(s).
411428
412- We can now see how the \command {sdist} command will build the list of
413- files to include in the Distutils source distribution:
429+ Following the Distutils' own manifest template, let's trace how the
430+ \command {sdist} command will build the list of files to include in the
431+ Distutils source distribution:
414432\begin {enumerate }
415433\item include all Python source files in the \file {distutils} and
416434 \file {distutils/command} subdirectories (because packages
@@ -432,16 +450,22 @@ \subsection{The manifest and manifest template}
432450 commands
433451\end {enumerate }
434452
453+ Just like in the setup script, file and directory names in the manifest
454+ template should always be slash-separated; the Distutils will take care
455+ of converting them to the standard representation on your platform.
456+ That way, the manifest template is portable across operating systems.
457+
435458
436459\subsection {Manifest-related options }
437460\label {sec:manifest-options }
438461
439462The normal course of operations for the \command {sdist} command is as
440463follows:
441464\begin {itemize }
442- \item if \file {MANIFEST.in} is more recent than \file {MANIFEST}, or
443- \file {MANIFEST} doesn't exist at all, recreate \file {MANIFEST} by
444- processing \file {MANIFEST.in}
465+ \item if the manifest file, \file {MANIFEST} doesn't exist, read
466+ \file {MANIFEST.in} and create the manifest
467+ \item if \file {MANIFEST.in} is more recent than \file {MANIFEST},
468+ recreate \file {MANIFEST} by reading \file {MANIFEST.in}
445469\item use the list of files now in \file {MANIFEST} (either just
446470 generated or read in) to create the source distribution archive(s)
447471\end {itemize }
@@ -473,7 +497,103 @@ \subsection{Manifest-related options}
473497\section {Creating Built Distributions }
474498\label {sec:built-dist }
475499
500+ A `` built distribution'' is what you're probably used to thinking of
501+ either as a `` binary package'' or an `` installer'' (depending on your
502+ background). It's not necessarily binary, though, because it might
503+ contain only Python source code and/or byte-code; and we don't call it a
504+ package, because that word is already spoken for in Python. (And
505+ `` installer'' is a term specific to the Windows world. \XXX {do Mac
506+ people use it?})
507+
508+ A built distribution is how you make life as easy as possible for
509+ installers of your module distribution: for users of RPM-based Linux
510+ systems, it's a binary RPM; for Windows users, it's an executable
511+ installer; for Debian-based Linux users, it's a Debian package; and so
512+ forth. Obviously, no one person will be able to create built
513+ distributions for every platform under the sun, so the Distutils is
514+ designed to enable module developers to concentrate on their
515+ specialty---writing code and creating source distributions---while an
516+ intermediary species of \emph {packager } springs up to turn source
517+ distributions into build distributions for as many platforms as there
518+ are packagers.
519+
520+ Of course, the module developer could be his own packager; or the
521+ packager could be a volunteer `` out there'' somewhere who has access to
522+ a platform which the original developer does not; or it could be
523+ software periodically grabbing new source distributions and turning them
524+ into built distributions for as many platforms as the software has
525+ access to. Regardless of the nature of the beast, a packager uses the
526+ setup script and the \command {bdist} command family to generate built
527+ distributions.
528+
529+ As a simple example, if I run the following command in the Distutils
530+ source tree:
531+ \begin {verbatim }
532+ python setup.py bdist
533+ \end {verbatim }
534+ then the Distutils builds my module distribution (the Distutils itself
535+ in this case), does a `` fake'' installation (also in the \file {build}
536+ directory), and creates the default type of built distribution for my
537+ platform. In Distutils 0.8, only two types of built distribution are
538+ supported: \code {gztar} (default on non-Linux Unix) and \code {zip}
539+ (default on Windows). Thus, the above command on a Unix system creates
540+ \file {Distutils-0.8.built-posix.tar.gz}; unpacking this tarball from
541+ Python's \filevar {prefix} directory installs the Distutils just as
542+ though you had downloaded the source distribution and run \code {python
543+ setup.py install}. Obviously, for pure Python distributions, this
544+ isn't a huge win---but for non-pure distributions, which include
545+ extensions that would need to be compiled, it can mean the difference
546+ between someone being able to use your extensions or not.
547+
548+ \XXX {filenames are inaccurate here!}
549+
550+ The \command {bdist} command has a \option {--format} option, similar to
551+ the \command {sdist} command, that you can use to select which formats to
552+ generate: for example,
553+ \begin {verbatim }
554+ python setup.py bdist --format=zip
555+ \end {verbatim }
556+ would, when run on a Unix system, create
557+ \file {Distutils-0.8.built-posix.tar.gz}---again, this archive would be
558+ unpacked from Python's \filevar {prefix} directory to install the
559+ Distutils.
560+
561+ The available formats for built distributions are:
562+ \begin {tableiii }{l|l|c}{code}%
563+ {Format}{Description}{Notes}
564+ \lineiii {zip}{zip file (\file {.zip})}{(1)}
565+ \lineiii {gztar}{gzipped tar file (\file {.tar.gz})}{(2)}
566+ \lineiii {ztar}{compressed tar file (\file {.tar.Z})}{}
567+ \lineiii {tar}{tar file (\file {.tar})}{}
568+ \lineiii {rpm}{RPM}{(3)}
569+ \lineiii {srpm}{source RPM}{}
570+ \lineiii {wise}{Wise installer for Windows}{}
571+ \end {tableiii }
572+
573+ \noindent Notes:
574+ \begin {description }
575+ \item [(1)] default on Windows
576+ \item [(2)] default on Unix
577+ \item [(3)] not implemented yet; will be default on RPM-based Linux
578+ systems
579+ \item [(5)] not implemented yet; will be default on Windows
580+ \end {description }
476581
582+ You don't have to use the \command {bdist} command with the
583+ \option {--formats} option; you can also use the command that directly
584+ implements the format you're interested in. Many of these
585+ \command {bdist} `` sub-commands'' actually generate several similar
586+ formats; for instance, the \command {bdist\_ dumb} command generates all
587+ the `` dumb'' archive formats (\code {tar}, \code {ztar}, \code {gztar}, and
588+ \code {zip}), and \command {bdist\_ rpm} generates both binary and source
589+ RPMs. The \command {bdist} sub-commands, and the formats generated by
590+ each, are:
591+ \begin {tableii }{l|l}{command}%
592+ {Command}{Formats}
593+ \lineii {bdist\_ dumb}{tar, ztar, gztar, zip}
594+ \lineii {bdist\_ rpm}{rpm, srpm}
595+ \lineii {bdist\_ wise}{wise}
596+ \end {tableii }
477597
478598\section {Examples }
479599\label {sec:examples }
0 commit comments