[Python-checkins] cpython: Remove obsolete verbose arguments from packaging.

eric.araujo python-checkins at python.org
Tue Nov 15 16:13:59 CET 2011


http://hg.python.org/cpython/rev/fff38970e4e3
changeset:   73569:fff38970e4e3
user:        Éric Araujo <merwok at netwok.org>
date:        Tue Nov 15 11:43:20 2011 +0100
summary:
  Remove obsolete verbose arguments from packaging.

Logging replaces verbose arguments.  I haven’t fixed the example in
Doc/install/install.rst because I have major fixes and changes to the
oc under way and will fix or remove that example as part of that task.

files:
  Doc/install/install.rst                   |   2 +
  Doc/library/packaging.compiler.rst        |  10 ++--
  Doc/library/packaging.util.rst            |   2 +-
  Lib/packaging/command/build_ext.py        |   6 --
  Lib/packaging/command/cmd.py              |  18 +++++---
  Lib/packaging/command/sdist.py            |   5 +-
  Lib/packaging/command/test.py             |   3 +-
  Lib/packaging/compiler/__init__.py        |   9 +---
  Lib/packaging/compiler/bcppcompiler.py    |   4 +-
  Lib/packaging/compiler/ccompiler.py       |   3 +-
  Lib/packaging/compiler/cygwinccompiler.py |   8 +-
  Lib/packaging/compiler/msvc9compiler.py   |   4 +-
  Lib/packaging/compiler/msvccompiler.py    |   4 +-
  Lib/packaging/util.py                     |  23 ++++------
  14 files changed, 44 insertions(+), 57 deletions(-)


diff --git a/Doc/install/install.rst b/Doc/install/install.rst
--- a/Doc/install/install.rst
+++ b/Doc/install/install.rst
@@ -842,6 +842,8 @@
 Sections consist of one or more lines containing a single option specified as
 ``option = value``.
 
+.. XXX use dry-run in the next example or use a pysetup option as example
+
 For example, here's a complete configuration file that forces all commands to
 run quietly by default::
 
diff --git a/Doc/library/packaging.compiler.rst b/Doc/library/packaging.compiler.rst
--- a/Doc/library/packaging.compiler.rst
+++ b/Doc/library/packaging.compiler.rst
@@ -15,7 +15,7 @@
 Public functions
 ----------------
 
-.. function:: new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0)
+.. function:: new_compiler(plat=None, compiler=None, dry_run=False, force=False)
 
    Factory function to generate an instance of some
    :class:`~.ccompiler.CCompiler` subclass for the requested platform or
@@ -165,7 +165,7 @@
 options for the compiler --- macro definitions, include directories, link path,
 libraries and the like.
 
-.. class:: CCompiler([verbose=0, dry_run=0, force=0])
+.. class:: CCompiler(dry_run=False, force=False)
 
    The abstract base class :class:`CCompiler` defines the interface that must be
    implemented by real compiler classes.  The class also has some utility
@@ -180,11 +180,11 @@
    per-compilation or per-link basis.
 
    The constructor for each subclass creates an instance of the Compiler object.
