diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2002-06-04 20:14:43 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2002-06-04 20:14:43 (GMT) |
commit | cd8a1148e19116db109f27d26c02e1de536dc76e (patch) | |
tree | e3969bc16f8ef0c540f1d0e72fb0da711344d758 /Lib/distutils/archive_util.py | |
parent | 6fa82a34775576b90c8ec38e8968dfbb0b02e11d (diff) | |
download | cpython-cd8a1148e19116db109f27d26c02e1de536dc76e.zip cpython-cd8a1148e19116db109f27d26c02e1de536dc76e.tar.gz cpython-cd8a1148e19116db109f27d26c02e1de536dc76e.tar.bz2 |
Make setup.py less chatty by default.
This is a conservative version of SF patch 504889. It uses the log
module instead of calling print in various places, and it ignores the
verbose argument passed to many functions and set as an attribute on
some objects. Instead, it uses the verbosity set on the logger via
the command line.
The log module is now preferred over announce() and warn() methods
that exist only for backwards compatibility.
XXX This checkin changes a lot of modules that have no test suite and
aren't exercised by the Python build process. It will need
substantial testing.
Diffstat (limited to 'Lib/distutils/archive_util.py')
-rw-r--r-- | Lib/distutils/archive_util.py | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py index 58d9a06..47fac0c 100644 --- a/Lib/distutils/archive_util.py +++ b/Lib/distutils/archive_util.py @@ -11,6 +11,7 @@ import os from distutils.errors import DistutilsExecError from distutils.spawn import spawn from distutils.dir_util import mkpath +from distutils import log def make_tarball (base_name, base_dir, compress="gzip", verbose=0, dry_run=0): @@ -42,13 +43,13 @@ def make_tarball (base_name, base_dir, compress="gzip", "bad value for 'compress': must be None, 'gzip', or 'compress'" archive_name = base_name + ".tar" - mkpath(os.path.dirname(archive_name), verbose=verbose, dry_run=dry_run) + mkpath(os.path.dirname(archive_name), dry_run=dry_run) cmd = ["tar", "-cf", archive_name, base_dir] - spawn(cmd, verbose=verbose, dry_run=dry_run) + spawn(cmd, dry_run=dry_run) if compress: spawn([compress] + compress_flags[compress] + [archive_name], - verbose=verbose, dry_run=dry_run) + dry_run=dry_run) return archive_name + compress_ext[compress] else: return archive_name @@ -69,10 +70,10 @@ def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): # no changes needed! zip_filename = base_name + ".zip" - mkpath(os.path.dirname(zip_filename), verbose=verbose, dry_run=dry_run) + mkpath(os.path.dirname(zip_filename), dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], - verbose=verbose, dry_run=dry_run) + dry_run=dry_run) except DistutilsExecError: # XXX really should distinguish between "couldn't find @@ -89,10 +90,10 @@ def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): "could neither find a standalone zip utility nor " + "import the 'zipfile' module") % zip_filename - if verbose: - print "creating '%s' and adding '%s' to it" % \ - (zip_filename, base_dir) - + + log.info("creating '%s' and adding '%s' to it", + zip_filename, base_dir) + def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) @@ -141,8 +142,7 @@ def make_archive (base_name, format, """ save_cwd = os.getcwd() if root_dir is not None: - if verbose: - print "changing into '%s'" % root_dir + log.debug("changing into '%s'", root_dir) base_name = os.path.abspath(base_name) if not dry_run: os.chdir(root_dir) @@ -150,8 +150,7 @@ def make_archive (base_name, format, if base_dir is None: base_dir = os.curdir - kwargs = { 'verbose': verbose, - 'dry_run': dry_run } + kwargs = { 'dry_run': dry_run } try: format_info = ARCHIVE_FORMATS[format] @@ -164,8 +163,7 @@ def make_archive (base_name, format, filename = apply(func, (base_name, base_dir), kwargs) if root_dir is not None: - if verbose: - print "changing back to '%s'" % save_cwd + log.debug("changing back to '%s'", save_cwd) os.chdir(save_cwd) return filename |