[Python-checkins] CVS: distutils/distutils cmd.py,1.5,1.6 dist.py,1.3,1.4 errors.py,1.5,1.6 msvccompiler.py,1.25,1.26 util.py,1.27,1.28
Greg Ward
python-dev@python.org
2000年4月15日 18:15:10 -0400 (EDT)
Update of /projects/cvsroot/distutils/distutils
In directory kaluha:/tmp/cvs-serv8562
Modified Files:
cmd.py dist.py errors.py msvccompiler.py util.py
Log Message:
Cleaned up/simplified error-handling:
- DistutilsOptionError is now documented as it's actually used, ie.
to indicate bogus option values (usually user options, eg. from
the command-line)
- added DistutilsSetupError to indicate errors that definitely arise
in the setup script
- got rid of DistutilsValueError, and changed all usage of it to
either DistutilsSetupError or ValueError as appropriate
- simplified a bunch of option get/set methods in Command and
Distribution classes -- just pass on AttributeError most of
the time, rather than turning it into something else
Index: cmd.py
===================================================================
RCS file: /projects/cvsroot/distutils/distutils/cmd.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** cmd.py 2000年04月10日 13:11:51 1.5
--- cmd.py 2000年04月15日 22:15:07 1.6
***************
*** 7,11 ****
# (extricated from core.py; actually dates back to the beginning)
! __revision__ = "$Id: cmd.py,v 1.5 2000年04月10日 13:11:51 gward Exp $"
import sys, string
--- 7,11 ----
# (extricated from core.py; actually dates back to the beginning)
! __revision__ = "$Id: cmd.py,v 1.6 2000年04月15日 22:15:07 gward Exp $"
import sys, string
***************
*** 162,197 ****
def get_option (self, option):
"""Return the value of a single option for this command. Raise
! DistutilsOptionError if 'option' is not known."""
! try:
! return getattr (self, option)
! except AttributeError:
! raise DistutilsOptionError, \
! "command %s: no such option %s" % \
! (self.get_command_name(), option)
def get_options (self, *options):
"""Return (as a tuple) the values of several options for this
! command. Raise DistutilsOptionError if any of the options in
'options' are not known."""
values = []
! try:
! for opt in options:
! values.append (getattr (self, opt))
! except AttributeError, name:
! raise DistutilsOptionError, \
! "command %s: no such option %s" % \
! (self.get_command_name(), name)
!
return tuple (values)
!
def set_option (self, option, value):
"""Set the value of a single option for this command. Raise
! DistutilsOptionError if 'option' is not known."""
if not hasattr (self, option):
! raise DistutilsOptionError, \
"command '%s': no such option '%s'" % \
(self.get_command_name(), option)
--- 162,187 ----
def get_option (self, option):
"""Return the value of a single option for this command. Raise
! AttributeError if 'option' is not known."""
! return getattr (self, option)
def get_options (self, *options):
"""Return (as a tuple) the values of several options for this
! command. Raise AttributeError if any of the options in
'options' are not known."""
values = []
! for opt in options:
! values.append (getattr (self, opt))
!
return tuple (values)
!
def set_option (self, option, value):
"""Set the value of a single option for this command. Raise
! AttributeError if 'option' is not known."""
if not hasattr (self, option):
! raise AttributeError, \
"command '%s': no such option '%s'" % \
(self.get_command_name(), option)
***************
*** 201,205 ****
def set_options (self, **optval):
"""Set the values of several options for this command. Raise
! DistutilsOptionError if any of the options specified as
keyword arguments are not known."""
--- 191,195 ----
def set_options (self, **optval):
"""Set the values of several options for this command. Raise
! AttributeError if any of the options specified as
keyword arguments are not known."""
***************
*** 237,248 ****
src_cmd_obj = self.distribution.find_command_obj (src_cmd)
src_cmd_obj.ensure_ready ()
! try:
! for (src_option, dst_option) in option_pairs:
! if getattr (self, dst_option) is None:
! self.set_option (dst_option,
! src_cmd_obj.get_option (src_option))
! except AttributeError, name:
! # duh, which command?
! raise DistutilsOptionError, "unknown option %s" % name
--- 227,234 ----
src_cmd_obj = self.distribution.find_command_obj (src_cmd)
src_cmd_obj.ensure_ready ()
! for (src_option, dst_option) in option_pairs:
! if getattr (self, dst_option) is None:
! self.set_option (dst_option,
! src_cmd_obj.get_option (src_option))
Index: dist.py
===================================================================
RCS file: /projects/cvsroot/distutils/distutils/dist.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** dist.py 2000年04月10日 00:18:16 1.3
--- dist.py 2000年04月15日 22:15:07 1.4
***************
*** 7,11 ****
# (extricated from core.py; actually dates back to the beginning)
! __revision__ = "$Id: dist.py,v 1.3 2000年04月10日 00:18:16 gward Exp $"
import sys, string, re
--- 7,11 ----
# (extricated from core.py; actually dates back to the beginning)
! __revision__ = "$Id: dist.py,v 1.4 2000年04月15日 22:15:07 gward Exp $"
import sys, string, re
***************
*** 153,157 ****
setattr (self, key, val)
else:
! raise DistutilsOptionError, \
"invalid distribution option '%s'" % key
--- 153,157 ----
setattr (self, key, val)
else:
! raise DistutilsSetupError, \
"invalid distribution option '%s'" % key
***************
*** 448,472 ****
def get_option (self, option):
"""Return the value of a distribution option. Raise
! DistutilsOptionError if 'option' is not known."""
- try:
- return getattr (self, opt)
- except AttributeError:
- raise DistutilsOptionError, \
- "unknown distribution option %s" % option
-
def get_options (self, *options):
"""Return (as a tuple) the values of several distribution
! options. Raise DistutilsOptionError if any element of
'options' is not known."""
values = []
! try:
! for opt in options:
! values.append (getattr (self, opt))
! except AttributeError, name:
! raise DistutilsOptionError, \
! "unknown distribution option %s" % name
return tuple (values)
--- 448,463 ----
def get_option (self, option):
"""Return the value of a distribution option. Raise
! AttributeError if 'option' is not known."""
! return getattr (self, opt)
def get_options (self, *options):
"""Return (as a tuple) the values of several distribution
! options. Raise AttributeError if any element of
'options' is not known."""
values = []
! for opt in options:
! values.append (getattr (self, opt))
return tuple (values)
***************
*** 499,503 ****
"""Create a command object for 'command' if necessary, ensure that
its option values are all set to their final values, and return
! the value of its 'option' option. Raise DistutilsOptionError if
'option' is not known for that 'command'."""
--- 490,494 ----
"""Create a command object for 'command' if necessary, ensure that
its option values are all set to their final values, and return
! the value of its 'option' option. Raise AttributeError if
'option' is not known for that 'command'."""
***************
*** 505,513 ****
cmd_obj.ensure_ready ()
return cmd_obj.get_option (option)
- try:
- return getattr (cmd_obj, option)
- except AttributeError:
- raise DistutilsOptionError, \
- "command %s: no such option %s" % (command, option)
--- 496,499 ----
***************
*** 522,531 ****
cmd_obj.ensure_ready ()
values = []
! try:
! for opt in options:
! values.append (getattr (cmd_obj, option))
! except AttributeError, name:
! raise DistutilsOptionError, \
! "command %s: no such option %s" % (command, name)
return tuple (values)
--- 508,513 ----
cmd_obj.ensure_ready ()
values = []
! for opt in options:
! values.append (getattr (cmd_obj, option))
return tuple (values)
Index: errors.py
===================================================================
RCS file: /projects/cvsroot/distutils/distutils/errors.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** errors.py 2000年03月31日 02:57:31 1.5
--- errors.py 2000年04月15日 22:15:07 1.6
***************
*** 11,15 ****
# created 1999年03月03日, Greg Ward
! __revision__ = "$Id: errors.py,v 1.5 2000年03月31日 02:57:31 gward Exp $"
import types
--- 11,15 ----
# created 1999年03月03日, Greg Ward
! __revision__ = "$Id: errors.py,v 1.6 2000年04月15日 22:15:07 gward Exp $"
import types
***************
*** 47,59 ****
pass
! # DistutilsOptionError is raised anytime an attempt is made to access
! # (get or set) an option that does not exist for a particular command
! # (or for the distribution itself).
class DistutilsOptionError (DistutilsError):
pass
! # DistutilsValueError is raised anytime an option value (presumably
! # provided by setup.py) is invalid.
! class DistutilsValueError (DistutilsError):
pass
--- 47,62 ----
pass
! # DistutilsOptionError is raised for syntactic/semantic errors in
! # command options, such as use of mutually conflicting options, or
! # inconsistent options, badly-spelled values, etc. No distinction is
! # made between option values originating in the setup script, the
! # command line, config files, or what-have-you.
class DistutilsOptionError (DistutilsError):
pass
! # DistutilsSetupError is raised for errors that can be definitely
! # blamed on the setup script, such as invalid keyword arguments to
! # 'setup()'.
! class DistutilsSetupError (DistutilsError):
pass
***************
*** 83,87 ****
DistutilsFileError = 'DistutilsFileError'
DistutilsOptionError = 'DistutilsOptionError'
- DistutilsValueError = 'DistutilsValueError'
DistutilsPlatformError = 'DistutilsPlatformError'
DistutilsExecError = 'DistutilsExecError'
--- 86,89 ----
Index: msvccompiler.py
===================================================================
RCS file: /projects/cvsroot/distutils/distutils/msvccompiler.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** msvccompiler.py 2000年03月31日 19:04:25 1.25
--- msvccompiler.py 2000年04月15日 22:15:07 1.26
***************
*** 9,13 ****
# finding DevStudio (through the registry)
! __revision__ = "$Id: msvccompiler.py,v 1.25 2000年03月31日 19:04:25 gward Exp $"
import sys, os, string
--- 9,13 ----
# finding DevStudio (through the registry)
! __revision__ = "$Id: msvccompiler.py,v 1.26 2000年04月15日 22:15:07 gward Exp $"
import sys, os, string
***************
*** 361,364 ****
--- 361,367 ----
ld_args.extend (extra_postargs)
+ print "link_shared_object():"
+ print " output_filename =", output_filename
+ print " mkpath'ing:", os.path.dirname (output_filename)
self.mkpath (os.path.dirname (output_filename))
self.spawn ([self.link] + ld_args)
Index: util.py
===================================================================
RCS file: /projects/cvsroot/distutils/distutils/util.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** util.py 2000年04月04日 02:05:59 1.27
--- util.py 2000年04月15日 22:15:07 1.28
***************
*** 6,10 ****
# created 1999年03月08日, Greg Ward
! __revision__ = "$Id: util.py,v 1.27 2000年04月04日 02:05:59 gward Exp $"
import sys, os, string, re, shutil
--- 6,10 ----
# created 1999年03月08日, Greg Ward
! __revision__ = "$Id: util.py,v 1.28 2000年04月15日 22:15:07 gward Exp $"
import sys, os, string, re, shutil
***************
*** 41,54 ****
the setup script are always supplied in Unix style, and have to be
converted to the local convention before we can actually use them in
! the filesystem. Raises DistutilsValueError if 'pathname' is
absolute (starts with '/') or contains local directory separators
(unless the local separator is '/', of course)."""
if pathname[0] == '/':
! raise DistutilsValueError, "path '%s' cannot be absolute" % pathname
if pathname[-1] == '/':
! raise DistutilsValueError, "path '%s' cannot end with '/'" % pathname
if os.sep != '/' and os.sep in pathname:
! raise DistutilsValueError, \
"path '%s' cannot contain '%c' character" % \
(pathname, os.sep)
--- 41,54 ----
the setup script are always supplied in Unix style, and have to be
converted to the local convention before we can actually use them in
! the filesystem. Raises ValueError if 'pathname' is
absolute (starts with '/') or contains local directory separators
(unless the local separator is '/', of course)."""
if pathname[0] == '/':
! raise ValueError, "path '%s' cannot be absolute" % pathname
if pathname[-1] == '/':
! raise ValueError, "path '%s' cannot end with '/'" % pathname
if os.sep != '/' and os.sep in pathname:
! raise ValueError, \
"path '%s' cannot contain '%c' character" % \
(pathname, os.sep)