[Python-checkins] distutils2: Remove display options (--name, etc.) from the Distribution class.

eric.araujo python-checkins at python.org
Mon Sep 19 15:12:39 CEST 2011


http://hg.python.org/distutils2/rev/9728bc6fd11f
changeset: 1164:9728bc6fd11f
user: Éric Araujo <merwok at netwok.org>
date: Mon Sep 19 03:44:02 2011 +0200
summary:
 Remove display options (--name, etc.) from the Distribution class.
These options were used to implement “setup.py --name”,
“setup.py --version”, etc. which are now handled by the pysetup metadata
action or direct parsing of the setup.cfg file.
As a side effect, the Distribution class no longer accepts a 'url' key
in its *attrs* argument: it has to be 'home_page' or 'home-page' to be
recognized as a valid metadata field and passed down to the
dist.metadata object.
files:
 distutils2/dist.py | 63 +--------
 distutils2/tests/test_command_bdist_dumb.py | 2 +-
 distutils2/tests/test_command_register.py | 2 +-
 distutils2/tests/test_command_sdist.py | 2 +-
 distutils2/tests/test_dist.py | 17 +-
 5 files changed, 21 insertions(+), 65 deletions(-)
diff --git a/distutils2/dist.py b/distutils2/dist.py
--- a/distutils2/dist.py
+++ b/distutils2/dist.py
@@ -42,7 +42,7 @@
 
 # 'global_options' describes the command-line options that may be
 # supplied to the setup script prior to any actual commands.
- # Eg. "pysetup -n" or "pysetup --dry-run" both take advantage of
+ # Eg. "pysetup run -n" or "pysetup run --dry-run" both take advantage of
 # these global options. This list should be kept to a bare minimum,
 # since every global option is also valid as a command option -- and we
 # don't want to pollute the commands with too many options that they
