summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/command
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2009-05-16 16:52:13 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2009-05-16 16:52:13 (GMT)
commit5af55c63607fb6bebfc95c57e6eda5db0c669b46 (patch)
tree13c4c08c3c60fbe5b79c1432145c1f0dc676070a /Lib/distutils/command
parentafdfbc72fb58dd01200573728e603b3da246c6e6 (diff)
downloadcpython-5af55c63607fb6bebfc95c57e6eda5db0c669b46.zip
cpython-5af55c63607fb6bebfc95c57e6eda5db0c669b46.tar.gz
cpython-5af55c63607fb6bebfc95c57e6eda5db0c669b46.tar.bz2
Merged revisions 72681 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72681 | tarek.ziade | 2009-05-16 18:37:06 +0200 (Sat, 16 May 2009) | 1 line #6041: sdist and register now use the check command. No more duplicate code for metadata checking ........
Diffstat (limited to 'Lib/distutils/command')
-rw-r--r--Lib/distutils/command/register.py57
-rw-r--r--Lib/distutils/command/sdist.py56
2 files changed, 51 insertions, 62 deletions
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index 7dd3099..bdf5f8f 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -10,6 +10,7 @@ __revision__ = "$Id$"
import os, string, getpass
import io
import urllib.parse, urllib.request
+from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
@@ -21,18 +22,34 @@ class register(PyPIRCCommand):
user_options = PyPIRCCommand.user_options + [
('list-classifiers', None,
'list the valid Trove classifiers'),
+ ('strict', None ,
+ 'Will stop the registering if the meta-data are not fully compliant')
]
boolean_options = PyPIRCCommand.boolean_options + [
- 'verify', 'list-classifiers']
+ 'verify', 'list-classifiers', 'strict']
+
+ sub_commands = [('check', lambda self: True)]
def initialize_options(self):
PyPIRCCommand.initialize_options(self)
self.list_classifiers = 0
+ self.strict = 0
+
+ def finalize_options(self):
+ PyPIRCCommand.finalize_options(self)
+ # setting options for the `check` subcommand
+ check_options = {'strict': ('register', self.strict),
+ 'restructuredtext': ('register', 1)}
+ self.distribution.command_options['check'] = check_options
def run(self):
self.finalize_options()
self._set_config()
- self.check_metadata()
+
+ # Run sub commands
+ for cmd_name in self.get_sub_commands():
+ self.run_command(cmd_name)
+
if self.dry_run:
self.verify_metadata()
elif self.list_classifiers:
@@ -41,34 +58,14 @@ class register(PyPIRCCommand):
self.send_metadata()
def check_metadata(self):
- """Ensure that all required elements of meta-data (name, version,
- URL, (author and author_email) or (maintainer and
- maintainer_email)) are supplied by the Distribution object; warn if
- any are missing.
- """
- metadata = self.distribution.metadata
-
- missing = []
- for attr in ('name', 'version', 'url'):
- if not (hasattr(metadata, attr) and getattr(metadata, attr)):
- missing.append(attr)
-
- if missing:
- self.warn("missing required meta-data: " +
- ", ".join(missing))
-
- if metadata.author:
- if not metadata.author_email:
- self.warn("missing meta-data: if 'author' supplied, " +
- "'author_email' must be supplied too")
- elif metadata.maintainer:
- if not metadata.maintainer_email:
- self.warn("missing meta-data: if 'maintainer' supplied, " +
- "'maintainer_email' must be supplied too")
- else:
- self.warn("missing meta-data: either (author and author_email) " +
- "or (maintainer and maintainer_email) " +
- "must be supplied")
+ """Deprecated API."""
+ warn("distutils.command.register.check_metadata is deprecated, \
+ use the check command instead", PendingDeprecationWarning)
+ check = self.distribution.get_command_obj('check')
+ check.ensure_finalized()
+ check.strict = self.strict
+ check.restructuredtext = 1
+ check.run()
def _set_config(self):
''' Reads the configuration file and set attributes.
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index cbb77c2..ace9eee 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -9,6 +9,8 @@ import string
import sys
from types import *
from glob import glob
+from warnings import warn
+
from distutils.core import Command
from distutils import dir_util, dep_util, file_util, archive_util
from distutils.text_file import TextFile
@@ -35,6 +37,12 @@ class sdist(Command):
description = "create a source distribution (tarball, zip file, etc.)"
+ def checking_metadata(self):
+ """Callable used for the check sub-command.
+
+ Placed here so user_options can view it"""
+ return self.metadata_check
+
user_options = [
('template=', 't',
"name of manifest template file [default: MANIFEST.in]"),
@@ -64,11 +72,14 @@ class sdist(Command):
('dist-dir=', 'd',
"directory to put the source distribution archive(s) in "
"[default: dist]"),
+ ('medata-check', None,
+ "Ensure that all required elements of meta-data "
+ "are supplied. Warn if any missing. [default]"),
]
boolean_options = ['use-defaults', 'prune',
'manifest-only', 'force-manifest',
- 'keep-temp']
+ 'keep-temp', 'metadata-check']
help_options = [
('help-formats', None,
@@ -81,6 +92,8 @@ class sdist(Command):
default_format = {'posix': 'gztar',
'nt': 'zip' }
+ sub_commands = [('check', checking_metadata)]
+
def initialize_options(self):
# 'template' and 'manifest' are, respectively, the names of
# the manifest template and manifest file.
@@ -100,6 +113,7 @@ class sdist(Command):
self.dist_dir = None
self.archive_files = None
+ self.metadata_check = 1
def finalize_options(self):
if self.manifest is None:
@@ -129,9 +143,9 @@ class sdist(Command):
# manifest
self.filelist = FileList()
- # Ensure that all required meta-data is given; warn if not (but
- # don't die, it's not *that* serious!)
- self.check_metadata()
+ # Run sub commands
+ for cmd_name in self.get_sub_commands():
+ self.run_command(cmd_name)
# Do whatever it takes to get the list of files to process
# (process the manifest template, read an existing manifest,
@@ -147,34 +161,12 @@ class sdist(Command):
self.make_distribution()
def check_metadata(self):
- """Ensure that all required elements of meta-data (name, version,
- URL, (author and author_email) or (maintainer and
- maintainer_email)) are supplied by the Distribution object; warn if
- any are missing.
- """
- metadata = self.distribution.metadata
-
- missing = []
- for attr in ('name', 'version', 'url'):
- if not (hasattr(metadata, attr) and getattr(metadata, attr)):
- missing.append(attr)
-
- if missing:
- self.warn("missing required meta-data: " +
- ", ".join(missing))
-
- if metadata.author:
- if not metadata.author_email:
- self.warn("missing meta-data: if 'author' supplied, " +
- "'author_email' must be supplied too")
- elif metadata.maintainer:
- if not metadata.maintainer_email:
- self.warn("missing meta-data: if 'maintainer' supplied, " +
- "'maintainer_email' must be supplied too")
- else:
- self.warn("missing meta-data: either (author and author_email) " +
- "or (maintainer and maintainer_email) " +
- "must be supplied")
+ """Deprecated API."""
+ warn("distutils.command.sdist.check_metadata is deprecated, \
+ use the check command instead", PendingDeprecationWarning)
+ check = self.distribution.get_command_obj('check')
+ check.ensure_finalized()
+ check.run()
def get_file_list(self):
"""Figure out the list of files to include in the source