diff options
Diffstat (limited to 'src/distutils2/dist.py')
| -rw-r--r-- | src/distutils2/dist.py | 76 |
1 files changed, 32 insertions, 44 deletions
diff --git a/src/distutils2/dist.py b/src/distutils2/dist.py index 31b3d33..55737a3 100644 --- a/src/distutils2/dist.py +++ b/src/distutils2/dist.py @@ -18,7 +18,6 @@ from distutils2.errors import (DistutilsOptionError, DistutilsArgError, from distutils2.fancy_getopt import FancyGetopt, translate_longopt from distutils2.util import check_environ, strtobool from distutils2 import log -from distutils2.debug import DEBUG from distutils2.metadata import DistributionMetadata # Regex to define acceptable Distutils command names. This is not *quite* @@ -28,7 +27,7 @@ from distutils2.metadata import DistributionMetadata command_re = re.compile (r'^[a-zA-Z]([a-zA-Z0-9_]*)$') -class Distribution: +class Distribution(object): """The core of the Distutils. Most of the work hiding behind 'setup' is really done within a Distribution instance, which farms the work out to the Distutils commands specified on the command line. @@ -145,10 +144,11 @@ Common commands: (see '--help-commands' for more) # information here (and enough command-line options) that it's # worth it. Also delegate 'get_XXX()' methods to the 'metadata' # object in a sneaky and underhanded (but efficient!) way. + self.metadata = DistributionMetadata() - for basename in self.metadata._METHOD_BASENAMES: - method_name = "get_" + basename - setattr(self, method_name, getattr(self.metadata, method_name)) + #for basename in self.metadata._METHOD_BASENAMES: + # method_name = "get_" + basename + # setattr(self, method_name, getattr(self.metadata, method_name)) # 'cmdclass' maps command names to class objects, so we # can 1) quickly figure out which class to instantiate when @@ -227,7 +227,7 @@ Common commands: (see '--help-commands' for more) # the setup script) to possibly override any or all of these # distribution options. - if attrs: + if attrs is not None: # Pull out the set of command options and work on them # specifically. Note that this order guarantees that aliased # command options will override any supplied redundantly @@ -240,22 +240,11 @@ Common commands: (see '--help-commands' for more) for (opt, val) in cmd_options.items(): opt_dict[opt] = ("setup script", val) - if 'licence' in attrs: - attrs['license'] = attrs['licence'] - del attrs['licence'] - msg = "'licence' distribution option is deprecated; use 'license'" - if warnings is not None: - warnings.warn(msg) - else: - sys.stderr.write(msg + "\n") - # Now work on the rest of the attributes. Any attribute that's # not already defined is invalid! - for (key, val) in attrs.items(): - if hasattr(self.metadata, "set_" + key): - getattr(self.metadata, "set_" + key)(val) - elif hasattr(self.metadata, key): - setattr(self.metadata, key, val) + for key, val in attrs.items(): + if self.metadata.is_metadata_field(key): + self.metadata[key] = val elif hasattr(self, key): setattr(self, key, val) else: @@ -294,6 +283,9 @@ Common commands: (see '--help-commands' for more) dict = self.command_options[command] = {} return dict + def get_fullname(self): + return self.metadata.get_fullname() + def dump_option_dicts(self, header=None, commands=None, indent=""): from pprint import pformat @@ -366,9 +358,7 @@ Common commands: (see '--help-commands' for more) if os.path.isfile(local_file): files.append(local_file) - if DEBUG: - self.announce("using config files: %s" % ', '.join(files)) - + log.debug("using config files: %s" % ', '.join(files)) return files def parse_config_files(self, filenames=None): @@ -377,13 +367,11 @@ Common commands: (see '--help-commands' for more) if filenames is None: filenames = self.find_config_files() - if DEBUG: - self.announce("Distribution.parse_config_files():") + log.debug("Distribution.parse_config_files():") parser = ConfigParser() for filename in filenames: - if DEBUG: - self.announce(" reading %s" % filename) + log.debug(" reading %s" % filename) parser.read(filename) for section in parser.sections(): options = parser.options(section) @@ -593,13 +581,15 @@ Common commands: (see '--help-commands' for more) instance, analogous to the .finalize_options() method of Command objects. """ - for attr in ('keywords', 'platforms'): - value = getattr(self.metadata, attr) - if value is None: - continue - if isinstance(value, str): - value = [elm.strip() for elm in value.split(',')] - setattr(self.metadata, attr, value) + + # XXX conversion -- removed + #for attr in ('keywords', 'platforms'): + # value = self.metadata.get_field(attr) + # if value is None: + # continue + # if isinstance(value, str): + # value = [elm.strip() for elm in value.split(',')] + # setattr(self.metadata, attr, value) def _show_help(self, parser, global_options=1, display_options=1, commands=[]): @@ -676,11 +666,11 @@ Common commands: (see '--help-commands' for more) for option in self.display_options: is_display_option[option[0]] = 1 - for (opt, val) in option_order: + for opt, val in option_order: if val and is_display_option.get(opt): opt = translate_longopt(opt) - value = getattr(self.metadata, "get_"+opt)() - if opt in ['keywords', 'platforms']: + value = self.metadata[opt] + if opt in ['keywords', 'platform']: print(','.join(value)) elif opt in ('classifiers', 'provides', 'requires', 'obsoletes'): @@ -835,9 +825,8 @@ Common commands: (see '--help-commands' for more) """ cmd_obj = self.command_obj.get(command) if not cmd_obj and create: - if DEBUG: - self.announce("Distribution.get_command_obj(): " \ - "creating '%s' command object" % command) + log.debug("Distribution.get_command_obj(): " \ + "creating '%s' command object" % command) klass = self.get_command_class(command) cmd_obj = self.command_obj[command] = klass(self) @@ -867,11 +856,10 @@ Common commands: (see '--help-commands' for more) if option_dict is None: option_dict = self.get_option_dict(command_name) - if DEBUG: - self.announce(" setting options for '%s' command:" % command_name) + log.debug(" setting options for '%s' command:" % command_name) + for (option, (source, value)) in option_dict.items(): - if DEBUG: - self.announce(" %s = %s (from %s)" % (option, value, + log.debug(" %s = %s (from %s)" % (option, value, source)) try: bool_opts = map(translate_longopt, command_obj.boolean_options) |
