diff options
author | Greg Ward <gward@python.net> | 2000-05-23 03:47:35 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 2000-05-23 03:47:35 (GMT) |
commit | 474607777d10562679b1640d3831290b0c4284f7 (patch) | |
tree | 9d1f345ceb8196b750eacde1df62cd256aea202c | |
parent | 7cb42cd0700fa9a0f15a0f9ebf8a86383ffee105 (diff) | |
download | cpython-474607777d10562679b1640d3831290b0c4284f7.zip cpython-474607777d10562679b1640d3831290b0c4284f7.tar.gz cpython-474607777d10562679b1640d3831290b0c4284f7.tar.bz2 |
Fixed so options from config files and command lines actually work:
* 'get_command_obj()' now sets command attributes based on
the 'command_options' dictionary
* some typos fixed
* kludged 'parse_config_files()' to re-initialize the ConfigParser
instance after each file, so we know for sure which config
file each option comes form
* added lots of handy debugging output
-rw-r--r-- | Lib/distutils/dist.py | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py index 3fd29d9..3ceadf1 100644 --- a/Lib/distutils/dist.py +++ b/Lib/distutils/dist.py @@ -258,8 +258,11 @@ class Distribution: if filenames is None: filenames = self.find_config_files() + print "Distribution.parse_config_files():" + parser = ConfigParser() for filename in filenames: + print " reading", filename parser.read(filename) for section in parser.sections(): options = parser.options(section) @@ -271,9 +274,11 @@ class Distribution: if opt != '__name__': opts[opt] = (filename, parser.get(section,opt)) - from pprint import pprint - print "options (after parsing config files):" - pprint (self.command_options) + # Make the ConfigParser forget everything (so we retain + # the original filenames that options come from) -- gag, + # retch, puke -- another good reason for a distutils- + # specific config parser (sigh...) + parser.__init__() # -- Command-line parsing methods ---------------------------------- @@ -397,7 +402,7 @@ class Distribution: cmd_class.user_options) parser.set_negative_aliases (negative_opt) (args, opts) = parser.getopt (args[1:]) - if opts.help: + if hasattr(opts, 'help') and opts.help: print "showing help for command", cmd_class self._show_help(parser, display_options=0, commands=[cmd_class]) return @@ -408,7 +413,7 @@ class Distribution: self.command_options[command] = {} cmd_opts = self.command_options[command] for (name, value) in vars(opts).items(): - cmd_opts[command] = ("command line", value) + cmd_opts[name] = ("command line", value) return args @@ -605,9 +610,24 @@ class Distribution: """ cmd_obj = self.command_obj.get(command) if not cmd_obj and create: + print "Distribution.get_command_obj(): " \ + "creating '%s' command object" % command + klass = self.get_command_class(command) - cmd_obj = self.command_obj[command] = klass() - self.command_run[command] = 0 + cmd_obj = self.command_obj[command] = klass(self) + self.have_run[command] = 0 + + # Set any options that were supplied in config files + # or on the command line. (NB. support for error + # reporting is lame here: any errors aren't reported + # until 'finalize_options()' is called, which means + # we won't report the source of the error.) + options = self.command_options.get(command) + if options: + print " setting options:" + for (option, (source, value)) in options.items(): + print " %s = %s (from %s)" % (option, value, source) + setattr(cmd_obj, option, value) return cmd_obj |