Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b8f665

Browse files
committed
Branch merge
2 parents 6747381 + f0ab5d6 commit 4b8f665

6 files changed

Lines changed: 100 additions & 91 deletions

File tree

Doc/distutils/apiref.rst

Lines changed: 82 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ setup script). Indirectly provides the :class:`distutils.dist.Distribution` and
2121
.. function:: setup(arguments)
2222

2323
The basic do-everything function that does most everything you could ever ask
24-
for from a Distutils method. See XXXXX
24+
for from a Distutils method.
2525

2626
The setup function takes a large number of arguments. These are laid out in the
2727
following table.
@@ -147,11 +147,11 @@ setup script). Indirectly provides the :class:`distutils.dist.Distribution` and
147147
In addition, the :mod:`distutils.core` module exposed a number of classes that
148148
live elsewhere.
149149

150-
* :class:`Extension` from :mod:`distutils.extension`
150+
* :class:`~distutils.extension.Extension` from :mod:`distutils.extension`
151151

152-
* :class:`Command` from :mod:`distutils.cmd`
152+
* :class:`~distutils.cmd.Command` from :mod:`distutils.cmd`
153153

154-
* :class:`Distribution` from :mod:`distutils.dist`
154+
* :class:`~distutils.dist.Distribution` from :mod:`distutils.dist`
155155

156156
A short description of each of these follows, but see the relevant module for
157157
the full reference.
@@ -1678,8 +1678,8 @@ lines, and joining lines with backslashes.
16781678
===================================================================
16791679

16801680
.. module:: distutils.cmd
1681-
:synopsis: This module provides the abstract base class Command. This class is subclassed
1682-
by the modules in the distutils.command subpackage.
1681+
:synopsis: This module provides the abstract base class Command. This class
1682+
is subclassed by the modules in the distutils.command subpackage.
16831683

16841684

16851685
This module supplies the abstract base class :class:`Command`.
@@ -1689,20 +1689,84 @@ This module supplies the abstract base class :class:`Command`.
16891689

16901690
Abstract base class for defining command classes, the "worker bees" of the
16911691
Distutils. A useful analogy for command classes is to think of them as
1692-
subroutines with local variables called *options*. The options are declared in
1693-
:meth:`initialize_options` and defined (given their final values) in
1694-
:meth:`finalize_options`, both of which must be defined by every command class.
1695-
The distinction between the two is necessary because option values might come
1696-
from the outside world (command line, config file, ...), and any options
1697-
dependent on other options must be computed after these outside influences have
1698-
been processed --- hence :meth:`finalize_options`. The body of the subroutine,
1699-
where it does all its work based on the values of its options, is the
1700-
:meth:`run` method, which must also be implemented by every command class.
1701-
1702-
The class constructor takes a single argument *dist*, a :class:`Distribution`
1692+
subroutines with local variables called *options*. The options are declared
1693+
in :meth:`initialize_options` and defined (given their final values) in
1694+
:meth:`finalize_options`, both of which must be defined by every command
1695+
class. The distinction between the two is necessary because option values
1696+
might come from the outside world (command line, config file, ...), and any
1697+
options dependent on other options must be computed after these outside
1698+
influences have been processed --- hence :meth:`finalize_options`. The body
1699+
of the subroutine, where it does all its work based on the values of its
1700+
options, is the :meth:`run` method, which must also be implemented by every
1701+
command class.
1702+
1703+
The class constructor takes a single argument *dist*, a :class:`Distribution`
17031704
instance.
17041705

17051706