-   Flags are *verbose* (show verbose output), *dry_run* (don't actually execute
+   Flags are *dry_run* (don't actually execute
    the steps) and *force* (rebuild everything, regardless of dependencies).  All
-   of these flags default to ``0`` (off). Note that you probably don't want to
+   of these flags default to ``False`` (off). Note that you probably don't want to
    instantiate :class:`CCompiler` or one of its subclasses directly - use the
-   :func:`packaging.CCompiler.new_compiler` factory function instead.
+   :func:`new_compiler` factory function instead.
 
    The following methods allow you to manually alter compiler options for the
    instance of the Compiler class.
diff --git a/Doc/library/packaging.util.rst b/Doc/library/packaging.util.rst
--- a/Doc/library/packaging.util.rst
+++ b/Doc/library/packaging.util.rst
@@ -90,7 +90,7 @@
    Search the path for a given executable name.
 
 
-.. function:: execute(func, args, msg=None, verbose=0, dry_run=0)
+.. function:: execute(func, args, msg=None, dry_run=False)
 
    Perform some action that affects the outside world (for instance, writing to
    the filesystem).  Such actions are special because they are disabled by the
diff --git a/Lib/packaging/command/build_ext.py b/Lib/packaging/command/build_ext.py
--- a/Lib/packaging/command/build_ext.py
+++ b/Lib/packaging/command/build_ext.py
@@ -4,7 +4,6 @@
 import re
 import sys
 import site
-import logging
 import sysconfig
 
 from packaging.util import get_platform
@@ -288,14 +287,9 @@
             self.libraries.extend(build_clib.get_library_names() or [])
             self.library_dirs.append(build_clib.build_clib)
 
-        # Temporary kludge until we remove the verbose arguments and use
-        # logging everywhere
-        verbose = logger.getEffectiveLevel() >= logging.DEBUG
-
         # Setup the CCompiler object that we'll use to do all the
         # compiling and linking
         self.compiler_obj = new_compiler(compiler=self.compiler,
-                                         verbose=verbose,
                                          dry_run=self.dry_run,
                                          force=self.force)
 
diff --git a/Lib/packaging/command/cmd.py b/Lib/packaging/command/cmd.py
--- a/Lib/packaging/command/cmd.py
+++ b/Lib/packaging/command/cmd.py
@@ -351,7 +351,7 @@
     def execute(self, func, args, msg=None, level=1):
         util.execute(func, args, msg, dry_run=self.dry_run)
 
-    def mkpath(self, name, mode=0o777, dry_run=None, verbose=0):
+    def mkpath(self, name, mode=0o777, dry_run=None):
         if dry_run is None:
             dry_run = self.dry_run
         name = os.path.normpath(name)
@@ -367,9 +367,11 @@
 
     def copy_file(self, infile, outfile,
                   preserve_mode=True, preserve_times=True, link=None, level=1):
-        """Copy a file respecting verbose, dry-run and force flags.  (The
-        former two default to whatever is in the Distribution object, and
-        the latter defaults to false for commands that don't define it.)"""
+        """Copy a file respecting dry-run and force flags.
+
+        (dry-run defaults to whatever is in the Distribution object, and
+        force to false for commands that don't define it.)
+        """
         if self.dry_run:
             # XXX add a comment
             return
@@ -380,11 +382,13 @@
 
     def copy_tree(self, infile, outfile, preserve_mode=True,
                   preserve_times=True, preserve_symlinks=False, level=1):
-        """Copy an entire directory tree respecting verbose, dry-run,
+        """Copy an entire directory tree respecting dry-run
         and force flags.
         """
         if self.dry_run:
-            return  # see if we want to display something
+            # XXX should not return but let copy_tree log and decide to execute
+            # or not based on its dry_run argument
+            return
 
         return util.copy_tree(infile, outfile, preserve_mode, preserve_times,
             preserve_symlinks, not self.force, dry_run=self.dry_run)
@@ -392,7 +396,7 @@
     def move_file(self, src, dst, level=1):
         """Move a file respecting the dry-run flag."""
         if self.dry_run:
-            return  # XXX log ?
+            return  # XXX same thing
         return move(src, dst)
 
     def spawn(self, cmd, search_path=True, level=1):
diff --git a/Lib/packaging/command/sdist.py b/Lib/packaging/command/sdist.py
--- a/Lib/packaging/command/sdist.py
+++ b/Lib/packaging/command/sdist.py
@@ -337,12 +337,11 @@
         """
         return self.archive_files
 
-    def create_tree(self, base_dir, files, mode=0o777, verbose=1,
-                    dry_run=False):
+    def create_tree(self, base_dir, files, mode=0o777, dry_run=False):
         need_dir = set()
         for file in files:
             need_dir.add(os.path.join(base_dir, os.path.dirname(file)))
 
         # Now create them
         for dir in sorted(need_dir):
-            self.mkpath(dir, mode, verbose=verbose, dry_run=dry_run)
+            self.mkpath(dir, mode, dry_run=dry_run)
diff --git a/Lib/packaging/command/test.py b/Lib/packaging/command/test.py
--- a/Lib/packaging/command/test.py
+++ b/Lib/packaging/command/test.py
@@ -60,8 +60,7 @@
             self.run_command('build')
             sys.path.insert(0, build.build_lib)
 
-            # Temporary kludge until we remove the verbose arguments and use
-            # logging everywhere
+            # XXX maybe we could pass the verbose argument of pysetup here
             logger = logging.getLogger('packaging')
             verbose = logger.getEffectiveLevel() >= logging.DEBUG
             verbosity = verbose + 1
diff --git a/Lib/packaging/compiler/__init__.py b/Lib/packaging/compiler/__init__.py
--- a/Lib/packaging/compiler/__init__.py
+++ b/Lib/packaging/compiler/__init__.py
@@ -153,8 +153,7 @@
     pretty_printer.print_help("List of available compilers:")
 
 
-def new_compiler(plat=None, compiler=None, verbose=0, dry_run=False,
-                 force=False):
+def new_compiler(plat=None, compiler=None, dry_run=False, force=False):
     """Generate an instance of some CCompiler subclass for the supplied
     platform/compiler combination.  'plat' defaults to 'os.name'
     (eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
@@ -183,11 +182,7 @@
         cls = resolve_name(cls)
         _COMPILERS[compiler] = cls
 
-
-    # XXX The None is necessary to preserve backwards compatibility
-    # with classes that expect verbose to be the first positional
-    # argument.
-    return cls(None, dry_run, force)
+    return cls(dry_run, force)
 
 
 def gen_preprocess_options(macros, include_dirs):
diff --git a/Lib/packaging/compiler/bcppcompiler.py b/Lib/packaging/compiler/bcppcompiler.py
--- a/Lib/packaging/compiler/bcppcompiler.py
+++ b/Lib/packaging/compiler/bcppcompiler.py
@@ -47,8 +47,8 @@
     exe_extension = '.exe'
 
 
-    def __init__(self, verbose=0, dry_run=False, force=False):
-        super(BCPPCompiler, self).__init__(verbose, dry_run, force)
+    def __init__(self, dry_run=False, force=False):
+        super(BCPPCompiler, self).__init__(dry_run, force)
 
         # These executables are assumed to all be in the path.
         # Borland doesn't seem to use any special registry settings to
diff --git a/Lib/packaging/compiler/ccompiler.py b/Lib/packaging/compiler/ccompiler.py
--- a/Lib/packaging/compiler/ccompiler.py
+++ b/Lib/packaging/compiler/ccompiler.py
@@ -79,10 +79,9 @@
                    }
     language_order = ["c++", "objc", "c"]
 
-    def __init__(self, verbose=0, dry_run=False, force=False):
+    def __init__(self, dry_run=False, force=False):
         self.dry_run = dry_run
         self.force = force
-        self.verbose = verbose
 
         # 'output_dir': a common output directory for object, library,
         # shared object, and shared library files
diff --git a/Lib/packaging/compiler/cygwinccompiler.py b/Lib/packaging/compiler/cygwinccompiler.py
--- a/Lib/packaging/compiler/cygwinccompiler.py
+++ b/Lib/packaging/compiler/cygwinccompiler.py
@@ -92,8 +92,8 @@
     shared_lib_format = "%s%s"
     exe_extension = ".exe"
 
-    def __init__(self, verbose=0, dry_run=False, force=False):
-        super(CygwinCCompiler, self).__init__(verbose, dry_run, force)
+    def __init__(self, dry_run=False, force=False):
+        super(CygwinCCompiler, self).__init__(dry_run, force)
 
         status, details = check_config_h()
         logger.debug("Python's GCC status: %s (details: %s)", status, details)
@@ -270,8 +270,8 @@
     name = 'mingw32'
     description = 'MinGW32 compiler'
 
-    def __init__(self, verbose=0, dry_run=False, force=False):
-        super(Mingw32CCompiler, self).__init__(verbose, dry_run, force)
+    def __init__(self, dry_run=False, force=False):
+        super(Mingw32CCompiler, self).__init__(dry_run, force)
 
         # ld_version >= "2.13" support -shared so use it instead of
         # -mdll -static
diff --git a/Lib/packaging/compiler/msvc9compiler.py b/Lib/packaging/compiler/msvc9compiler.py
--- a/Lib/packaging/compiler/msvc9compiler.py
+++ b/Lib/packaging/compiler/msvc9compiler.py
@@ -309,8 +309,8 @@
     static_lib_format = shared_lib_format = '%s%s'
     exe_extension = '.exe'
 
-    def __init__(self, verbose=0, dry_run=False, force=False):
-        super(MSVCCompiler, self).__init__(verbose, dry_run, force)
+    def __init__(self, dry_run=False, force=False):
+        super(MSVCCompiler, self).__init__(dry_run, force)
         self.__version = VERSION
         self.__root = r"Software\Microsoft\VisualStudio"
         # self.__macros = MACROS
diff --git a/Lib/packaging/compiler/msvccompiler.py b/Lib/packaging/compiler/msvccompiler.py
--- a/Lib/packaging/compiler/msvccompiler.py
+++ b/Lib/packaging/compiler/msvccompiler.py
@@ -236,8 +236,8 @@
     static_lib_format = shared_lib_format = '%s%s'
     exe_extension = '.exe'
 
-    def __init__(self, verbose=0, dry_run=False, force=False):
-        super(MSVCCompiler, self).__init__(verbose, dry_run, force)
+    def __init__(self, dry_run=False, force=False):
+        super(MSVCCompiler, self).__init__(dry_run, force)
         self.__version = get_build_version()
         self.__arch = get_build_architecture()
         if self.__arch == "Intel":
diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py
--- a/Lib/packaging/util.py
+++ b/Lib/packaging/util.py
@@ -259,7 +259,7 @@
             if element]
 
 
-def execute(func, args, msg=None, verbose=0, dry_run=False):
+def execute(func, args, msg=None, dry_run=False):
     """Perform some action that affects the outside world.
 
     Some actions (e.g. writing to the filesystem) are special because
@@ -681,7 +681,7 @@
     _cfg_target_split = None
 
 
-def spawn(cmd, search_path=True, verbose=0, dry_run=False, env=None):
+def spawn(cmd, search_path=True, dry_run=False, env=None):
     """Run another program specified as a command list 'cmd' in a new process.
 
     'cmd' is just the argument list for the new process, ie.
@@ -1331,8 +1331,7 @@
 
 # XXX to be replaced by shutil.copytree
 def copy_tree(src, dst, preserve_mode=True, preserve_times=True,
-              preserve_symlinks=False, update=False, verbose=True,
-              dry_run=False):
+              preserve_symlinks=False, update=False, dry_run=False):
     # FIXME use of this function is why we get spurious logging message on
     # stdout when tests run; kill and replace by shutil!
     from distutils.file_util import copy_file
@@ -1351,7 +1350,7 @@
                   "error listing files in '%s': %s" % (src, errstr))
 
     if not dry_run:
-        _mkpath(dst, verbose=verbose)
+        _mkpath(dst)
 
     outputs = []
 
@@ -1361,8 +1360,7 @@
 
         if preserve_symlinks and os.path.islink(src_name):
             link_dest = os.readlink(src_name)
-            if verbose >= 1:
-                logger.info("linking %s -> %s", dst_name, link_dest)
+            logger.info("linking %s -> %s", dst_name, link_dest)
             if not dry_run:
                 os.symlink(link_dest, dst_name)
             outputs.append(dst_name)
@@ -1371,11 +1369,10 @@
             outputs.extend(
                 copy_tree(src_name, dst_name, preserve_mode,
                           preserve_times, preserve_symlinks, update,
-                          verbose=verbose, dry_run=dry_run))
+                          dry_run=dry_run))
         else:
             copy_file(src_name, dst_name, preserve_mode,
-                      preserve_times, update, verbose=verbose,
-                      dry_run=dry_run)
+                      preserve_times, update, dry_run=dry_run)
             outputs.append(dst_name)
 
     return outputs
@@ -1388,7 +1385,7 @@
 # I don't use os.makedirs because a) it's new to Python 1.5.2, and
 # b) it blows up if the directory already exists (I want to silently
 # succeed in that case).
-def _mkpath(name, mode=0o777, verbose=True, dry_run=False):
+def _mkpath(name, mode=0o777, dry_run=False):
     # Detect a common bug -- name is None
     if not isinstance(name, str):
         raise PackagingInternalError(
@@ -1423,9 +1420,7 @@
         if abs_head in _path_created:
             continue
 
-        if verbose >= 1:
-            logger.info("creating %s", head)
-
+        logger.info("creating %s", head)
         if not dry_run:
             try:
                 os.mkdir(head, mode)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list