mirror of https://github.com/python/cpython.git
Branch merge
This commit is contained in:
commit
98b6592266
|
@ -128,6 +128,7 @@ def run(self):
|
|||
for i in range(len(self.formats)):
|
||||
cmd_name = commands[i]
|
||||
sub_cmd = self.get_reinitialized_command(cmd_name)
|
||||
sub_cmd.format = self.formats[i]
|
||||
|
||||
# passing the owner and group names for tar archiving
|
||||
if cmd_name == 'bdist_dumb':
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
"""Create a source distribution."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import sys
|
||||
from io import StringIO
|
||||
from glob import glob
|
||||
from shutil import get_archive_formats, rmtree
|
||||
|
||||
from packaging import logger
|
||||
|
@ -203,45 +202,14 @@ def get_file_list(self):
|
|||
|
||||
def add_defaults(self):
|
||||
"""Add all the default files to self.filelist:
|
||||
- README or README.txt
|
||||
- test/test*.py
|
||||
- all pure Python modules mentioned in setup script
|
||||
- all files pointed by package_data (build_py)
|
||||
- all files defined in data_files.
|
||||
- all files defined as scripts.
|
||||
- all C sources listed as part of extensions or C libraries
|
||||
in the setup script (doesn't catch C headers!)
|
||||
Warns if (README or README.txt) or setup.py are missing; everything
|
||||
else is optional.
|
||||
Everything is optional.
|
||||
"""
|
||||
standards = [('README', 'README.txt')]
|
||||
for fn in standards:
|
||||
if isinstance(fn, tuple):
|
||||
alts = fn
|
||||
got_it = False
|
||||
for fn in alts:
|
||||
if os.path.exists(fn):
|
||||
got_it = True
|
||||
self.filelist.append(fn)
|
||||
break
|
||||
|
||||
if not got_it:
|
||||
logger.warning(
|
||||
'%s: standard file not found: should have one of %s',
|
||||
self.get_command_name(), ', '.join(alts))
|
||||
else:
|
||||
if os.path.exists(fn):
|
||||
self.filelist.append(fn)
|
||||
else:
|
||||
logger.warning('%s: standard file %r not found',
|
||||
self.get_command_name(), fn)
|
||||
|
||||
optional = ['test/test*.py', 'setup.cfg']
|
||||
for pattern in optional:
|
||||
files = [f for f in glob(pattern) if os.path.isfile(f)]
|
||||
if files:
|
||||
self.filelist.extend(files)
|
||||
|
||||
for cmd_name in get_command_names():
|
||||
try:
|
||||
cmd_obj = self.get_finalized_command(cmd_name)
|
||||
|
|
|
@ -83,19 +83,16 @@ def customize_compiler(compiler):
|
|||
# patterns. Order is important; platform mappings are preferred over
|
||||
# OS names.
|
||||
_default_compilers = (
|
||||
|
||||
# Platform string mappings
|
||||
|
||||
# on a cygwin built python we can use gcc like an ordinary UNIXish
|
||||
# compiler
|
||||
('cygwin.*', 'unix'),
|
||||
('os2emx', 'emx'),
|
||||
|
||||
# OS name mappings
|
||||
('posix', 'unix'),
|
||||
('nt', 'msvc'),
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
def get_default_compiler(osname=None, platform=None):
|
||||
""" Determine the default compiler to use for the given platform.
|
||||
|
|
|
@ -352,7 +352,7 @@ def _setup_compile(self, outdir, macros, incdirs, sources, depends,
|
|||
return macros, objects, extra, pp_opts, build
|
||||
|
||||
def _get_cc_args(self, pp_opts, debug, before):
|
||||
# works for unixccompiler, emxccompiler, cygwinccompiler
|
||||
# works for unixccompiler and cygwinccompiler
|
||||
cc_args = pp_opts + ['-c']
|
||||
if debug:
|
||||
cc_args[:0] = ['-g']
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
import getopt
|
||||
import re
|
||||
import sys
|
||||
import string
|
||||
import textwrap
|
||||
|
||||
from packaging.errors import PackagingGetoptError, PackagingArgError
|
||||
|
@ -142,20 +141,20 @@ def _grok_option_table(self):
|
|||
|
||||
for option in self.option_table:
|
||||
if len(option) == 3:
|
||||
integer, short, help = option
|
||||
longopt, short, help = option
|
||||
repeat = 0
|
||||
elif len(option) == 4:
|
||||
integer, short, help, repeat = option
|
||||
longopt, short, help, repeat = option
|
||||
else:
|
||||
# the option table is part of the code, so simply
|
||||
# assert that it is correct
|
||||
raise ValueError("invalid option tuple: %r" % option)
|
||||
|
||||
# Type- and value-check the option names
|
||||
if not isinstance(integer, str) or len(integer) < 2:
|
||||
if not isinstance(longopt, str) or len(longopt) < 2:
|
||||
raise PackagingGetoptError(
|
||||
("invalid long option '%s': "
|
||||
"must be a string of length >= 2") % integer)
|
||||
"must be a string of length >= 2") % longopt)
|
||||
|
||||
if (not ((short is None) or
|
||||
(isinstance(short, str) and len(short) == 1))):
|
||||
|
@ -163,55 +162,55 @@ def _grok_option_table(self):
|
|||
("invalid short option '%s': "
|
||||
"must be a single character or None") % short)
|
||||
|
||||
self.repeat[integer] = repeat
|
||||
self.long_opts.append(integer)
|
||||
self.repeat[longopt] = repeat
|
||||
self.long_opts.append(longopt)
|
||||
|
||||
if integer[-1] == '=': # option takes an argument?
|
||||
if longopt[-1] == '=': # option takes an argument?
|
||||
if short:
|
||||
short = short + ':'
|
||||
integer = integer[0:-1]
|
||||
self.takes_arg[integer] = 1
|
||||
longopt = longopt[0:-1]
|
||||
self.takes_arg[longopt] = 1
|
||||
else:
|
||||
|
||||
# Is option is a "negative alias" for some other option (eg.
|
||||
# "quiet" == "!verbose")?
|
||||
alias_to = self.negative_alias.get(integer)
|
||||
alias_to = self.negative_alias.get(longopt)
|
||||
if alias_to is not None:
|
||||
if self.takes_arg[alias_to]:
|
||||
raise PackagingGetoptError(
|
||||
("invalid negative alias '%s': "
|
||||
"aliased option '%s' takes a value") % \
|
||||
(integer, alias_to))
|
||||
(longopt, alias_to))
|
||||
|
||||
self.long_opts[-1] = integer # XXX redundant?!
|
||||
self.takes_arg[integer] = 0
|
||||
self.long_opts[-1] = longopt # XXX redundant?!
|
||||
self.takes_arg[longopt] = 0
|
||||
|
||||
else:
|
||||
self.takes_arg[integer] = 0
|
||||
self.takes_arg[longopt] = 0
|
||||
|
||||
# If this is an alias option, make sure its "takes arg" flag is
|
||||
# the same as the option it's aliased to.
|
||||
alias_to = self.alias.get(integer)
|
||||
alias_to = self.alias.get(longopt)
|
||||
if alias_to is not None:
|
||||
if self.takes_arg[integer] != self.takes_arg[alias_to]:
|
||||
if self.takes_arg[longopt] != self.takes_arg[alias_to]:
|
||||
raise PackagingGetoptError(
|
||||
("invalid alias '%s': inconsistent with "
|
||||
"aliased option '%s' (one of them takes a value, "
|
||||
"the other doesn't") % (integer, alias_to))
|
||||
"the other doesn't") % (longopt, alias_to))
|
||||
|
||||
# Now enforce some bondage on the long option name, so we can
|
||||
# later translate it to an attribute name on some object. Have
|
||||
# to do this a bit late to make sure we've removed any trailing
|
||||
# '='.
|
||||
if not longopt_re.match(integer):
|
||||
if not longopt_re.match(longopt):
|
||||
raise PackagingGetoptError(
|
||||
("invalid long option name '%s' " +
|
||||
"(must be letters, numbers, hyphens only") % integer)
|
||||
"(must be letters, numbers, hyphens only") % longopt)
|
||||
|
||||
self.attr_name[integer] = integer.replace('-', '_')
|
||||
self.attr_name[longopt] = longopt.replace('-', '_')
|
||||
if short:
|
||||
self.short_opts.append(short)
|
||||
self.short2long[short[0]] = integer
|
||||
self.short2long[short[0]] = longopt
|
||||
|
||||
def getopt(self, args=None, object=None):
|
||||
"""Parse command-line options in args. Store as attributes on object.
|
||||
|
@ -297,10 +296,10 @@ def generate_help(self, header=None):
|
|||
# First pass: determine maximum length of long option names
|
||||
max_opt = 0
|
||||
for option in self.option_table:
|
||||
integer = option[0]
|
||||
longopt = option[0]
|
||||
short = option[1]
|
||||
l = len(integer)
|
||||
if integer[-1] == '=':
|
||||
l = len(longopt)
|
||||
if longopt[-1] == '=':
|
||||
l = l - 1
|
||||
if short is not None:
|
||||
l = l + 5 # " (-x)" where short == 'x'
|
||||
|
@ -340,20 +339,20 @@ def generate_help(self, header=None):
|
|||
lines = ['Option summary:']
|
||||
|
||||
for option in self.option_table:
|
||||
integer, short, help = option[:3]
|
||||
longopt, short, help = option[:3]
|
||||
text = textwrap.wrap(help, text_width)
|
||||
|
||||
# Case 1: no short option at all (makes life easy)
|
||||
if short is None:
|
||||
if text:
|
||||
lines.append(" --%-*s %s" % (max_opt, integer, text[0]))
|
||||
lines.append(" --%-*s %s" % (max_opt, longopt, text[0]))
|
||||
else:
|
||||
lines.append(" --%-*s " % (max_opt, integer))
|
||||
lines.append(" --%-*s " % (max_opt, longopt))
|
||||
|
||||
# Case 2: we have a short option, so we have to include it
|
||||
# just after the long option
|
||||
else:
|
||||
opt_names = "%s (-%s)" % (integer, short)
|
||||
opt_names = "%s (-%s)" % (longopt, short)
|
||||
if text:
|
||||
lines.append(" --%-*s %s" %
|
||||
(max_opt, opt_names, text[0]))
|
||||
|
@ -378,68 +377,6 @@ def fancy_getopt(options, negative_opt, object, args):
|
|||
return parser.getopt(args, object)
|
||||
|
||||
|
||||
WS_TRANS = str.maketrans(string.whitespace, ' ' * len(string.whitespace))
|
||||
|
||||
|
||||
def wrap_text(text, width):
|
||||
"""Split *text* into lines of no more than *width* characters each.
|
||||
|
||||
*text* is a str and *width* an int. Returns a list of str.
|
||||
"""
|
||||
|
||||
if text is None:
|
||||
return []
|
||||
if len(text) <= width:
|
||||
return [text]
|
||||
|
||||
text = text.expandtabs()
|
||||
text = text.translate(WS_TRANS)
|
||||
|
||||
chunks = re.split(r'( +|-+)', text)
|
||||
chunks = [_f for _f in chunks if _f] # ' - ' results in empty strings
|
||||
lines = []
|
||||
|
||||
while chunks:
|
||||
|
||||
cur_line = [] # list of chunks (to-be-joined)
|
||||
cur_len = 0 # length of current line
|
||||
|
||||
while chunks:
|
||||
l = len(chunks[0])
|
||||
if cur_len + l <= width: # can squeeze (at least) this chunk in
|
||||
cur_line.append(chunks[0])
|
||||
del chunks[0]
|
||||
cur_len = cur_len + l
|
||||
else: # this line is full
|
||||
# drop last chunk if all space
|
||||
if cur_line and cur_line[-1][0] == ' ':
|
||||
del cur_line[-1]
|
||||
break
|
||||
|
||||
if chunks: # any chunks left to process?
|
||||
|
||||
# if the current line is still empty, then we had a single
|
||||
# chunk that's too big too fit on a line -- so we break
|
||||
# down and break it up at the line width
|
||||
if cur_len == 0:
|
||||
cur_line.append(chunks[0][0:width])
|
||||
chunks[0] = chunks[0][width:]
|
||||
|
||||
# all-whitespace chunks at the end of a line can be discarded
|
||||
# (and we know from the re.split above that if a chunk has
|
||||
# *any* whitespace, it is *all* whitespace)
|
||||
if chunks[0][0] == ' ':
|
||||
del chunks[0]
|
||||
|
||||
# and store this line in the list-of-all-lines -- as a single
|
||||
# string, of course!
|
||||
lines.append(''.join(cur_line))
|
||||
|
||||
# while chunks
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
class OptionDummy:
|
||||
"""Dummy class just used as a place to hold command-line option
|
||||
values as instance attributes."""
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Spider using the screen-scraping "simple" PyPI API.
|
||||
|
||||
This module contains the class SimpleIndexCrawler, a simple spider that
|
||||
This module contains the class Crawler, a simple spider that
|
||||
can be used to find and retrieve distributions from a project index
|
||||
(like the Python Package Index), using its so-called simple API (see
|
||||
reference implementation available at http://pypi.python.org/simple/).
|
||||
|
@ -178,7 +178,7 @@ def search_projects(self, name=None, **kwargs):
|
|||
|
||||
def get_releases(self, requirements, prefer_final=None,
|
||||
force_update=False):
|
||||
"""Search for releases and return a ReleaseList object containing
|
||||
"""Search for releases and return a ReleasesList object containing
|
||||
the results.
|
||||
"""
|
||||
predicate = get_version_predicate(requirements)
|
||||
|
|
|
@ -31,11 +31,11 @@ class Client(BaseClient):
|
|||
If no server_url is specified, use the default PyPI XML-RPC URL,
|
||||
defined in the DEFAULT_XMLRPC_INDEX_URL constant::
|
||||
|
||||
>>> client = XMLRPCClient()
|
||||
>>> client = Client()
|
||||
>>> client.server_url == DEFAULT_XMLRPC_INDEX_URL
|
||||
True
|
||||
|
||||
>>> client = XMLRPCClient("http://someurl/")
|
||||
>>> client = Client("http://someurl/")
|
||||
>>> client.server_url
|
||||
'http://someurl/'
|
||||
"""
|
||||
|
@ -69,7 +69,7 @@ def get_releases(self, requirements, prefer_final=None, show_hidden=True,
|
|||
informations (eg. make a new XML-RPC call).
|
||||
::
|
||||
|
||||
>>> client = XMLRPCClient()
|
||||
>>> client = Client()
|
||||
>>> client.get_releases('Foo')
|
||||
['1.1', '1.2', '1.3']
|
||||
|
||||
|
@ -189,7 +189,7 @@ def proxy(self):
|
|||
|
||||
If no server proxy is defined yet, creates a new one::
|
||||
|
||||
>>> client = XmlRpcClient()
|
||||
>>> client = Client()
|
||||
>>> client.proxy()
|
||||
<ServerProxy for python.org/pypi>
|
||||
|
||||
|
|
|
@ -370,8 +370,8 @@ def test_suite():
|
|||
src = _get_source_filename()
|
||||
if not os.path.exists(src):
|
||||
if verbose:
|
||||
print ('test_build_ext: Cannot find source code (test'
|
||||
' must run in python build dir)')
|
||||
print('test_command_build_ext: Cannot find source code (test'
|
||||
' must run in python build dir)')
|
||||
return unittest.TestSuite()
|
||||
else:
|
||||
return unittest.makeSuite(BuildExtTestCase)
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
MANIFEST = """\
|
||||
# file GENERATED by packaging, do NOT edit
|
||||
README
|
||||
inroot.txt
|
||||
data%(sep)sdata.dt
|
||||
scripts%(sep)sscript.py
|
||||
|
@ -129,7 +128,7 @@ def test_prune_file_list(self):
|
|||
content = zip_file.namelist()
|
||||
|
||||
# making sure everything has been pruned correctly
|
||||
self.assertEqual(len(content), 3)
|
||||
self.assertEqual(len(content), 2)
|
||||
|
||||
@requires_zlib
|
||||
@unittest.skipIf(find_executable('tar') is None or
|
||||
|
@ -214,7 +213,7 @@ def test_add_defaults(self):
|
|||
|
||||
# Making sure everything was added. This includes 9 code and data
|
||||
# files in addition to PKG-INFO.
|
||||
self.assertEqual(len(content), 10)
|
||||
self.assertEqual(len(content), 9)
|
||||
|
||||
# Checking the MANIFEST
|
||||
with open(join(self.tmp_dir, 'MANIFEST')) as fp:
|
||||
|
@ -331,7 +330,7 @@ def test_get_file_list(self):
|
|||
with open(cmd.manifest) as f:
|
||||
manifest = [line.strip() for line in f.read().split('\n')
|
||||
if line.strip() != '']
|
||||
self.assertEqual(len(manifest), 4)
|
||||
self.assertEqual(len(manifest), 3)
|
||||
|
||||
# Adding a file
|
||||
self.write_file((self.tmp_dir, 'somecode', 'doc2.txt'), '#')
|
||||
|
@ -348,7 +347,7 @@ def test_get_file_list(self):
|
|||
if line.strip() != '']
|
||||
|
||||
# Do we have the new file in MANIFEST?
|
||||
self.assertEqual(len(manifest2), 5)
|
||||
self.assertEqual(len(manifest2), 4)
|
||||
self.assertIn('doc2.txt', manifest2[-1])
|
||||
|
||||
@requires_zlib
|
||||
|
|
Loading…
Reference in New Issue