summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-06-24 00:23:20 (GMT)
committerGreg Ward <gward@python.net>2000-06-24 00:23:20 (GMT)
commit2ff7887270385bd6dddc2d5461486334b4fec8bc (patch)
tree35c3f4814ec717a72c03a70d24bad2cccf1ac3aa /Lib/distutils
parentffcaf2dd72ef0735d0eea125f1789d48c575f9b5 (diff)
downloadcpython-2ff7887270385bd6dddc2d5461486334b4fec8bc.zip
cpython-2ff7887270385bd6dddc2d5461486334b4fec8bc.tar.gz
cpython-2ff7887270385bd6dddc2d5461486334b4fec8bc.tar.bz2
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/archive_util.py8
-rw-r--r--Lib/distutils/ccompiler.py30
-rw-r--r--Lib/distutils/command/bdist.py29
-rw-r--r--Lib/distutils/command/build.py3
-rw-r--r--Lib/distutils/command/build_clib.py3
-rw-r--r--Lib/distutils/command/sdist.py4
-rw-r--r--Lib/distutils/dist.py37
7 files changed, 72 insertions, 42 deletions
diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py
index 27aa8c0..08a3c83 100644
--- a/Lib/distutils/archive_util.py
+++ b/Lib/distutils/archive_util.py
@@ -110,10 +110,10 @@ def make_zipfile (base_name, base_dir, verbose=0, dry_run=0):
ARCHIVE_FORMATS = {
- 'gztar': (make_tarball, [('compress', 'gzip')],"gzipped tar-file"),
- 'bztar': (make_tarball, [('compress', 'bzip2')],"bzip2-ed tar-file"),
- 'ztar': (make_tarball, [('compress', 'compress')],"compressed tar-file"),
- 'tar': (make_tarball, [('compress', None)],"uncompressed tar-file"),
+ 'gztar': (make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"),
+ 'bztar': (make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"),
+ 'ztar': (make_tarball, [('compress', 'compress')], "compressed tar file"),
+ 'tar': (make_tarball, [('compress', None)], "uncompressed tar file"),
'zip': (make_zipfile, [],"zip-file")
}
diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
index 53d4fa5..5be8c25 100644
--- a/Lib/distutils/ccompiler.py
+++ b/Lib/distutils/ccompiler.py
@@ -742,20 +742,30 @@ default_compiler = { 'posix': 'unix',
# Map compiler types to (module_name, class_name) pairs -- ie. where to
# find the code that implements an interface to this compiler. (The module
# is assumed to be in the 'distutils' package.)
-compiler_class = { 'unix': ('unixccompiler', 'UnixCCompiler',"standard UNIX-style compiler"),
- 'msvc': ('msvccompiler', 'MSVCCompiler',"Microsoft Visual C++"),
- 'cygwin': ('cygwinccompiler', 'CygwinCCompiler',"Cygwin-Gnu-Win32-C-Compiler"),
- 'mingw32': ('cygwinccompiler', 'Mingw32CCompiler',"MinGW32-C-Compiler (or cygwin in this mode)"),
+compiler_class = { 'unix': ('unixccompiler', 'UnixCCompiler',
+ "standard UNIX-style compiler"),
+ 'msvc': ('msvccompiler', 'MSVCCompiler',
+ "Microsoft Visual C++"),
+ 'cygwin': ('cygwinccompiler', 'CygwinCCompiler',
+ "Cygwin port of GNU C Compiler for Win32"),
+ 'mingw32': ('cygwinccompiler', 'Mingw32CCompiler',
+ "Mingw32 port of GNU C Compiler for Win32"),
}
-# prints all possible arguments to --compiler
def show_compilers():
+ """Print list of available compilers (used by the "--help-compiler"
+ options to "build", "build_ext", "build_clib").
+ """
+ # XXX this "knows" that the compiler option it's describing is
+ # "--compiler", which just happens to be the case for the three
+ # commands that use it.
from distutils.fancy_getopt import FancyGetopt
- list_of_compilers=[]
+ compilers = []
for compiler in compiler_class.keys():
- list_of_compilers.append(("compiler="+compiler,None,compiler_class[compiler][2]))
- list_of_compilers.sort()
- pretty_printer=FancyGetopt(list_of_compilers)
+ compilers.append(("compiler="+compiler, None,
+ compiler_class[compiler][2]))
+ compilers.sort()
+ pretty_printer = FancyGetopt(compilers)
pretty_printer.print_help("List of available compilers:")
@@ -783,7 +793,7 @@ def new_compiler (plat=None,
if compiler is None:
compiler = default_compiler[plat]
- (module_name, class_name,long_description) = compiler_class[compiler]
+ (module_name, class_name, long_description) = compiler_class[compiler]
except KeyError:
msg = "don't know how to compile C/C++ code on platform '%s'" % plat
if compiler is not None:
diff --git a/Lib/distutils/command/bdist.py b/Lib/distutils/command/bdist.py
index 66ef113..1646993 100644
--- a/Lib/distutils/command/bdist.py
+++ b/Lib/distutils/command/bdist.py
@@ -21,7 +21,7 @@ class bdist (Command):
user_options = [('bdist-base=', 'b',
"temporary directory for creating built distributions"),
('formats=', None,
- "formats for distribution"),
+ "formats for distribution (comma-separated list)"),
]
# The following commands do not take a format option from bdist
@@ -32,22 +32,24 @@ class bdist (Command):
default_format = { 'posix': 'gztar',
'nt': 'zip', }
- format_command = { 'gztar': ('bdist_dumb',"gzipped tar-file"),
- 'bztar': ('bdist_dumb',"bzip2-ed tar-file"),
- 'ztar': ('bdist_dumb',"compressed tar-file"),
- 'tar': ('bdist_dumb',"tar-file"),
- 'rpm': ('bdist_rpm',"rpm distribution"),
- 'zip': ('bdist_dumb',"zip-file"),
+ format_command = { 'rpm': ('bdist_rpm', "RPM distribution"),
+ 'gztar': ('bdist_dumb', "gzip'ed tar file"),
+ 'bztar': ('bdist_dumb', "bzip2'ed tar file"),
+ 'ztar': ('bdist_dumb', "compressed tar file"),
+ 'tar': ('bdist_dumb', "tar file"),
+ 'zip': ('bdist_dumb', "ZIP file"),
}
- # prints all possible arguments to --format
- def show_formats():
+ def show_formats ():
+ """Print list of available formats (arguments to "--format" option).
+ """
from distutils.fancy_getopt import FancyGetopt
- list_of_formats=[]
+ formats=[]
for format in bdist.format_command.keys():
- list_of_formats.append(("formats="+format,None,bdist.format_command[format][1]))
- list_of_formats.sort()
- pretty_printer=FancyGetopt(list_of_formats)
+ formats.append(("formats="+format, None,
+ bdist.format_command[format][1]))
+ formats.sort()
+ pretty_printer = FancyGetopt(formats)
pretty_printer.print_help("List of available distribution formats:")
help_options = [
@@ -87,7 +89,6 @@ class bdist (Command):
def run (self):
for format in self.formats:
-
try:
cmd_name = self.format_command[format][0]
except KeyError:
diff --git a/Lib/distutils/command/build.py b/Lib/distutils/command/build.py
index c064f83..d5513fc 100644
--- a/Lib/distutils/command/build.py
+++ b/Lib/distutils/command/build.py
@@ -36,9 +36,10 @@ class build (Command):
('force', 'f',
"forcibly build everything (ignore file timestamps)"),
]
+
help_options = [
('help-compiler', None,
- "lists available compilers",show_compilers),
+ "list available compilers", show_compilers),
]
def initialize_options (self):
diff --git a/Lib/distutils/command/build_clib.py b/Lib/distutils/command/build_clib.py
index 72df372..9a82ac0 100644
--- a/Lib/distutils/command/build_clib.py
+++ b/Lib/distutils/command/build_clib.py
@@ -42,9 +42,10 @@ class build_clib (Command):
('compiler=', 'c',
"specify the compiler type"),
]
+
help_options = [
('help-compiler', None,
- "lists available compilers",show_compilers),
+ "list available compilers", show_compilers),
]
def initialize_options (self):
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index ded8ec2..93e53bb 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -36,7 +36,7 @@ class sdist (Command):
('force-manifest', 'f',
"forcibly regenerate the manifest and carry on as usual"),
('formats=', None,
- "formats for source distribution"),
+ "formats for source distribution (comma-separated list)"),
('keep-tree', 'k',
"keep the distribution tree around after creating " +
"archive file(s)"),
@@ -61,7 +61,7 @@ class sdist (Command):
help_options = [
('help-formats', None,
- "lists available distribution formats", show_formats),
+ "list available distribution formats", show_formats),
]
negative_opts = {'use-defaults': 'no-defaults'}
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index 88bd94a..2e4951f 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -437,11 +437,14 @@ class Distribution:
negative_opt = copy (negative_opt)
negative_opt.update (cmd_class.negative_opt)
- # Check for help_options in command class
- # They have a different format (tuple of four) so we need to preprocess them here
- help_options = []
- if hasattr(cmd_class,"help_options") and type (cmd_class.help_options) is ListType:
- help_options = map(lambda x:(x[0],x[1],x[2]),cmd_class.help_options)
+ # Check for help_options in command class. They have a different
+ # format (tuple of four) so we need to preprocess them here.
+ if (hasattr(cmd_class, 'help_options') and
+ type (cmd_class.help_options) is ListType):
+ help_options = fix_help_options(cmd_class.help_options)
+ else:
+ help_optiosn = []
+
# All commands support the global options too, just by adding
# in 'global_options'.
@@ -453,12 +456,14 @@ class Distribution:
self._show_help(parser, display_options=0, commands=[cmd_class])
return
- if hasattr(cmd_class,"help_options") and type (cmd_class.help_options) is ListType:
+ if (hasattr(cmd_class, 'help_options') and
+ type (cmd_class.help_options) is ListType):
help_option_found=0
for help_option in cmd_class.help_options:
if hasattr(opts, parser.get_attr_name(help_option[0])):
help_option_found=1
- #print "showing help for option %s of command %s" % (help_option[0],cmd_class)
+ #print "showing help for option %s of command %s" % \
+ # (help_option[0],cmd_class)
if callable(help_option[3]):
help_option[3]()
else:
@@ -518,9 +523,10 @@ class Distribution:
klass = command
else:
klass = self.get_command_class (command)
- if hasattr(klass,"help_options") and type (klass.help_options) is ListType:
- parser.set_option_table (klass.user_options+
- map(lambda x:(x[0],x[1],x[2]),klass.help_options))
+ if (hasattr(klass, 'help_options') and
+ type (klass.help_options) is ListType):
+ parser.set_option_table (klass.user_options +
+ fix_help_options(klass.help_options))
else:
parser.set_option_table (klass.user_options)
parser.print_help ("Options for '%s' command:" % klass.__name__)
@@ -890,6 +896,17 @@ class DistributionMetadata:
# class DistributionMetadata
+
+def fix_help_options (options):
+ """Convert a 4-tuple 'help_options' list as found in various command
+ classes to the 3-tuple form required by FancyGetopt.
+ """
+ new_options = []
+ for help_tuple in options:
+ new_options.append(help_tuple[0:3])
+ return new_options
+
+
if __name__ == "__main__":
dist = Distribution ()
print "ok"