1707+
Creating a new Distutils command
1708+
================================
1709+
1710+
This section outlines the steps to create a new Distutils command.
1711+
1712+
A new command lives in a module in the :mod:`distutils.command` package. There
1713+
is a sample template in that directory called :file:`command_template`. Copy
1714+
this file to a new module with the same name as the new command you're
1715+
implementing. This module should implement a class with the same name as the
1716+
module (and the command). So, for instance, to create the command
1717+
``peel_banana`` (so that users can run ``setup.py peel_banana``), you'd copy
1718+
:file:`command_template` to :file:`distutils/command/peel_banana.py`, then edit
1719+
it so that it's implementing the class :class:`peel_banana`, a subclass of
1720+
:class:`distutils.cmd.Command`.
1721+
1722+
Subclasses of :class:`Command` must define the following methods.
1723+
1724+
.. method:: Command.initialize_options()
1725+
1726+
Set default values for all the options that this command supports. Note that
1727+
these defaults may be overridden by other commands, by the setup script, by
1728+
config files, or by the command-line. Thus, this is not the place to code
1729+
dependencies between options; generally, :meth:`initialize_options`
1730+
implementations are just a bunch of ``self.foo = None`` assignments.
1731+
1732+
1733+
.. method:: Command.finalize_options()
1734+
1735+
Set final values for all the options that this command supports. This is
1736+
always called as late as possible, ie. after any option assignments from the
1737+
command-line or from other commands have been done. Thus, this is the place
1738+
to to code option dependencies: if *foo* depends on *bar*, then it is safe to
1739+
set *foo* from *bar* as long as *foo* still has the same value it was
1740+
assigned in :meth:`initialize_options`.
1741+
1742+
1743+
.. method:: Command.run()
1744+
1745+
A command's raison d'etre: carry out the action it exists to perform, controlled
1746+
by the options initialized in :meth:`initialize_options`, customized by other
1747+
commands, the setup script, the command-line, and config files, and finalized in
1748+
:meth:`finalize_options`. All terminal output and filesystem interaction should
1749+
be done by :meth:`run`.
1750+
1751+
1752+
.. attribute:: Command.sub_commands
1753+
1754+
*sub_commands* formalizes the notion of a "family" of commands,
1755+
e.g. ``install`` as the parent with sub-commands ``install_lib``,
1756+
``install_headers``, etc. The parent of a family of commands defines
1757+
*sub_commands* as a class attribute; it's a list of 2-tuples ``(command_name,
1758+
predicate)``, with *command_name* a string and *predicate* a function, a
1759+
string or ``None``. *predicate* is a method of the parent command that
1760+
determines whether the corresponding command is applicable in the current
1761+
situation. (E.g. ``install_headers`` is only applicable if we have any C
1762+
header files to install.) If *predicate* is ``None``, that command is always
1763+
applicable.
1764+
1765+
*sub_commands* is usually defined at the *end* of a class, because
1766+
predicates can be methods of the class, so they must already have been
1767+
defined. The canonical example is the :command:`install` command.
1768+
1769+
17061770
:mod:`distutils.command` --- Individual Distutils commands
17071771
==========================================================
17081772

@@ -1942,6 +2006,7 @@ This is described in more detail in :pep:`301`.
19422006

19432007
.. % todo
19442008
2009+
19452010
:mod:`distutils.command.check` --- Check the meta-data of a package
19462011
===================================================================
19472012

@@ -1954,63 +2019,3 @@ For example, it verifies that all required meta-data are provided as
19542019
the arguments passed to the :func:`setup` function.
19552020

19562021
.. % todo
1957-
1958-
1959-
Creating a new Distutils command
1960-
================================
1961-
1962-
This section outlines the steps to create a new Distutils command.
1963-
1964-
A new command lives in a module in the :mod:`distutils.command` package. There
1965-
is a sample template in that directory called :file:`command_template`. Copy
1966-
this file to a new module with the same name as the new command you're
1967-
implementing. This module should implement a class with the same name as the
1968-
module (and the command). So, for instance, to create the command
1969-
``peel_banana`` (so that users can run ``setup.py peel_banana``), you'd copy
1970-
:file:`command_template` to :file:`distutils/command/peel_banana.py`, then edit
1971-
it so that it's implementing the class :class:`peel_banana`, a subclass of
1972-
:class:`distutils.cmd.Command`.
1973-
1974-
Subclasses of :class:`Command` must define the following methods.
1975-
1976-
1977-
.. method:: Command.initialize_options()
1978-
1979-
Set default values for all the options that this command supports. Note that
1980-
these defaults may be overridden by other commands, by the setup script, by
1981-
config files, or by the command-line. Thus, this is not the place to code
1982-
dependencies between options; generally, :meth:`initialize_options`
1983-
implementations are just a bunch of ``self.foo = None`` assignments.
1984-
1985-
1986-
.. method:: Command.finalize_options()
1987-
1988-
Set final values for all the options that this command supports. This is
1989-
always called as late as possible, ie. after any option assignments from the
1990-
command-line or from other commands have been done. Thus, this is the place
1991-
to to code option dependencies: if *foo* depends on *bar*, then it is safe to
1992-
set *foo* from *bar* as long as *foo* still has the same value it was
1993-
assigned in :meth:`initialize_options`.
1994-
1995-
1996-
.. method:: Command.run()
1997-
1998-
A command's raison d'etre: carry out the action it exists to perform, controlled
1999-
by the options initialized in :meth:`initialize_options`, customized by other
2000-
commands, the setup script, the command-line, and config files, and finalized in
2001-
:meth:`finalize_options`. All terminal output and filesystem interaction should
2002-
be done by :meth:`run`.
2003-
2004-
*sub_commands* formalizes the notion of a "family" of commands, eg. ``install``
2005-
as the parent with sub-commands ``install_lib``, ``install_headers``, etc. The
2006-
parent of a family of commands defines *sub_commands* as a class attribute; it's
2007-
a list of 2-tuples ``(command_name, predicate)``, with *command_name* a string
2008-
and *predicate* a function, a string or None. *predicate* is a method of
2009-
the parent command that determines whether the corresponding command is
2010-
applicable in the current situation. (Eg. we ``install_headers`` is only
2011-
applicable if we have any C header files to install.) If *predicate* is None,
2012-
that command is always applicable.
2013-
2014-
*sub_commands* is usually defined at the \*end\* of a class, because predicates
2015-
can be methods of the class, so they must already have been defined. The
2016-
canonical example is the :command:`install` command.

