Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0c84c7f9
Commit
0c84c7f9
authored
Aug 02, 2004
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start filling in documentation on extending distutils
parent
576298d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
2 deletions
+48
-2
Doc/dist/dist.tex
Doc/dist/dist.tex
+48
-2
No files found.
Doc/dist/dist.tex
View file @
0c84c7f9
...
...
@@ -1887,8 +1887,26 @@ setup(name='foobar',
%\section{Putting it all together}
%\chapter{Extending the Distutils}
%\label{extending}
\chapter
{
Extending Distutils
\label
{
extending
}}
Distutils can be extended in various ways. Most extensions take the
form of new commands or replacements for existing commands. New
commands may be written to support new types of platform-specific
packaging, for example, while replacements for existing commands may
be made to modify details of how the command operates on a package.
Most extensions of the distutils are made within
\file
{
setup.py
}
scripts that want to modify existing commands; many simply add a few
file extensions that should be copied into packages in addition to
\file
{
.py
}
files as a convenience.
Most distutils command implementations are subclasses of the
\class
{
Command
}
class from
\refmodule
{
distutils.cmd
}
. New commands
may directly inherit from
\class
{
Command
}
, while replacements often
derive from
\class
{
Command
}
indirectly, directly subclassing the
command they are replacing. Commands are not required to derive from
\class
{
Command
}
, but must implement the interface documented as part
of that class.
%\section{Extending existing commands}
...
...
@@ -1900,6 +1918,34 @@ setup(name='foobar',
%\XXX{Would an uninstall command be a good example here?}
\section
{
Integrating new commands
}
There are different ways to integrate new command implementations into
distutils. The most difficult is to lobby for the inclusion of the
new features in distutils itself, and wait for (and require) a version
of Python that provides that support. This is really hard for many
reasons.
The most common, and possibly the most reasonable for most needs, is
to include the new implementations with your
\file
{
setup.py
}
script,
and cause the
\function
{
distutils.core.setup()
}
function use them:
\begin{verbatim}
from distutils.command.build
_
py import build
_
py as
_
build
_
py
from distutils.core import setup
class build
_
py(
_
build
_
py):
"""Specialized Python source builder."""
# implement whatever needs to be different...
setup(cmdclass=
{
'build
_
py': build
_
py
}
,
...)
\end{verbatim}
This approach is most valuable if the new implementations must be used
to use a particular package, as everyone interested in the package
will need to have the new command implementation.
\chapter
{
Command Reference
}
...
...
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