mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Changed so all the help-generating functions are defined, at module-level,
in the module of the command classes that have command-specific help options. This lets us keep the principle of lazily importing the ccompiler module, and also gets away from defining non-methods at class level.
This commit is contained in:
parent
55fced3df9
commit
3459381e2a
5 changed files with 56 additions and 41 deletions
|
@ -14,6 +14,18 @@ from distutils.errors import *
|
||||||
from distutils.util import get_platform
|
from distutils.util import get_platform
|
||||||
|
|
||||||
|
|
||||||
|
def show_formats ():
|
||||||
|
"""Print list of available formats (arguments to "--format" option).
|
||||||
|
"""
|
||||||
|
from distutils.fancy_getopt import FancyGetopt
|
||||||
|
formats=[]
|
||||||
|
for format in bdist.format_commands:
|
||||||
|
formats.append(("formats=" + format, None,
|
||||||
|
bdist.format_command[format][1]))
|
||||||
|
pretty_printer = FancyGetopt(formats)
|
||||||
|
pretty_printer.print_help("List of available distribution formats:")
|
||||||
|
|
||||||
|
|
||||||
class bdist (Command):
|
class bdist (Command):
|
||||||
|
|
||||||
description = "create a built (binary) distribution"
|
description = "create a built (binary) distribution"
|
||||||
|
@ -24,6 +36,11 @@ class bdist (Command):
|
||||||
"formats for distribution (comma-separated list)"),
|
"formats for distribution (comma-separated list)"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
help_options = [
|
||||||
|
('help-formats', None,
|
||||||
|
"lists available distribution formats", show_formats),
|
||||||
|
]
|
||||||
|
|
||||||
# The following commands do not take a format option from bdist
|
# The following commands do not take a format option from bdist
|
||||||
no_format_option = ('bdist_rpm',)
|
no_format_option = ('bdist_rpm',)
|
||||||
|
|
||||||
|
@ -38,24 +55,9 @@ class bdist (Command):
|
||||||
'ztar': ('bdist_dumb', "compressed tar file"),
|
'ztar': ('bdist_dumb', "compressed tar file"),
|
||||||
'tar': ('bdist_dumb', "tar file"),
|
'tar': ('bdist_dumb', "tar file"),
|
||||||
'zip': ('bdist_dumb', "ZIP file"),
|
'zip': ('bdist_dumb', "ZIP file"),
|
||||||
}
|
}
|
||||||
|
# establish the preferred order
|
||||||
def show_formats ():
|
format_commands = ['rpm', 'gztar', 'bztar', 'ztar', 'tar', 'zip']
|
||||||
"""Print list of available formats (arguments to "--format" option).
|
|
||||||
"""
|
|
||||||
from distutils.fancy_getopt import FancyGetopt
|
|
||||||
formats=[]
|
|
||||||
for format in bdist.format_command.keys():
|
|
||||||
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 = [
|
|
||||||
('help-formats', None,
|
|
||||||
"lists available distribution formats",show_formats),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def initialize_options (self):
|
def initialize_options (self):
|
||||||
|
|
|
@ -9,7 +9,12 @@ __revision__ = "$Id$"
|
||||||
import sys, os
|
import sys, os
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.util import get_platform
|
from distutils.util import get_platform
|
||||||
from distutils.ccompiler import show_compilers
|
|
||||||
|
|
||||||
|
def show_compilers ():
|
||||||
|
from distutils.ccompiler import show_compilers
|
||||||
|
show_compilers()
|
||||||
|
|
||||||
|
|
||||||
class build (Command):
|
class build (Command):
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,11 @@ import os, string
|
||||||
from types import *
|
from types import *
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
from distutils.ccompiler import new_compiler,show_compilers
|
|
||||||
|
|
||||||
|
def show_compilers ():
|
||||||
|
from distutils.ccompiler import show_compilers
|
||||||
|
show_compilers()
|
||||||
|
|
||||||
|
|
||||||
class build_clib (Command):
|
class build_clib (Command):
|
||||||
|
@ -102,6 +106,7 @@ class build_clib (Command):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Yech -- this is cut 'n pasted from build_ext.py!
|
# Yech -- this is cut 'n pasted from build_ext.py!
|
||||||
|
from distutils.ccompiler import new_compiler
|
||||||
self.compiler = new_compiler (compiler=self.compiler,
|
self.compiler = new_compiler (compiler=self.compiler,
|
||||||
verbose=self.verbose,
|
verbose=self.verbose,
|
||||||
dry_run=self.dry_run,
|
dry_run=self.dry_run,
|
||||||
|
|
|
@ -14,7 +14,6 @@ from distutils.core import Command
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
from distutils.dep_util import newer_group
|
from distutils.dep_util import newer_group
|
||||||
from distutils.extension import Extension
|
from distutils.extension import Extension
|
||||||
from distutils.ccompiler import show_compilers
|
|
||||||
|
|
||||||
# An extension name is just a dot-separated list of Python NAMEs (ie.
|
# An extension name is just a dot-separated list of Python NAMEs (ie.
|
||||||
# the same as a fully-qualified module name).
|
# the same as a fully-qualified module name).
|
||||||
|
@ -22,6 +21,11 @@ extension_name_re = re.compile \
|
||||||
(r'^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$')
|
(r'^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$')
|
||||||
|
|
||||||
|
|
||||||
|
def show_compilers ():
|
||||||
|
from distutils.ccompiler import show_compilers
|
||||||
|
show_compilers()
|
||||||
|
|
||||||
|
|
||||||
class build_ext (Command):
|
class build_ext (Command):
|
||||||
|
|
||||||
description = "build C/C++ extensions (compile/link to build directory)"
|
description = "build C/C++ extensions (compile/link to build directory)"
|
||||||
|
@ -73,12 +77,12 @@ class build_ext (Command):
|
||||||
('compiler=', 'c',
|
('compiler=', 'c',
|
||||||
"specify the compiler type"),
|
"specify the compiler type"),
|
||||||
]
|
]
|
||||||
|
|
||||||
help_options = [
|
help_options = [
|
||||||
('help-compiler', None,
|
('help-compiler', None,
|
||||||
"lists available compilers",show_compilers),
|
"list available compilers", show_compilers),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def initialize_options (self):
|
def initialize_options (self):
|
||||||
self.extensions = None
|
self.extensions = None
|
||||||
self.build_lib = None
|
self.build_lib = None
|
||||||
|
|
|
@ -13,11 +13,27 @@ from glob import glob
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.util import \
|
from distutils.util import \
|
||||||
convert_path, create_tree, remove_tree, newer, write_file, \
|
convert_path, create_tree, remove_tree, newer, write_file, \
|
||||||
check_archive_formats, ARCHIVE_FORMATS
|
check_archive_formats
|
||||||
from distutils.text_file import TextFile
|
from distutils.text_file import TextFile
|
||||||
from distutils.errors import DistutilsExecError, DistutilsOptionError
|
from distutils.errors import DistutilsExecError, DistutilsOptionError
|
||||||
|
|
||||||
|
|
||||||
|
def show_formats ():
|
||||||
|
"""Print all possible values for the 'formats' option (used by
|
||||||
|
the "--help-formats" command-line option).
|
||||||
|
"""
|
||||||
|
from distutils.fancy_getopt import FancyGetopt
|
||||||
|
from distutils.archive_util import ARCHIVE_FORMATS
|
||||||
|
formats=[]
|
||||||
|
for format in ARCHIVE_FORMATS.keys():
|
||||||
|
formats.append(("formats=" + format, None,
|
||||||
|
ARCHIVE_FORMATS[format][2]))
|
||||||
|
formats.sort()
|
||||||
|
pretty_printer = FancyGetopt(formats)
|
||||||
|
pretty_printer.print_help(
|
||||||
|
"List of available source distribution formats:")
|
||||||
|
|
||||||
|
|
||||||
class sdist (Command):
|
class sdist (Command):
|
||||||
|
|
||||||
description = "create a source distribution (tarball, zip file, etc.)"
|
description = "create a source distribution (tarball, zip file, etc.)"
|
||||||
|
@ -43,22 +59,6 @@ class sdist (Command):
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# XXX ugh: this has to precede the 'help_options' list, because
|
|
||||||
# it is mentioned there -- also, this is not a method, even though
|
|
||||||
# it's defined in a class: double-ugh!
|
|
||||||
def show_formats ():
|
|
||||||
"""Print all possible values for the 'formats' option -- used by
|
|
||||||
the "--help-formats" command-line option.
|
|
||||||
"""
|
|
||||||
from distutils.fancy_getopt import FancyGetopt
|
|
||||||
formats=[]
|
|
||||||
for format in ARCHIVE_FORMATS.keys():
|
|
||||||
formats.append(("formats="+format,None,ARCHIVE_FORMATS[format][2]))
|
|
||||||
formats.sort()
|
|
||||||
pretty_printer = FancyGetopt(formats)
|
|
||||||
pretty_printer.print_help(
|
|
||||||
"List of available source distribution formats:")
|
|
||||||
|
|
||||||
help_options = [
|
help_options = [
|
||||||
('help-formats', None,
|
('help-formats', None,
|
||||||
"list available distribution formats", show_formats),
|
"list available distribution formats", show_formats),
|
||||||
|
@ -69,7 +69,6 @@ class sdist (Command):
|
||||||
default_format = { 'posix': 'gztar',
|
default_format = { 'posix': 'gztar',
|
||||||
'nt': 'zip' }
|
'nt': 'zip' }
|
||||||
|
|
||||||
|
|
||||||
def initialize_options (self):
|
def initialize_options (self):
|
||||||
# 'template' and 'manifest' are, respectively, the names of
|
# 'template' and 'manifest' are, respectively, the names of
|
||||||
# the manifest template and manifest file.
|
# the manifest template and manifest file.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue