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

Skip to content

Commit e77535c

Browse files
committed
Branch merge
2 parents 9f0df8b + a69ade8 commit e77535c

15 files changed

Lines changed: 260 additions & 87 deletions

File tree

Doc/glossary.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ Glossary
2727
:ref:`2to3-reference`.
2828

2929
abstract base class
30-
:ref:`abstract-base-classes` complement :term:`duck-typing` by
30+
Abstract base classes complement :term:`duck-typing` by
3131
providing a way to define interfaces when other techniques like
32-
:func:`hasattr` would be clumsy. Python comes with many built-in ABCs for
33-
data structures (in the :mod:`collections` module), numbers (in the
34-
:mod:`numbers` module), and streams (in the :mod:`io` module). You can
35-
create your own ABC with the :mod:`abc` module.
32+
:func:`hasattr` would be clumsy or subtly wrong (for example with
33+
:ref:`magic methods <special-lookup>`). Python comes with many built-in ABCs for
34+
data structures (in the :mod:`collections.abc` module), numbers (in the
35+
:mod:`numbers` module), streams (in the :mod:`io` module), import finders
36+
and loaders (in the :mod:`importlib.abc` module). You can create your own
37+
ABCs with the :mod:`abc` module.
3638

3739
argument
3840
A value passed to a function or method, assigned to a named local
@@ -430,8 +432,8 @@ Glossary
430432
mapping
431433
A container object that supports arbitrary key lookups and implements the
432434
methods specified in the :class:`Mapping` or :class:`MutableMapping`
433-
:ref:`abstract base classes <abstract-base-classes>`. Examples include
434-
:class:`dict`, :class:`collections.defaultdict`,
435+
:ref:`abstract base classes <collections-abstract-base-classes>`. Examples
436+
include :class:`dict`, :class:`collections.defaultdict`,
435437
:class:`collections.OrderedDict` and :class:`collections.Counter`.
436438

437439
metaclass

Doc/library/abc.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. _abstract-base-classes:
2-
31
:mod:`abc` --- Abstract Base Classes
42
====================================
53

@@ -20,7 +18,7 @@ regarding a type hierarchy for numbers based on ABCs.)
2018

2119
The :mod:`collections` module has some concrete classes that derive from
2220
ABCs; these can, of course, be further derived. In addition the
23-
:mod:`collections` module has some ABCs that can be used to test whether
21+
:mod:`collections.abc` submodule has some ABCs that can be used to test whether
2422
a class or instance provides a particular interface, for example, is it
2523
hashable or a mapping.
2624

Doc/library/collections.abc.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ABC Inherits from Abstract Methods Mixin
4444
:class:`Iterable`, ``index``, and ``count``
4545
:class:`Container`
4646

47-
:class:`MutableSequence` :class:`Sequence` ``__setitem__`` Inherited :class:`Sequence` methods and
47+
:class:`MutableSequence` :class:`Sequence` ``__setitem__``, Inherited :class:`Sequence` methods and
4848
``__delitem__``, ``append``, ``reverse``, ``extend``, ``pop``,
4949
``insert`` ``remove``, ``clear``, and ``__iadd__``
5050

@@ -175,7 +175,7 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:
175175

176176
.. seealso::
177177

178-
* `OrderedSet recipe <http://code.activestate.com/recipes/576694/>`_ that uses
179-
:class:`MutableSet`.
178+
* `OrderedSet recipe <http://code.activestate.com/recipes/576694/>`_ for an
179+
example built on :class:`MutableSet`.
180180

181-
* For more about ABCs, see the :mod:`abc` module and :pep:`3119`.
181+
* For more about ABCs, see the :mod:`abc` module and :pep:`3119`.

Doc/library/numbers.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
:synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).
66

77

8-
The :mod:`numbers` module (:pep:`3141`) defines a hierarchy of numeric abstract
9-
base classes which progressively define more operations. None of the types
10-
defined in this module can be instantiated.
8+
The :mod:`numbers` module (:pep:`3141`) defines a hierarchy of numeric
9+
:term:`abstract base classes <abstract base class>` which progressively define
10+
more operations. None of the types defined in this module can be instantiated.
1111

1212

1313
.. class:: Number

Doc/packaging/commandhooks.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. TODO integrate this in commandref and configfile
2+
13
=============
24
Command hooks
35
=============
@@ -9,6 +11,9 @@ The pre-hooks are run after the command is finalized (its options are
911
processed), but before it is run. The post-hooks are run after the command
1012
itself. Both types of hooks receive an instance of the command object.
1113

14+
See also global setup hooks in :ref:`setupcfg-spec`.
15+
16+
1217
Sample usage of hooks
1318
=====================
1419

Doc/packaging/setupcfg.rst

Lines changed: 186 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,124 @@
11
.. highlightlang:: cfg
22

3+
.. _setupcfg-spec:
4+
35
*******************************************
46
Specification of the :file:`setup.cfg` file
57
*******************************************
68

7-
.. :version: 1.0
9+
:version: 0.9
810

911
This document describes the :file:`setup.cfg`, an ini-style configuration file
10-
(compatible with :class:`configparser.RawConfigParser`) configuration file used
11-
by Packaging to replace the :file:`setup.py` file.
12+
used by Packaging to replace the :file:`setup.py` file used by Distutils.
13+
This specification is language-agnostic, and will therefore repeat some
14+
information that's already documented for Python in the
15+
:class:`configparser.RawConfigParser` documentation.
16+
17+
.. contents::
18+
:depth: 3
19+
:local:
20+
21+
22+
Syntax
23+
======
24+
25+
The ini-style format used in the configuration file is a simple collection of
26+
sections that group sets of key-value fields separated by ``=`` or ``:`` and
27+
optional whitespace. Lines starting with ``#`` or ``;`` are comments and will
28+
be ignored. Empty lines are also ignored. Example::
29+
30+
[section1]
31+
# comment
32+
name = value
33+
name2 = "other value"
34+
35+
[section2]
36+
foo = bar
37+
38+
39+
Parsing values
40+
---------------
41+
42+
Here are a set of rules to parse values:
43+
44+
- If a value is quoted with ``"`` chars, it's a string. If a quote character is
45+
present in the quoted value, it can be escaped as ``\"`` or left as-is.
46+
47+
- If the value is ``true``, ``t``, ``yes``, ``y`` (case-insensitive) or ``1``,
48+
it's converted to the language equivalent of a ``True`` value; if it's
49+
``false``, ``f``, ``no``, ``n`` (case-insensitive) or ``0``, it's converted to
50+
the equivalent of ``False``.
51+
52+
- A value can contain multiple lines. When read, lines are converted into a
53+
sequence of values. Each line after the first must start with a least one
54+
space or tab character; this leading indentation will be stripped.
55+
56+
- All other values are considered strings.
57+
58+
Examples::
59+
60+
[section]
61+
foo = one
62+
two
63+
three
64+
65+
bar = false
66+
baz = 1.3
67+
boo = "ok"
68+
beee = "wqdqw pojpj w\"ddq"
69+
70+
71+
Extending files
72+
---------------
73+
74+
A configuration file can be extended (i.e. included) by other files. For this,
75+
a ``DEFAULT`` section must contain an ``extends`` key which value points to one
76+
or more files which will be merged into the current files by adding new sections
77+
and fields. If a file loaded by ``extends`` contains sections or keys that
78+
already exist in the original file, they will not override the previous values.
79+
80+
Contents of :file:`one.cfg`::
81+
82+
[section1]
83+
name = value
84+
85+
[section2]
86+
foo = foo from one.cfg
87+
88+
Contents of :file:`two.cfg`::
89+
90+
[DEFAULT]
91+
extends = one.cfg
92+
93+
[section2]
94+
foo = foo from two.cfg
95+
baz = baz from two.cfg
96+
97+
The result of parsing :file:`two.cfg` is equivalent to this file::
98+
99+
[section1]
100+
name = value
101+
102+
[section2]
103+
foo = foo from one.cfg
104+
baz = baz from two.cfg
105+
106+
Example use of multi-line notation to include more than one file::
107+
108+
[DEFAULT]
109+
extends = one.cfg
110+
two.cfg
111+
112+
When several files are provided, they are processed sequentially, following the
113+
precedence rules explained above. This means that the list of files should go
114+
from most specialized to most common.
115+
116+
**Tools will need to provide a way to produce a merged version of the
117+
file**. This will be useful to let users publish a single file.
118+
119+
120+
Description of sections and fields
121+
==================================
12122

13123
Each section contains a description of its options.
14124

@@ -108,10 +218,6 @@ description
108218
in Distutils1.) A file can be provided in the *description-file* field.
109219
*optional*
110220

111-
description-file
112-
path to a text file that will be used for the
113-
**description** field. *optional*
114-
115221
keywords
116222
A list of additional keywords to be used to assist searching
117223
for the distribution in a larger catalog. Comma or space-separated.
@@ -172,6 +278,13 @@ project-url
172278
A label, followed by a browsable URL for the project.
173279
"label, url". The label is limited to 32 signs. *optional*, *multi*
174280

281+
One extra field not present in PEP 345 is supported:
282+
283+
description-file
284+
Path to a text file that will be used to fill the ``description`` field.
285+
``description-file`` and ``description`` are mutually exclusive. *optional*
286+
287+
175288

