Kaydet (Commit) 98b65922 authored tarafından Éric Araujo's avatar Éric Araujo

Branch merge

...@@ -128,6 +128,7 @@ class bdist(Command): ...@@ -128,6 +128,7 @@ class bdist(Command):
for i in range(len(self.formats)): for i in range(len(self.formats)):
cmd_name = commands[i] cmd_name = commands[i]
sub_cmd = self.get_reinitialized_command(cmd_name) sub_cmd = self.get_reinitialized_command(cmd_name)
sub_cmd.format = self.formats[i]
# passing the owner and group names for tar archiving # passing the owner and group names for tar archiving
if cmd_name == 'bdist_dumb': if cmd_name == 'bdist_dumb':
......
"""Create a source distribution.""" """Create a source distribution."""
import os import os
import sys
import re import re
import sys
from io import StringIO from io import StringIO
from glob import glob
from shutil import get_archive_formats, rmtree from shutil import get_archive_formats, rmtree
from packaging import logger from packaging import logger
...@@ -203,45 +202,14 @@ class sdist(Command): ...@@ -203,45 +202,14 @@ class sdist(Command):
def add_defaults(self): def add_defaults(self):
"""Add all the default files to self.filelist: """Add all the default files to self.filelist:
- README or README.txt
- test/test*.py
- all pure Python modules mentioned in setup script - all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py) - all files pointed by package_data (build_py)
- all files defined in data_files. - all files defined in data_files.
- all files defined as scripts. - all files defined as scripts.
- all C sources listed as part of extensions or C libraries - all C sources listed as part of extensions or C libraries
in the setup script (doesn't catch C headers!) in the setup script (doesn't catch C headers!)
Warns if (README or README.txt) or setup.py are missing; everything Everything is optional.
else 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(): for cmd_name in get_command_names():
try: try:
cmd_obj = self.get_finalized_command(cmd_name) cmd_obj = self.get_finalized_command(cmd_name)
......
...@@ -83,19 +83,16 @@ def customize_compiler(compiler): ...@@ -83,19 +83,16 @@ def customize_compiler(compiler):
# patterns. Order is important; platform mappings are preferred over # patterns. Order is important; platform mappings are preferred over
# OS names. # OS names.
_default_compilers = ( _default_compilers = (
# Platform string mappings # Platform string mappings
# on a cygwin built python we can use gcc like an ordinary UNIXish # on a cygwin built python we can use gcc like an ordinary UNIXish
# compiler # compiler
('cygwin.*', 'unix'), ('cygwin.*', 'unix'),
('os2emx', 'emx'),
# OS name mappings # OS name mappings
('posix', 'unix'), ('posix', 'unix'),
('nt', 'msvc'), ('nt', 'msvc'),
)
)
def get_default_compiler(osname=None, platform=None): def get_default_compiler(osname=None, platform=None):
""" Determine the default compiler to use for the given platform. """ Determine the default compiler to use for the given platform.
......
...@@ -352,7 +352,7 @@ class CCompiler: ...@@ -352,7 +352,7 @@ class CCompiler:
return macros, objects, extra, pp_opts, build return macros, objects, extra, pp_opts, build
def _get_cc_args(self, pp_opts, debug, before): def _get_cc_args(self, pp_opts, debug, before):
# works for unixccompiler, emxccompiler, cygwinccompiler # works for unixccompiler and cygwinccompiler
cc_args = pp_opts + ['-c'] cc_args = pp_opts + ['-c']
if debug: if debug:
cc_args[:0] = ['-g'] cc_args[:0] = ['-g']
......
...@@ -13,7 +13,6 @@ It is used under the hood by the command classes. Do not use directly. ...@@ -13,7 +13,6 @@ It is used under the hood by the command classes. Do not use directly.
import getopt import getopt
import re import re
import sys import sys
import string
import textwrap import textwrap
from packaging.errors import PackagingGetoptError, PackagingArgError from packaging.errors import PackagingGetoptError, PackagingArgError
...@@ -142,20 +141,20 @@ class FancyGetopt: ...@@ -142,20 +141,20 @@ class FancyGetopt:
for option in self.option_table: for option in self.option_table:
if len(option) == 3: if len(option) == 3:
integer, short, help = option longopt, short, help = option
repeat = 0 repeat = 0
elif len(option) == 4: elif len(option) == 4:
integer, short, help, repeat = option longopt, short, help, repeat = option
else: else:
# the option table is part of the code, so simply # the option table is part of the code, so simply
# assert that it is correct # assert that it is correct
raise ValueError("invalid option tuple: %r" % option) raise ValueError("invalid option tuple: %r" % option)
# Type- and value-check the option names # 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( raise PackagingGetoptError(
("invalid long option '%s': " ("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 if (not ((short is None) or
(isinstance(short, str) and len(short) == 1))): (isinstance(short, str) and len(short) == 1))):
...@@ -163,55 +162,55 @@ class FancyGetopt: ...@@ -163,55 +162,55 @@ class FancyGetopt:
("invalid short option '%s': " ("invalid short option '%s': "
"must be a single character or None") % short) "must be a single character or None") % short)
self.repeat[integer] = repeat self.repeat[longopt] = repeat
self.long_opts.append(integer) self.long_opts.append(longopt)
if integer[-1] == '=': # option takes an argument? if longopt[-1] == '=': # option takes an argument?
if short: if short:
short = short + ':' short = short + ':'
integer = integer[0:-1] longopt = longopt[0:-1]
self.takes_arg[integer] = 1 self.takes_arg[longopt] = 1
else: else:
# Is option is a "negative alias" for some other option (eg. # Is option is a "negative alias" for some other option (eg.
# "quiet" == "!verbose")? # "quiet" == "!verbose")?
alias_to = self.negative_alias.get(integer) alias_to = self.negative_alias.get(longopt)
if alias_to is not None: if alias_to is not None:
if self.takes_arg[alias_to]: if self.takes_arg[alias_to]:
raise PackagingGetoptError( raise PackagingGetoptError(
("invalid negative alias '%s': " ("invalid negative alias '%s': "
"aliased option '%s' takes a value") % \ "aliased option '%s' takes a value") % \
(integer, alias_to)) (longopt, alias_to))
self.long_opts[-1] = integer # XXX redundant?! self.long_opts[-1] = longopt # XXX redundant?!
self.takes_arg[integer] = 0 self.takes_arg[longopt] = 0
else: else:
self.takes_arg[integer] = 0 self.takes_arg[longopt] = 0
# If this is an alias option, make sure its "takes arg" flag is # If this is an alias option, make sure its "takes arg" flag is
# the same as the option it's aliased to. # 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 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( raise PackagingGetoptError(
("invalid alias '%s': inconsistent with " ("invalid alias '%s': inconsistent with "
"aliased option '%s' (one of them takes a value, " "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 # Now enforce some bondage on the long option name, so we can
# later translate it to an attribute name on some object. Have # 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 # 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( raise PackagingGetoptError(
("invalid long option name '%s' " + ("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: if short:
self.short_opts.append(short) self.short_opts.append(short)
self.short2long[short[0]] = integer self.short2long[short[0]] = longopt
def getopt(self, args=None, object=None): def getopt(self, args=None, object=None):
"""Parse command-line options in args. Store as attributes on object. """Parse command-line options in args. Store as attributes on object.
...@@ -297,10 +296,10 @@ class FancyGetopt: ...@@ -297,10 +296,10 @@ class FancyGetopt:
# First pass: determine maximum length of long option names # First pass: determine maximum length of long option names
max_opt = 0 max_opt = 0
for option in self.option_table: for option in self.option_table:
integer = option[0] longopt = option[0]
short = option[1] short = option[1]
l = len(integer) l = len(longopt)
if integer[-1] == '=': if longopt[-1] == '=':
l = l - 1 l = l - 1
if short is not None: if short is not None:
l = l + 5 # " (-x)" where short == 'x' l = l + 5 # " (-x)" where short == 'x'
...@@ -340,20 +339,20 @@ class FancyGetopt: ...@@ -340,20 +339,20 @@ class FancyGetopt:
lines = ['Option summary:'] lines = ['Option summary:']
for option in self.option_table: for option in self.option_table:
integer, short, help = option[:3] longopt, short, help = option[:3]
text = textwrap.wrap(help, text_width) text = textwrap.wrap(help, text_width)
# Case 1: no short option at all (makes life easy) # Case 1: no short option at all (makes life easy)
if short is None: if short is None:
if text: if text:
lines.append(" --%-*s %s" % (max_opt, integer, text[0])) lines.append(" --%-*s %s" % (max_opt, longopt, text[0]))
else: 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 # Case 2: we have a short option, so we have to include it
# just after the long option # just after the long option
else: else:
opt_names = "%s (-%s)" % (integer, short) opt_names = "%s (-%s)" % (longopt, short)
if text: if text:
lines.append(" --%-*s %s" % lines.append(" --%-*s %s" %
(max_opt, opt_names, text[0])) (max_opt, opt_names, text[0]))
...@@ -378,68 +377,6 @@ def fancy_getopt(options, negative_opt, object, args): ...@@ -378,68 +377,6 @@ def fancy_getopt(options, negative_opt, object, args):
return parser.getopt(args, object) 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: class OptionDummy:
"""Dummy class just used as a place to hold command-line option """Dummy class just used as a place to hold command-line option
values as instance attributes.""" values as instance attributes."""
......
"""Spider using the screen-scraping "simple" PyPI API. """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 can be used to find and retrieve distributions from a project index
(like the Python Package Index), using its so-called simple API (see (like the Python Package Index), using its so-called simple API (see
reference implementation available at http://pypi.python.org/simple/). reference implementation available at http://pypi.python.org/simple/).
...@@ -178,7 +178,7 @@ class Crawler(BaseClient): ...@@ -178,7 +178,7 @@ class Crawler(BaseClient):
def get_releases(self, requirements, prefer_final=None, def get_releases(self, requirements, prefer_final=None,
force_update=False): force_update=False):
"""Search for releases and return a ReleaseList object containing """Search for releases and return a ReleasesList object containing
the results. the results.
""" """
predicate = get_version_predicate(requirements) predicate = get_version_predicate(requirements)
......
...@@ -31,11 +31,11 @@ class Client(BaseClient): ...@@ -31,11 +31,11 @@ class Client(BaseClient):
If no server_url is specified, use the default PyPI XML-RPC URL, If no server_url is specified, use the default PyPI XML-RPC URL,
defined in the DEFAULT_XMLRPC_INDEX_URL constant:: defined in the DEFAULT_XMLRPC_INDEX_URL constant::
>>> client = XMLRPCClient() >>> client = Client()
>>> client.server_url == DEFAULT_XMLRPC_INDEX_URL >>> client.server_url == DEFAULT_XMLRPC_INDEX_URL
True True
>>> client = XMLRPCClient("http://someurl/") >>> client = Client("http://someurl/")
>>> client.server_url >>> client.server_url
'http://someurl/' 'http://someurl/'
""" """
...@@ -69,7 +69,7 @@ class Client(BaseClient): ...@@ -69,7 +69,7 @@ class Client(BaseClient):
informations (eg. make a new XML-RPC call). informations (eg. make a new XML-RPC call).
:: ::
>>> client = XMLRPCClient() >>> client = Client()
>>> client.get_releases('Foo') >>> client.get_releases('Foo')
['1.1', '1.2', '1.3'] ['1.1', '1.2', '1.3']
...@@ -189,7 +189,7 @@ class Client(BaseClient): ...@@ -189,7 +189,7 @@ class Client(BaseClient):
If no server proxy is defined yet, creates a new one:: If no server proxy is defined yet, creates a new one::
>>> client = XmlRpcClient() >>> client = Client()
>>> client.proxy() >>> client.proxy()
<ServerProxy for python.org/pypi> <ServerProxy for python.org/pypi>
......
...@@ -370,8 +370,8 @@ def test_suite(): ...@@ -370,8 +370,8 @@ def test_suite():
src = _get_source_filename() src = _get_source_filename()
if not os.path.exists(src): if not os.path.exists(src):
if verbose: if verbose:
print ('test_build_ext: Cannot find source code (test' print('test_command_build_ext: Cannot find source code (test'
' must run in python build dir)') ' must run in python build dir)')
return unittest.TestSuite() return unittest.TestSuite()
else: else:
return unittest.makeSuite(BuildExtTestCase) return unittest.makeSuite(BuildExtTestCase)
......
...@@ -33,7 +33,6 @@ setup(name='fake') ...@@ -33,7 +33,6 @@ setup(name='fake')
MANIFEST = """\ MANIFEST = """\
# file GENERATED by packaging, do NOT edit # file GENERATED by packaging, do NOT edit
README
inroot.txt inroot.txt
data%(sep)sdata.dt data%(sep)sdata.dt
scripts%(sep)sscript.py scripts%(sep)sscript.py
...@@ -129,7 +128,7 @@ class SDistTestCase(support.TempdirManager, ...@@ -129,7 +128,7 @@ class SDistTestCase(support.TempdirManager,
content = zip_file.namelist() content = zip_file.namelist()
# making sure everything has been pruned correctly # making sure everything has been pruned correctly
self.assertEqual(len(content), 3) self.assertEqual(len(content), 2)
@requires_zlib @requires_zlib
@unittest.skipIf(find_executable('tar') is None or @unittest.skipIf(find_executable('tar') is None or
...@@ -214,7 +213,7 @@ class SDistTestCase(support.TempdirManager, ...@@ -214,7 +213,7 @@ class SDistTestCase(support.TempdirManager,
# Making sure everything was added. This includes 9 code and data # Making sure everything was added. This includes 9 code and data
# files in addition to PKG-INFO. # files in addition to PKG-INFO.
self.assertEqual(len(content), 10) self.assertEqual(len(content), 9)
# Checking the MANIFEST # Checking the MANIFEST
with open(join(self.tmp_dir, 'MANIFEST')) as fp: with open(join(self.tmp_dir, 'MANIFEST')) as fp:
...@@ -331,7 +330,7 @@ class SDistTestCase(support.TempdirManager, ...@@ -331,7 +330,7 @@ class SDistTestCase(support.TempdirManager,
with open(cmd.manifest) as f: with open(cmd.manifest) as f:
manifest = [line.strip() for line in f.read().split('\n') manifest = [line.strip() for line in f.read().split('\n')
if line.strip() != ''] if line.strip() != '']
self.assertEqual(len(manifest), 4) self.assertEqual(len(manifest), 3)
# Adding a file # Adding a file
self.write_file((self.tmp_dir, 'somecode', 'doc2.txt'), '#') self.write_file((self.tmp_dir, 'somecode', 'doc2.txt'), '#')
...@@ -348,7 +347,7 @@ class SDistTestCase(support.TempdirManager, ...@@ -348,7 +347,7 @@ class SDistTestCase(support.TempdirManager,
if line.strip() != ''] if line.strip() != '']
# Do we have the new file in MANIFEST? # Do we have the new file in MANIFEST?
self.assertEqual(len(manifest2), 5) self.assertEqual(len(manifest2), 4)
self.assertIn('doc2.txt', manifest2[-1]) self.assertIn('doc2.txt', manifest2[-1])
@requires_zlib @requires_zlib
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment