Kaydet (Commit) 4d155465 authored tarafından Éric Araujo's avatar Éric Araujo

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.
üst 9b5c7f44
......@@ -842,6 +842,8 @@ Additionally, there's a ``global`` section for options that affect every command
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::
......
......@@ -15,7 +15,7 @@ function. Compiler types provided by Packaging are listed in
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 @@ link steps needed to build a single project. Methods are provided to set
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 @@ libraries and the like.
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.
......
......@@ -90,7 +90,7 @@ This module contains various helpers for the other modules.
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
......
......@@ -4,7 +4,6 @@ import os
import re
import sys
import site
import logging
import sysconfig
from packaging.util import get_platform
......@@ -288,14 +287,9 @@ class build_ext(Command):
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)
......
......@@ -351,7 +351,7 @@ class Command:
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 @@ class Command:
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 @@ class Command:
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 @@ class Command:
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):
......
......@@ -337,12 +337,11 @@ class sdist(Command):
"""
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)
......@@ -60,8 +60,7 @@ class test(Command):
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
......
......@@ -153,8 +153,7 @@ def show_compilers():
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 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=False,
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):
......
......@@ -47,8 +47,8 @@ class BCPPCompiler(CCompiler) :
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
......
......@@ -79,10 +79,9 @@ class CCompiler:
}
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
......
......@@ -92,8 +92,8 @@ class CygwinCCompiler(UnixCCompiler):
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 @@ class Mingw32CCompiler(CygwinCCompiler):
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
......
......@@ -309,8 +309,8 @@ class MSVCCompiler(CCompiler) :
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
......
......@@ -236,8 +236,8 @@ class MSVCCompiler(CCompiler):
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":
......
......@@ -259,7 +259,7 @@ def split_multiline(value):
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 @@ if sys.platform == 'darwin':
_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 @@ def get_install_method(path):
# 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 @@ def copy_tree(src, dst, preserve_mode=True, preserve_times=True,
"error listing files in '%s': %s" % (src, errstr))
if not dry_run:
_mkpath(dst, verbose=verbose)
_mkpath(dst)
outputs = []
......@@ -1361,8 +1360,7 @@ def copy_tree(src, dst, preserve_mode=True, preserve_times=True,
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 @@ def copy_tree(src, dst, preserve_mode=True, preserve_times=True,
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 @@ _path_created = set()
# 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 @@ def _mkpath(name, mode=0o777, verbose=True, dry_run=False):
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)
......
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