@@ -66,47 +66,6 @@
 display_options = [
 ('help-commands', None,
 "list all available commands"),
- # XXX this is obsoleted by the pysetup metadata action
- ('name', None,
- "print package name"),
- ('version', 'V',
- "print package version"),
- ('fullname', None,
- "print <package name>-<version>"),
- ('author', None,
- "print the author's name"),
- ('author-email', None,
- "print the author's email address"),
- ('maintainer', None,
- "print the maintainer's name"),
- ('maintainer-email', None,
- "print the maintainer's email address"),
- ('contact', None,
- "print the maintainer's name if known, else the author's"),
- ('contact-email', None,
- "print the maintainer's email address if known, else the author's"),
- ('url', None,
- "print the URL for this package"),
- ('license', None,
- "print the license of the package"),
- ('licence', None,
- "alias for --license"),
- ('description', None,
- "print the package description"),
- ('long-description', None,
- "print the long package description"),
- ('platforms', None,
- "print the list of platforms"),
- ('classifier', None,
- "print the list of classifiers"),
- ('keywords', None,
- "print the list of keywords"),
- ('provides', None,
- "print the list of packages/modules provided"),
- ('requires', None,
- "print the list of packages/modules required"),
- ('obsoletes', None,
- "print the list of packages/modules made obsolete"),
 ('use-2to3', None,
 "use 2to3 to make source python 3.x compatible"),
 ('convert-2to3-doctests', None,
@@ -342,7 +301,6 @@
 self.commands = []
 parser = FancyGetopt(toplevel_options + self.display_options)
 parser.set_negative_aliases(self.negative_opt)
- parser.set_aliases({'licence': 'license'})
 args = parser.getopt(args=self.script_args, object=self)
 option_order = parser.get_option_order()
 
@@ -491,7 +449,7 @@
 
 If 'global_options' is true, lists the global options:
 --dry-run, etc. If 'display_options' is true, lists
- the "display-only" options: --name, --version, etc. Finally,
+ the "display-only" options: --help-commands. Finally,
 lists per-command help for every command name or command class
 in 'commands'.
 """
@@ -528,9 +486,8 @@
 
 def handle_display_options(self, option_order):
 """If there were any non-global "display-only" options
- (--help-commands or the metadata display options) on the command
- line, display the requested info and return true; else return
- false.
+ (--help-commands) on the command line, display the requested info and
+ return true; else return false.
 """
 # User just wants a list of commands -- we'll print it out and stop
 # processing now (ie. if they ran "setup --help-commands foo bar",
@@ -539,7 +496,7 @@
 self.print_commands()
 print
 print gen_usage(self.script_name)
- return 1
+ return True
 
 # If user supplied any of the "display metadata" options, then
 # display that metadata in the order in which the user supplied the
@@ -627,14 +584,14 @@
 cmd_obj = self.command_obj[command] = cls(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.)
+ # Set any options that were supplied in config files or on the
+ # command line. (XXX support for error reporting is suboptimal
+ # here: 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:
 self._set_command_options(cmd_obj, options)
+
 return cmd_obj
 
 def _set_command_options(self, command_obj, option_dict=None):
diff --git a/distutils2/tests/test_command_bdist_dumb.py b/distutils2/tests/test_command_bdist_dumb.py
--- a/distutils2/tests/test_command_bdist_dumb.py
+++ b/distutils2/tests/test_command_bdist_dumb.py
@@ -35,7 +35,7 @@
 
 dist = Distribution({'name': 'foo', 'version': '0.1',
 'py_modules': ['foo'],
- 'url': 'xxx', 'author': 'xxx',
+ 'home_page': 'xxx', 'author': 'xxx',
 'author_email': 'xxx'})
 os.chdir(pkg_dir)
 cmd = bdist_dumb(dist)
diff --git a/distutils2/tests/test_command_register.py b/distutils2/tests/test_command_register.py
--- a/distutils2/tests/test_command_register.py
+++ b/distutils2/tests/test_command_register.py
@@ -97,7 +97,7 @@
 
 def _get_cmd(self, metadata=None):
 if metadata is None:
- metadata = {'url': 'xxx', 'author': 'xxx',
+ metadata = {'home_page': 'xxx', 'author': 'xxx',
 'author_email': 'xxx',
 'name': 'xxx', 'version': 'xxx'}
 pkg_info, dist = self.create_dist(**metadata)
diff --git a/distutils2/tests/test_command_sdist.py b/distutils2/tests/test_command_sdist.py
--- a/distutils2/tests/test_command_sdist.py
+++ b/distutils2/tests/test_command_sdist.py
@@ -72,7 +72,7 @@
 """Returns a cmd"""
 if metadata is None:
 metadata = {'name': 'fake', 'version': '1.0',
- 'url': 'xxx', 'author': 'xxx',
+ 'home_page': 'xxx', 'author': 'xxx',
 'author_email': 'xxx'}
 dist = Distribution(metadata)
 dist.packages = ['somecode']
diff --git a/distutils2/tests/test_dist.py b/distutils2/tests/test_dist.py
--- a/distutils2/tests/test_dist.py
+++ b/distutils2/tests/test_dist.py
@@ -108,17 +108,17 @@
 Distribution(attrs={'author': 'xxx',
 'name': 'xxx',
 'version': '1.2',
- 'url': 'xxxx',
+ 'home_page': 'xxxx',
 'badoptname': 'xxx'})
 logs = self.get_logs(logging.WARNING)
- self.assertEqual(1, len(logs))
+ self.assertEqual(len(logs), 1)
 self.assertIn('unknown argument', logs[0])
 
 def test_bad_version(self):
 Distribution(attrs={'author': 'xxx',
 'name': 'xxx',
 'version': 'xxx',
- 'url': 'xxxx'})
+ 'home_page': 'xxxx'})
 logs = self.get_logs(logging.WARNING)
 self.assertEqual(1, len(logs))
 self.assertIn('not a valid version', logs[0])
@@ -126,13 +126,12 @@
 def test_empty_options(self):
 # an empty options dictionary should not stay in the
 # list of attributes
- Distribution(attrs={'author': 'xxx',
- 'name': 'xxx',
- 'version': '1.2',
- 'url': 'xxxx',
- 'options': {}})
+ dist = Distribution(attrs={'author': 'xxx', 'name': 'xxx',
+ 'version': '1.2', 'home_page': 'xxxx',
+ 'options': {}})
 
 self.assertEqual([], self.get_logs(logging.WARNING))
+ self.assertNotIn('options', dir(dist))
 
 def test_non_empty_options(self):
 # TODO: how to actually use options is not documented except
@@ -145,7 +144,7 @@
 dist = Distribution(attrs={'author': 'xxx',
 'name': 'xxx',
 'version': 'xxx',
- 'url': 'xxxx',
+ 'home_page': 'xxxx',
 'options': {'sdist': {'owner': 'root'}}})
 
 self.assertIn('owner', dist.get_option_dict('sdist'))
-- 
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /