Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
d7abe2a0
Kaydet (Commit)
d7abe2a0
authored
May 29, 2002
tarafından
Andrew M. Kuchling
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Various minor rewrites
üst
72b58e0c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
42 deletions
+52
-42
dist.tex
Doc/dist/dist.tex
+52
-42
No files found.
Doc/dist/dist.tex
Dosyayı görüntüle @
d7abe2a0
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
\begin{abstract}
\begin{abstract}
\noindent
\noindent
This document describes the Python Distribution Utilities
This document describes the Python Distribution Utilities
(``Distutils'') from the module developer's point
-of-
view, describing
(``Distutils'') from the module developer's point
of
view, describing
how to use the Distutils to make Python modules and extensions easily
how to use the Distutils to make Python modules and extensions easily
available to a wider audience with very little overhead for
available to a wider audience with very little overhead for
build/release/install mechanics.
build/release/install mechanics.
...
@@ -71,21 +71,21 @@ Python module distributions in the most natural way for their platform,
...
@@ -71,21 +71,21 @@ Python module distributions in the most natural way for their platform,
without having to run a single setup script or compile a line of code.
without having to run a single setup script or compile a line of code.
\subsection
{
A
simple e
xample
}
\subsection
{
A
Simple E
xample
}
\label
{
simple-example
}
\label
{
simple-example
}
The setup script is usually quite simple, although since it's written
in
The setup script is usually quite simple, although since it's written
Python, there are no arbitrary limits to what you can do with
in Python, there are no arbitrary limits to what you can do with it,
it,
though you should be careful about putting arbitrarily expensive
though you should be careful about putting arbitrarily expensive
operations in your setup script. Unlike, say, Autoconf-style configure
operations in your setup script. Unlike, say, Autoconf-style configure
scripts, the setup script may be run multiple times in the course of
scripts, the setup script may be run multiple times in the course of
building and installing your module distribution. If you need to
building and installing your module distribution. If you need to
insert potentially expensive processing steps into the Distutils
insert potentially expensive processing steps into the Distutils
chain, see section~
\ref
{
extending
}
on extending the Distutils.
chain, see section~
\ref
{
extending
}
on extending the Distutils.
If all you want to do is distribute a module called
\module
{
foo
}
,
If all you want to do is distribute a module called
\module
{
foo
}
,
contained in a file
\file
{
foo.py
}
, then your setup script can be as
contained in a file
\file
{
foo.py
}
, then your setup script can be as
litt
le as this:
simp
le as this:
\begin{verbatim}
\begin{verbatim}
from distutils.core import setup
from distutils.core import setup
...
@@ -99,11 +99,11 @@ Some observations:
...
@@ -99,11 +99,11 @@ Some observations:
\item
most information that you supply to the Distutils is supplied as
\item
most information that you supply to the Distutils is supplied as
keyword arguments to the
\function
{
setup()
}
function
keyword arguments to the
\function
{
setup()
}
function
\item
those keyword arguments fall into two categories: package
\item
those keyword arguments fall into two categories: package
meta
-
data (name, version number) and information about what's in the
metadata (name, version number) and information about what's in the
package (a list of pure Python modules, in this case)
package (a list of pure Python modules, in this case)
\item
modules are specified by module name, not filename (the same will
\item
modules are specified by module name, not filename (the same will
hold true for packages and extensions)
hold true for packages and extensions)
\item
it's recommended that you supply a little more meta
-
data, in
\item
it's recommended that you supply a little more metadata, in
particular your name, email address and a URL for the project
particular your name, email address and a URL for the project
(see section~
\ref
{
setup-script
}
for an example)
(see section~
\ref
{
setup-script
}
for an example)
\end{itemize}
\end{itemize}
...
@@ -116,7 +116,7 @@ python setup.py sdist
...
@@ -116,7 +116,7 @@ python setup.py sdist
\end{verbatim}
\end{verbatim}
which will create an archive file (e.g., tarball on
\UNIX
, ZIP file on
which will create an archive file (e.g., tarball on
\UNIX
, ZIP file on
Windows) containing your setup script
,
\file
{
setup.py
}
, and your module,
Windows) containing your setup script
\file
{
setup.py
}
, and your module
\file
{
foo.py
}
. The archive file will be named
\file
{
foo-1.0.tar.gz
}
(or
\file
{
foo.py
}
. The archive file will be named
\file
{
foo-1.0.tar.gz
}
(or
\file
{
.zip
}
), and will unpack into a directory
\file
{
foo-1.0
}
.
\file
{
.zip
}
), and will unpack into a directory
\file
{
foo-1.0
}
.
...
@@ -132,7 +132,7 @@ which will ultimately copy \file{foo.py} to the appropriate directory
...
@@ -132,7 +132,7 @@ which will ultimately copy \file{foo.py} to the appropriate directory
for third-party modules in their Python installation.
for third-party modules in their Python installation.
This simple example demonstrates some fundamental concepts of the
This simple example demonstrates some fundamental concepts of the
Distutils
: f
irst, both developers and installers have the same basic
Distutils
. F
irst, both developers and installers have the same basic
user interface, i.e. the setup script. The difference is which
user interface, i.e. the setup script. The difference is which
Distutils
\emph
{
commands
}
they use: the
\command
{
sdist
}
command is
Distutils
\emph
{
commands
}
they use: the
\command
{
sdist
}
command is
almost exclusively for module developers, while
\command
{
install
}
is
almost exclusively for module developers, while
\command
{
install
}
is
...
@@ -155,16 +155,17 @@ current directory.
...
@@ -155,16 +155,17 @@ current directory.
Other useful built distribution formats are RPM, implemented by the
Other useful built distribution formats are RPM, implemented by the
\command
{
bdist
\_
rpm
}
command, Solaris
\program
{
pkgtool
}
\command
{
bdist
\_
rpm
}
command, Solaris
\program
{
pkgtool
}
(
\command
{
bdist
\_
pkgtool
}
, and HP-UX
\program
{
swinstall
}
(
\command
{
bdist
_
sdux
}
).
(
\command
{
bdist
\_
pkgtool
}
), and HP-UX
\program
{
swinstall
}
For example, the following command will create an RPM file called
(
\command
{
bdist
_
sdux
}
). For example, the following command will
\file
{
foo-1.0.noarch.rpm
}
:
create an RPM file called
\file
{
foo-1.0.noarch.rpm
}
:
\begin{verbatim}
\begin{verbatim}
python setup.py bdist
_
rpm
python setup.py bdist
_
rpm
\end{verbatim}
\end{verbatim}
(This uses the
\command
{
rpm
}
command, so has to be run on an RPM-based
(The
\command
{
bdist
\_
rpm
}
command uses the
\command
{
rpm
}
executable,
system such as Red Hat Linux, SuSE Linux, or Mandrake Linux.)
therefore this has to be run on an RPM-based system such as Red Hat
Linux, SuSE Linux, or Mandrake Linux.)
You can find out what distribution formats are available at any time by
You can find out what distribution formats are available at any time by
running
running
...
@@ -209,7 +210,7 @@ following glossary of common Python terms:
...
@@ -209,7 +210,7 @@ following glossary of common Python terms:
third-party modules that don't belong to a larger module collection.
third-party modules that don't belong to a larger module collection.
Unlike regular packages, modules in the root package can be found in
Unlike regular packages, modules in the root package can be found in
many directories: in fact, every directory listed in
\code
{
sys.path
}
many directories: in fact, every directory listed in
\code
{
sys.path
}
c
an contribute
modules to the root package.
c
ontributes
modules to the root package.
\end{description}
\end{description}
...
@@ -277,7 +278,7 @@ setup(name="Distutils",
...
@@ -277,7 +278,7 @@ setup(name="Distutils",
There are only two differences between this and the trivial one-file
There are only two differences between this and the trivial one-file
distribution presented in section~
\ref
{
simple-example
}
: more
distribution presented in section~
\ref
{
simple-example
}
: more
meta
-
data, and the specification of pure Python modules by package,
metadata, and the specification of pure Python modules by package,
rather than by module. This is important since the Distutils consist of
rather than by module. This is important since the Distutils consist of
a couple of dozen modules split into (so far) two packages; an explicit
a couple of dozen modules split into (so far) two packages; an explicit
list of every module would be tedious to generate and difficult to
list of every module would be tedious to generate and difficult to
...
@@ -294,16 +295,18 @@ this document are slash-separated. (MacOS programmers should keep in
...
@@ -294,16 +295,18 @@ this document are slash-separated. (MacOS programmers should keep in
mind that the
\emph
{
absence
}
of a leading slash indicates a relative
mind that the
\emph
{
absence
}
of a leading slash indicates a relative
path, the opposite of the MacOS convention with colons.)
path, the opposite of the MacOS convention with colons.)
This, of course, only applies to pathnames given to Distutils functions.
This, of course, only applies to pathnames given to Distutils
If you, for example, use standard python functions such as
\function
{
glob.glob
}
functions. If you, for example, use standard python functions such as
or
\function
{
os.listdir
}
to specify files, you should be careful to write portable
\function
{
glob.glob
}
or
\function
{
os.listdir
}
to specify files, you
code instead of hardcoding path separators:
should be careful to write portable code instead of hardcoding path
separators:
\begin{verbatim}
\begin{verbatim}
glob.glob(os.path.join('mydir', 'subdir', '*.html'))
glob.glob(os.path.join('mydir', 'subdir', '*.html'))
os.listdir(os.path.join('mydir', 'subdir'))
os.listdir(os.path.join('mydir', 'subdir'))
\end{verbatim}
\end{verbatim}
\subsection
{
Listing whole packages
}
\subsection
{
Listing whole packages
}
\label
{
listing-packages
}
\label
{
listing-packages
}
...
@@ -317,15 +320,15 @@ obvious one, i.e. package \module{distutils} is found in the directory
...
@@ -317,15 +320,15 @@ obvious one, i.e. package \module{distutils} is found in the directory
\code
{
packages = ['foo']
}
in your setup script, you are promising that
\code
{
packages = ['foo']
}
in your setup script, you are promising that
the Distutils will find a file
\file
{
foo/
\_\_
init
\_\_
.py
}
(which might
the Distutils will find a file
\file
{
foo/
\_\_
init
\_\_
.py
}
(which might
be spelled differently on your system, but you get the idea) relative to
be spelled differently on your system, but you get the idea) relative to
the directory where your setup script lives.
(
If you break this
the directory where your setup script lives. If you break this
promise, the Distutils will issue a warning but process the broken
promise, the Distutils will issue a warning but
still
process the broken
package anyways.
)
package anyways.
If you use a different convention to lay out your source directory,
If you use a different convention to lay out your source directory,
that's no problem: you just have to supply the
\option
{
package
\_
dir
}
that's no problem: you just have to supply the
\option
{
package
\_
dir
}
option to tell the Distutils about your convention. For example, say
option to tell the Distutils about your convention. For example, say
you keep all Python source under
\file
{
lib
}
, so that modules in the
you keep all Python source under
\file
{
lib
}
, so that modules in the
``root package'' (i.e., not in any package at all) are
right
in
``root package'' (i.e., not in any package at all) are in
\file
{
lib
}
, modules in the
\module
{
foo
}
package are in
\file
{
lib/foo
}
,
\file
{
lib
}
, modules in the
\module
{
foo
}
package are in
\file
{
lib/foo
}
,
and so forth. Then you would put
and so forth. Then you would put
...
@@ -383,6 +386,7 @@ the \option{package\_dir} option.
...
@@ -383,6 +386,7 @@ the \option{package\_dir} option.
\subsection
{
Describing extension modules
}
\subsection
{
Describing extension modules
}
\label
{
describing-extensions
}
\label
{
describing-extensions
}
% XXX read over this section
Just as writing Python extension modules is a bit more complicated than
Just as writing Python extension modules is a bit more complicated than
writing pure Python modules, describing them to the Distutils is a bit
writing pure Python modules, describing them to the Distutils is a bit
more complicated. Unlike pure modules, it's not enough just to list
more complicated. Unlike pure modules, it's not enough just to list
...
@@ -617,11 +621,11 @@ is not needed when building compiled extensions: Distutils
...
@@ -617,11 +621,11 @@ is not needed when building compiled extensions: Distutils
will automatically add
\code
{
initmodule
}
will automatically add
\code
{
initmodule
}
to the list of exported symbols.
to the list of exported symbols.
\subsection
{
Listing s
cripts
}
\subsection
{
Installing S
cripts
}
So far we have been dealing with pure and non-pure Python modules,
So far we have been dealing with pure and non-pure Python modules,
which are usually not run by themselves but imported by scripts.
which are usually not run by themselves but imported by scripts.
Scripts are files containing Python source code, in
d
ended to be
Scripts are files containing Python source code, in
t
ended to be
started from the command line. Scripts don't require Distutils to do
started from the command line. Scripts don't require Distutils to do
anything very complicated. The only clever feature is that if the
anything very complicated. The only clever feature is that if the
first line of the script starts with
\code
{
\#
!
}
and contains the word
first line of the script starts with
\code
{
\#
!
}
and contains the word
...
@@ -629,14 +633,21 @@ first line of the script starts with \code{\#!} and contains the word
...
@@ -629,14 +633,21 @@ first line of the script starts with \code{\#!} and contains the word
current interpreter location.
current interpreter location.
The
\option
{
scripts
}
option simply is a list of files to be handled
The
\option
{
scripts
}
option simply is a list of files to be handled
in this way.
in this way.
From the PyXML setup script:
\begin{verbatim}
setup (...
scripts = ['scripts/xmlproc
_
parse', 'scripts/xmlproc
_
val']
)
\end{verbatim}
\subsection
{
Listing additional files
}
\subsection
{
Installing Additional Files
}
The
\option
{
data
\_
files
}
option can be used to specify additional
The
\option
{
data
\_
files
}
option can be used to specify additional
files needed by the module distribution: configuration files,
files needed by the module distribution: configuration files, message
data files, anything which does not fit in the previous categories.
catalogs, data files, anything which doesn't fit in the previous
categories.
\option
{
data
\_
files
}
specifies a sequence of (
\var
{
directory
}
,
\option
{
data
\_
files
}
specifies a sequence of (
\var
{
directory
}
,
\var
{
files
}
) pairs in the following way:
\var
{
files
}
) pairs in the following way:
...
@@ -644,7 +655,9 @@ data files, anything which does not fit in the previous categories.
...
@@ -644,7 +655,9 @@ data files, anything which does not fit in the previous categories.
\begin{verbatim}
\begin{verbatim}
setup(...
setup(...
data
_
files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
data
_
files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
('config', ['cfg/data.cfg'])])
('config', ['cfg/data.cfg']),
('/etc/init.d', ['init-script'])]
)
\end{verbatim}
\end{verbatim}
Note that you can specify the directory names where the data files
Note that you can specify the directory names where the data files
...
@@ -739,9 +752,6 @@ Options for 'build_ext' command:
...
@@ -739,9 +752,6 @@ Options for 'build_ext' command:
[...]
[...]
\end{verbatim}
\end{verbatim}
Or consult section
\ref
{
reference
}
of this document (the command
reference).
Note that an option spelled
\longprogramopt
{
foo-bar
}
on the command-line
Note that an option spelled
\longprogramopt
{
foo-bar
}
on the command-line
is spelled
\option
{
foo
\_
bar
}
in configuration files.
is spelled
\option
{
foo
\_
bar
}
in configuration files.
...
@@ -1258,10 +1268,10 @@ extending the Distutils.)
...
@@ -1258,10 +1268,10 @@ extending the Distutils.)
Executable installers are the natural format for binary
Executable installers are the natural format for binary
distributions on Windows. They display a nice graphical user interface,
distributions on Windows. They display a nice graphical user interface,
display some information about the module distribution to be installed taken
display some information about the module distribution to be installed taken
from the meta
-
data in the setup script, let the user select a few
from the metadata in the setup script, let the user select a few
(currently maybe too few) options, and start or cancel the installation.
(currently maybe too few) options, and start or cancel the installation.
Since the meta
-
data is taken from the setup script, creating
Since the metadata is taken from the setup script, creating
Windows installers is usually as easy as running:
Windows installers is usually as easy as running:
\begin{verbatim}
\begin{verbatim}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment