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

Skip to content

Commit 1e88f3f

Browse files
author
Stefan Krah
committed
Merge.
2 parents 1649c1b + c53d624 commit 1e88f3f

13 files changed

Lines changed: 72 additions & 31 deletions

File tree

Doc/howto/advocacy.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ the organizations that use Python.
264264

265265
**What are the restrictions on Python's use?**
266266

267-
They're practically nonexistent. Consult the :file:`Misc/COPYRIGHT` file in the
268-
source distribution, or the section :ref:`history-and-license` for the full
267+
They're practically nonexistent. Consult :ref:`history-and-license` for the full
269268
language, but it boils down to three conditions:
270269

271270
* You have to leave the copyright notice on the software; if you don't include

Doc/howto/cporting.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ behave slightly differently from real Capsules. Specifically:
261261
copy as you see fit.)
262262

263263
You can find :file:`capsulethunk.h` in the Python source distribution
264-
in the :file:`Doc/includes` directory. We also include it here for
265-
your reference; here is :file:`capsulethunk.h`:
264+
as :source:`Doc/includes/capsulethunk.h`. We also include it here for
265+
your convenience:
266266

267267
.. literalinclude:: ../includes/capsulethunk.h
268268

Doc/howto/regex.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ and more.
360360

361361
You can learn about this by interactively experimenting with the :mod:`re`
362362
module. If you have :mod:`tkinter` available, you may also want to look at
363-
:file:`Tools/demo/redemo.py`, a demonstration program included with the
363+
:source:`Tools/demo/redemo.py`, a demonstration program included with the
364364
Python distribution. It allows you to enter REs and strings, and displays
365365
whether the RE matches or fails. :file:`redemo.py` can be quite useful when
366366
trying to debug a complicated RE. Phil Schwartz's `Kodos
@@ -495,7 +495,7 @@ more convenient. If a program contains a lot of regular expressions, or re-uses
495495
the same ones in several locations, then it might be worthwhile to collect all
496496
the definitions in one place, in a section of code that compiles all the REs
497497
ahead of time. To take an example from the standard library, here's an extract
498-
from the now deprecated :file:`xmllib.py`::
498+
from the now-defunct Python 2 standard :mod:`xmllib` module::
499499

500500
ref = re.compile( ... )
501501
entityref = re.compile( ... )

Doc/library/markup.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ definition of the Python bindings for the DOM and SAX interfaces.
2323
html.rst
2424
html.parser.rst
2525
html.entities.rst
26-
pyexpat.rst
26+
xml.etree.elementtree.rst
2727
xml.dom.rst
2828
xml.dom.minidom.rst
2929
xml.dom.pulldom.rst
3030
xml.sax.rst
3131
xml.sax.handler.rst
3232
xml.sax.utils.rst
3333
xml.sax.reader.rst
34-
xml.etree.elementtree.rst
34+
pyexpat.rst

Doc/library/packaging.database.rst

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ Installed Python distributions are represented by instances of
1515
Most functions also provide an extra argument ``use_egg_info`` to take legacy
1616
distributions into account.
1717

18+
For the purpose of this module, "installed" means that the distribution's
19+
:file:`.dist-info`, :file:`.egg-info` or :file:`egg` directory or file is found
20+
on :data:`sys.path`. For example, if the parent directory of a
21+
:file:`dist-info` directory is added to :envvar:`PYTHONPATH`, then it will be
22+
available in the database.
1823

1924
Classes representing installed distributions
2025
--------------------------------------------
@@ -128,7 +133,7 @@ Functions to work with the database
128133
for the first installed distribution matching *name*. Egg distributions are
129134
considered only if *use_egg_info* is true; if both a dist-info and an egg
130135
file are found, the dist-info prevails. The directories to be searched are
131-
given in *paths*, which defaults to :data:`sys.path`. Return ``None`` if no
136+
given in *paths*, which defaults to :data:`sys.path`. Returns ``None`` if no
132137
matching distribution is found.
133138

134139
.. FIXME param should be named use_egg
@@ -200,20 +205,23 @@ functions:
200205
Examples
201206
--------
202207

203-
Print all information about a distribution
204-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
208+
Printing all information about a distribution
209+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
205210

206-
Given a path to a ``.dist-info`` distribution, we shall print out all
211+
Given the name of an installed distribution, we shall print out all
207212
information that can be obtained using functions provided in this module::
208213

209214
import sys
210215
import packaging.database
211216

212-
path = input()
213-
# first create the Distribution instance
214217
try:
215-
dist = packaging.database.Distribution(path)
216-
except FileNotFoundError:
218+
name = sys.argv[1]
219+
except ValueError:
220+
sys.exit('Not enough arguments')
221+
222+
# first create the Distribution instance
223+
dist = packaging.database.Distribution(path)
224+
if dist is None:
217225
sys.exit('No such distribution')
218226

219227
print('Information about %r' % dist.name)
@@ -244,7 +252,7 @@ information from a :file:`.dist-info` directory. By typing in the console:
244252

245253
.. code-block:: sh
246254
247-
$ echo /tmp/choxie/choxie-2.0.0.9.dist-info | python3 print_info.py
255+
python print_info.py choxie
248256
249257
we get the following output:
250258

@@ -299,10 +307,23 @@ we get the following output:
299307
* It was installed as a dependency
300308
301309
302-
Find out obsoleted distributions
303-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
310+
Getting metadata about a distribution
311+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
312+
313+
Sometimes you're not interested about the packaging information contained in a
314+
full :class:`Distribution` object but just want to do something with its
315+
:attr:`~Distribution.metadata`::
316+
317+
>>> from packaging.database import get_distribution
318+
>>> info = get_distribution('chocolate').metadata
319+
>>> info['Keywords']
320+
['cooking', 'happiness']
321+
322+
323+
Finding out obsoleted distributions
324+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
304325

305-
Now, we take tackle a different problem, we are interested in finding out
326+
Now, we tackle a different problem, we are interested in finding out
306327
which distributions have been obsoleted. This can be easily done as follows::
307328

308329
import packaging.database

Lib/distutils/command/bdist_msi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def run(self):
260260
self.db.Commit()
261261

262262
if hasattr(self.distribution, 'dist_files'):
263-
tup = 'bdist_msi', self.target_version or 'any', fullname
263+
tup = 'bdist_msi', self.target_version or 'any', installer_name
264264
self.distribution.dist_files.append(tup)
265265

266266
if not self.keep_temp:

Lib/distutils/tests/test_bdist_msi.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
"""Tests for distutils.command.bdist_msi."""
2-
import unittest
2+
import os
33
import sys
4-
4+
import unittest
55
from test.support import run_unittest
6-
76
from distutils.tests import support
87

9-
@unittest.skipUnless(sys.platform=="win32", "These tests are only for win32")
8+
9+
@unittest.skipUnless(sys.platform == 'win32', 'these tests require Windows')
1010
class BDistMSITestCase(support.TempdirManager,
1111
support.LoggingSilencer,
1212
unittest.TestCase):
1313

1414
def test_minimal(self):
1515
# minimal test XXX need more tests
1616
from distutils.command.bdist_msi import bdist_msi
17-
pkg_pth, dist = self.create_dist()
17+
project_dir, dist = self.create_dist()
1818
cmd = bdist_msi(dist)
1919
cmd.ensure_finalized()
20+
cmd.run()
21+
22+
bdists = os.listdir(os.path.join(project_dir, 'dist'))
23+
self.assertEqual(bdists, ['foo-0.1.msi'])
24+
25+
# bug #13719: upload ignores bdist_msi files
26+
self.assertEqual(dist.dist_files,
27+
[('bdist_msi', 'any', 'dist/foo-0.1.msi')])
28+
2029

2130
def test_suite():
2231
return unittest.makeSuite(BDistMSITestCase)

Lib/packaging/command/bdist_msi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def run(self):
261261
self.db.Commit()
262262

263263
if hasattr(self.distribution, 'dist_files'):
264-
tup = 'bdist_msi', self.target_version or 'any', fullname
264+
tup = 'bdist_msi', self.target_version or 'any', installer_name
265265
self.distribution.dist_files.append(tup)
266266

267267
if not self.keep_temp:

Lib/packaging/database.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'get_distributions', 'get_distribution', 'get_file_users',
2020
'provides_distribution', 'obsoletes_distribution',
2121
'enable_cache', 'disable_cache', 'clear_cache',
22+
# XXX these functions' names look like get_file_users but are not related
2223
'get_file_path', 'get_file']
2324

2425

Lib/packaging/tests/test_command_bdist_msi.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
"""Tests for distutils.command.bdist_msi."""
2+
import os
23
import sys
34

45
from packaging.tests import unittest, support
56

67

8+
@unittest.skipUnless(sys.platform == 'win32', 'these tests require Windows')
79
class BDistMSITestCase(support.TempdirManager,
810
support.LoggingCatcher,
911
unittest.TestCase):
1012

11-
@unittest.skipUnless(sys.platform == "win32", "runs only on win32")
1213
def test_minimal(self):
1314
# minimal test XXX need more tests
1415
from packaging.command.bdist_msi import bdist_msi
15-
pkg_pth, dist = self.create_dist()
16+
project_dir, dist = self.create_dist()
1617
cmd = bdist_msi(dist)
1718
cmd.ensure_finalized()
19+
cmd.run()
20+
21+
bdists = os.listdir(os.path.join(project_dir, 'dist'))
22+
self.assertEqual(bdists, ['foo-0.1.msi'])
23+
24+
# bug #13719: upload ignores bdist_msi files
25+
self.assertEqual(dist.dist_files,
26+
[('bdist_msi', 'any', 'dist/foo-0.1.msi')])
1827

1928

2029
def test_suite():

0 commit comments

Comments
 (0)