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.
This commit is contained in:
Jeremy Hylton 2002-06-04 20:14:43 +00:00
parent 6fa82a3477
commit cd8a1148e1
32 changed files with 260 additions and 313 deletions

View file

@ -37,27 +37,19 @@ class FileList:
def __init__(self,
warn=None,
debug_print=None):
# use standard warning and debug functions if no other given
self.warn = warn or self.__warn
self.debug_print = debug_print or self.__debug_print
# ignore argument to FileList, but keep them for backwards
# compatibility
self.allfiles = None
self.files = []
def set_allfiles (self, allfiles):
self.allfiles = allfiles
def findall (self, dir=os.curdir):
self.allfiles = findall(dir)
# -- Fallback warning/debug functions ------------------------------
def __warn (self, msg):
sys.stderr.write("warning: %s\n" % msg)
def __debug_print (self, msg):
def debug_print (self, msg):
"""Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
"""
@ -65,7 +57,6 @@ class FileList:
if DEBUG:
print msg
# -- List-like methods ---------------------------------------------
def append (self, item):
@ -87,8 +78,8 @@ class FileList:
def remove_duplicates (self):
# Assumes list has been sorted!
for i in range(len(self.files)-1, 0, -1):
if self.files[i] == self.files[i-1]:
for i in range(len(self.files) - 1, 0, -1):
if self.files[i] == self.files[i - 1]:
del self.files[i]
@ -147,61 +138,60 @@ class FileList:
self.debug_print("include " + string.join(patterns))
for pattern in patterns:
if not self.include_pattern(pattern, anchor=1):
self.warn("no files found matching '%s'" % pattern)
log.warn("warning: no files found matching '%s'",
pattern)
elif action == 'exclude':
self.debug_print("exclude " + string.join(patterns))
for pattern in patterns:
if not self.exclude_pattern(pattern, anchor=1):
self.warn(
"no previously-included files found matching '%s'"%
pattern)
log.warn(("warning: no previously-included files "
"found matching '%s'"), pattern)
elif action == 'global-include':
self.debug_print("global-include " + string.join(patterns))
for pattern in patterns:
if not self.include_pattern(pattern, anchor=0):
self.warn(("no files found matching '%s' " +
"anywhere in distribution") %
pattern)
log.warn(("warning: no files found matching '%s' " +
"anywhere in distribution"), pattern)
elif action == 'global-exclude':
self.debug_print("global-exclude " + string.join(patterns))
for pattern in patterns:
if not self.exclude_pattern(pattern, anchor=0):
self.warn(("no previously-included files matching '%s' " +
"found anywhere in distribution") %
pattern)
log.warn(("warning: no previously-included files matching "
"'%s' found anywhere in distribution"),
pattern)
elif action == 'recursive-include':
self.debug_print("recursive-include %s %s" %
(dir, string.join(patterns)))
for pattern in patterns:
if not self.include_pattern(pattern, prefix=dir):
self.warn(("no files found matching '%s' " +
"under directory '%s'") %
(pattern, dir))
log.warn(("warngin: no files found matching '%s' " +
"under directory '%s'"),
pattern, dir)
elif action == 'recursive-exclude':
self.debug_print("recursive-exclude %s %s" %
(dir, string.join(patterns)))
for pattern in patterns:
if not self.exclude_pattern(pattern, prefix=dir):
self.warn(("no previously-included files matching '%s' " +
"found under directory '%s'") %
(pattern, dir))
log.warn(("warning: no previously-included files matching "
"'%s' found under directory '%s'"),
pattern, dir)
elif action == 'graft':
self.debug_print("graft " + dir_pattern)
if not self.include_pattern(None, prefix=dir_pattern):
self.warn("no directories found matching '%s'" % dir_pattern)
log.warn("warning: no directories found matching '%s'",
dir_pattern)
elif action == 'prune':
self.debug_print("prune " + dir_pattern)
if not self.exclude_pattern(None, prefix=dir_pattern):
self.warn(("no previously-included directories found " +
"matching '%s'") %
dir_pattern)
log.warn(("no previously-included directories found " +
"matching '%s'"), dir_pattern)
else:
raise DistutilsInternalError, \
"this cannot happen: invalid action '%s'" % action