Doc/distutils/extending.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ want to modify existing commands; many simply add a few file extensions that
1515
should be copied into packages in addition to :file:`.py` files as a
1616
convenience.
1717

18-
Most distutils command implementations are subclasses of the :class:`Command`
19-
class from :mod:`distutils.cmd`. New commands may directly inherit from
18+
Most distutils command implementations are subclasses of the
19+
:class:`distutils.cmd.Command` class. New commands may directly inherit from
2020
:class:`Command`, while replacements often derive from :class:`Command`
2121
indirectly, directly subclassing the command they are replacing. Commands are
2222
required to derive from :class:`Command`.

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ Glossary
247247
processing, remembering the location execution state (including local
248248
variables and pending try-statements). When the generator resumes, it
249249
picks-up where it left-off (in contrast to functions which start fresh on
250-
every invocation.
250+
every invocation).
251251

252252
.. index:: single: generator expression
253253

Doc/library/functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ are always available. They are listed here in alphabetical order.
580580
Two objects with non-overlapping lifetimes may have the same :func:`id`
581581
value.
582582

583-
.. impl-detail:: This is the address of the object.
583+
.. impl-detail:: This is the address of the object in memory.
584584

585585

586586
.. function:: input([prompt])

Lib/distutils/tests/test_build_py.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,15 @@ def test_package_data(self):
5757
self.assertEqual(len(cmd.get_outputs()), 3)
5858
pkgdest = os.path.join(destination, "pkg")
5959
files = os.listdir(pkgdest)
60-
self.assertTrue("__init__.py" in files)
61-
self.assertTrue("__init__.pyc" in files)
62-
self.assertTrue("README.txt" in files)
63-
64-
def test_empty_package_dir (self):
60+
self.assertIn("__init__.py", files)
61+
self.assertIn("README.txt", files)
62+
# XXX even with -O, distutils writes pyc, not pyo; bug?
63+
if sys.dont_write_bytecode:
64+
self.assertNotIn("__init__.pyc", files)
65+
else:
66+
self.assertIn("__init__.pyc", files)
67+
68+
def test_empty_package_dir(self):
6569
# See SF 1668596/1720897.
6670
cwd = os.getcwd()
6771

@@ -109,7 +113,7 @@ def test_dont_write_bytecode(self):
109113
finally:
110114
sys.dont_write_bytecode = old_dont_write_bytecode
111115

112-
self.assertTrue('byte-compiling is disabled' in self.logs[0][1])
116+
self.assertIn('byte-compiling is disabled', self.logs[0][1])
113117

114118
def test_suite():
115119
return unittest.makeSuite(BuildPyTestCase)

Misc/NEWS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ Library
299299
- Issue #7311: fix html.parser to accept non-ASCII attribute values.
300300

301301
- Issue #11605: email.parser.BytesFeedParser was incorrectly converting
302-
multipart subpararts with an 8bit CTE into unicode instead of preserving the
302+
multipart subparts with an 8-bit CTE into unicode instead of preserving the
303303
bytes.
304304

305305
- Issue #10963: Ensure that subprocess.communicate() never raises EPIPE.
@@ -496,7 +496,7 @@ Tests
496496

497497
- Issue #11577: improve test coverage of binhex.py. Patch by Arkady Koplyarov.
498498

499-
- Issue #11578: added test for the timeit module. Patch Michael Henry.
499+
- Issue #11578: added test for the timeit module. Patch by Michael Henry.
500500

501501
- Issue #11503: improve test coverage of posixpath.py. Patch by Evan Dandrea.
502502

@@ -796,10 +796,10 @@ Library
796796
comparisons that could lead to infinite recursion.
797797

798798
- Issue #10686: the email package now :rfc:`2047`\ -encodes headers with
799-
non-ASCII bytes (parsed by a Bytes Parser) when doing conversion to 7bit-clean
799+
non-ASCII bytes (parsed by a BytesParser) when doing conversion to 7bit-clean
800800
presentation, instead of replacing them with ?s.
801801

802-
- email.header.Header was incorrectly encoding folding white space when
802+
- email.header.Header was incorrectly encoding folding whitespace when
803803
rfc2047-encoding header values with embedded newlines, leaving them without
804804
folding whitespace. It now uses the continuation_ws, as it does for
805805
continuation lines that it creates itself.

0 commit comments

Comments
 (0)