diff options
author | Greg Ward <gward@python.net> | 2000-05-26 00:54:52 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 2000-05-26 00:54:52 (GMT) |
commit | 37af1c380714d6f67d99d84ce9c28759ecfd311c (patch) | |
tree | 01addfbabe618de0ab0856935624b58b5675ab73 /Lib/distutils/core.py | |
parent | 8bbba17d3815a44eefbd0cf33db937a56fe50db5 (diff) | |
download | cpython-37af1c380714d6f67d99d84ce9c28759ecfd311c.zip cpython-37af1c380714d6f67d99d84ce9c28759ecfd311c.tar.gz cpython-37af1c380714d6f67d99d84ce9c28759ecfd311c.tar.bz2 |
Added the DEBUG global (set from the DISTUTILS_DEBUG environment variable).
Changed the exception-handling code in 'setup()' to re-raise exceptions
if DEBUG is true.
Diffstat (limited to 'Lib/distutils/core.py')
-rw-r--r-- | Lib/distutils/core.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py index e22db93..cd0f8e9 100644 --- a/Lib/distutils/core.py +++ b/Lib/distutils/core.py @@ -27,6 +27,11 @@ usage: %s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] """ % ((os.path.basename(sys.argv[0]),) * 4) +# If DISTUTILS_DEBUG is anything other than the empty string, we run in +# debug mode. +DEBUG = os.environ.get('DISTUTILS_DEBUG') + + def setup (**attrs): """The gateway to the Distutils: do everything your setup script needs to do, in a highly flexible and user-driven way. Briefly: @@ -101,18 +106,26 @@ def setup (**attrs): # check for Python 1.5.2-style {IO,OS}Error exception objects if hasattr (exc, 'filename') and hasattr (exc, 'strerror'): if exc.filename: - raise SystemExit, \ - "error: %s: %s" % (exc.filename, exc.strerror) + error = "error: %s: %s" % (exc.filename, exc.strerror) else: # two-argument functions in posix module don't # include the filename in the exception object! - raise SystemExit, \ - "error: %s" % exc.strerror + error = "error: %s" % exc.strerror else: - raise SystemExit, "error: " + str(exc[-1]) + error = "error: " + str(exc[-1]) + + if DEBUG: + sys.stderr.write(error + "\n") + raise + else: + raise SystemExit, error + except (DistutilsExecError, DistutilsFileError, DistutilsOptionError), msg: - raise SystemExit, "error: " + str(msg) + if DEBUG: + raise + else: + raise SystemExit, "error: " + str(msg) # setup () |