176289
Example::
177290

@@ -278,7 +391,7 @@ The final paths where files will be placed are composed by : **source** +
278391
**destination**. In the previous example, **doc/doc.man** will be placed in
279392
**destination_doc/doc/doc.man** and **scripts/foo.sh** will be placed in
280393
**destination_scripts/scripts/foo.sh**. (If you want more control on the final
281-
path, take a look at base_prefix_).
394+
path, take a look at :ref:`setupcfg-resources-base-prefix`).
282395

283396
The **destination** part of resources declaration are paths with categories.
284397
Indeed, it's generally a bad idea to give absolute path as it will be cross
@@ -402,13 +515,13 @@ Your **files** section will be::
402515
More control on destination part
403516
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
404517

405-
.. _base_prefix:
518+
.. _setupcfg-resources-base-prefix:
406519

407520
Defining a base prefix
408521
""""""""""""""""""""""
409522

410523
When you define your resources, you can have more control of how the final path
411-
is compute.
524+
is computed.
412525

413526
By default, the final path is::
414527

@@ -435,7 +548,7 @@ The **prefix** is "docs/" and the **suffix** is "doc.html".
435548

436549
.. note::
437550

438-
Glob syntax is working the same way with standard source and splitted source.
551+
Glob syntax is working the same way with standard source and split source.
439552
So these rules::
440553

441554
docs/*
@@ -444,7 +557,7 @@ The **prefix** is "docs/" and the **suffix** is "doc.html".
444557

445558
Will match all the files in the docs directory.
446559

447-
When you use splitted source, the final path is compute in this way::
560+
When you use split source, the final path is computed this way::
448561

449562
destination + prefix
450563

@@ -646,3 +759,64 @@ section named after the command. Example::
646759

647760
Option values given in the configuration file can be overriden on the command
648761
line. See :ref:`packaging-setup-config` for more information.
762+
763+
764+
Extensibility
765+
=============
766+
767+
Every section can have fields that are not part of this specification. They are
768+
called **extensions**.
769+
770+
An extension field starts with ``X-``. Example::
771+
772+
[metadata]
773+
name = Distribute
774+
X-Debian-Name = python-distribute
775+
776+
777+
Changes in the specification
778+
============================
779+
780+
The versioning scheme for this specification is **MAJOR.MINOR**. Changes in the
781+
specification will cause the version number to be updated.
782+
783+
Changes to the minor number reflect backwards-compatible changes:
784+
785+
- New fields and sections (optional or mandatory) can be added.
786+
- Optional fields can be removed.
787+
788+
The major number will be incremented for backwards-incompatible changes:
789+
790+
- Mandatory fields or sections are removed.
791+
- Fields change their meaning.
792+
793+
As a consequence, a tool written to consume 1.5 has these properties:
794+
795+
- Can read 1.1, 1.2 and all versions < 1.5, since the tool knows what
796+
optional fields weren't there.
797+
798+
.. XXX clarify
799+
800+
- Can also read 1.6 and other 1.x versions: The tool will just ignore fields it
801+
doesn't know about, even if they are mandatory in the new version. If
802+
optional fields were removed, the tool will just consider them absent.
803+
804+
- Cannot read 2.x and should refuse to interpret such files.
805+
806+
A tool written to produce 1.x should have these properties:
807+
808+
- Writes all mandatory fields.
809+
- May write optional fields.
810+
811+
812+
Acknowledgments
813+
===============
814+
815+
This specification includes work and feedback from these people:
816+
817+
- Tarek Ziadé
818+
- Julien Jehannet
819+
- Boris Feld
820+
- Éric Araujo
821+
822+
(If your name is missing, please :ref:`let us know <reporting-bugs>`.)

Lib/distutils/tests/Setup.sample

100755100644
File mode changed.

Lib/distutils/tests/test_extension.py

100755100644
File mode changed.

Lib/packaging/compiler/cygwinccompiler.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
import os
5050
import sys
51-
import copy
5251

5352
from packaging import logger
5453
from packaging.compiler.unixccompiler import UnixCCompiler
@@ -172,9 +171,9 @@ def link(self, target_desc, objects, output_filename, output_dir=None,
172171
extra_postargs=None, build_temp=None, target_lang=None):
173172
"""Link the objects."""
174173
# use separate copies, so we can modify the lists
175-
extra_preargs = copy.copy(extra_preargs or [])
176-
libraries = copy.copy(libraries or [])
177-
objects = copy.copy(objects or [])
174+
extra_preargs = list(extra_preargs or [])
175+
libraries = list(libraries or [])
176+
objects = list(objects or [])
178177

179178
# Additional libraries
180179
libraries.extend(self.dll_libraries)

0 commit comments

Comments
 (0)