diff options
Diffstat (limited to 'distutils2/command')
| -rw-r--r-- | distutils2/command/__init__.py | 7 | ||||
| -rw-r--r-- | distutils2/command/bdist.py | 6 | ||||
| -rw-r--r-- | distutils2/command/bdist_dumb.py | 13 | ||||
| -rw-r--r-- | distutils2/command/bdist_wininst.py | 2 | ||||
| -rw-r--r-- | distutils2/command/build_ext.py | 2 | ||||
| -rw-r--r-- | distutils2/command/build_py.py | 51 | ||||
| -rw-r--r-- | distutils2/command/check.py | 13 | ||||
| -rw-r--r-- | distutils2/command/clean.py | 4 | ||||
| -rw-r--r-- | distutils2/command/cmd.py | 16 | ||||
| -rw-r--r-- | distutils2/command/config.py | 2 | ||||
| -rw-r--r-- | distutils2/command/install_data.py | 75 | ||||
| -rw-r--r-- | distutils2/command/install_dist.py | 8 | ||||
| -rw-r--r-- | distutils2/command/install_distinfo.py | 40 | ||||
| -rw-r--r-- | distutils2/command/register.py | 40 | ||||
| -rw-r--r-- | distutils2/command/sdist.py | 49 | ||||
| -rw-r--r-- | distutils2/command/upload.py | 6 |
16 files changed, 143 insertions, 191 deletions
diff --git a/distutils2/command/__init__.py b/distutils2/command/__init__.py index 46a2111..e04a2c9 100644 --- a/distutils2/command/__init__.py +++ b/distutils2/command/__init__.py @@ -5,6 +5,9 @@ commands.""" from distutils2.errors import DistutilsModuleError from distutils2.util import resolve_name +__all__ = ['get_command_names', 'set_command', 'get_command_class', + 'STANDARD_COMMANDS'] + _COMMANDS = { 'check': 'distutils2.command.check.check', 'test': 'distutils2.command.test.test', @@ -29,10 +32,12 @@ _COMMANDS = { 'upload': 'distutils2.command.upload.upload', 'upload_docs': 'distutils2.command.upload_docs.upload_docs'} +STANDARD_COMMANDS = set(_COMMANDS) + def get_command_names(): - return sorted(_COMMANDS.keys()) """Return registered commands""" + return sorted(_COMMANDS) def set_command(location): diff --git a/distutils2/command/bdist.py b/distutils2/command/bdist.py index c7ffc7f..f8976e1 100644 --- a/distutils2/command/bdist.py +++ b/distutils2/command/bdist.py @@ -4,7 +4,7 @@ Implements the Distutils 'bdist' command (create a built [binary] distribution).""" import os -from distutils2.util import get_platform +from distutils2 import util from distutils2.command.cmd import Command from distutils2.errors import DistutilsPlatformError, DistutilsOptionError @@ -29,7 +29,7 @@ class bdist(Command): "temporary directory for creating built distributions"), ('plat-name=', 'p', "platform name to embed in generated filenames " - "(default: %s)" % get_platform()), + "(default: %s)" % util.get_platform()), ('formats=', None, "formats for distribution (comma-separated list)"), ('dist-dir=', 'd', @@ -87,7 +87,7 @@ class bdist(Command): # have to finalize 'plat_name' before 'bdist_base' if self.plat_name is None: if self.skip_build: - self.plat_name = get_platform() + self.plat_name = util.get_platform() else: self.plat_name = self.get_finalized_command('build').plat_name diff --git a/distutils2/command/bdist_dumb.py b/distutils2/command/bdist_dumb.py index 8aed45c..0ca232f 100644 --- a/distutils2/command/bdist_dumb.py +++ b/distutils2/command/bdist_dumb.py @@ -87,7 +87,7 @@ class bdist_dumb (Command): install.skip_build = self.skip_build install.warn_dir = 0 - logger.info("installing to %s" % self.bdist_dir) + logger.info("installing to %s", self.bdist_dir) self.run_command('install_dist') # And make an archive relative to the root of the @@ -106,11 +106,10 @@ class bdist_dumb (Command): else: if (self.distribution.has_ext_modules() and (install.install_base != install.install_platbase)): - raise DistutilsPlatformError, \ - ("can't make a dumb built distribution where " - "base and platbase are different (%s, %s)" - % (repr(install.install_base), - repr(install.install_platbase))) + raise DistutilsPlatformError( + "can't make a dumb built distribution where base and " + "platbase are different (%r, %r)" % + (install.install_base, install.install_platbase)) else: archive_root = os.path.join( self.bdist_dir, @@ -129,7 +128,7 @@ class bdist_dumb (Command): if not self.keep_temp: if self.dry_run: - logger.info('Removing %s' % self.bdist_dir) + logger.info('removing %s', self.bdist_dir) else: rmtree(self.bdist_dir) diff --git a/distutils2/command/bdist_wininst.py b/distutils2/command/bdist_wininst.py index 40f151f..5932d50 100644 --- a/distutils2/command/bdist_wininst.py +++ b/distutils2/command/bdist_wininst.py @@ -192,7 +192,7 @@ class bdist_wininst (Command): if not self.keep_temp: if self.dry_run: - logger.info('Removing %s' % self.bdist_dir) + logger.info('removing %s', self.bdist_dir) else: rmtree(self.bdist_dir) diff --git a/distutils2/command/build_ext.py b/distutils2/command/build_ext.py index 5302faa..6575e55 100644 --- a/distutils2/command/build_ext.py +++ b/distutils2/command/build_ext.py @@ -257,7 +257,7 @@ class build_ext(Command): elif MSVC_VERSION == 8: self.library_dirs.append(os.path.join(sys.exec_prefix, - 'PC', 'VS8.0', 'win32release')) + 'PC', 'VS8.0')) elif MSVC_VERSION == 7: self.library_dirs.append(os.path.join(sys.exec_prefix, 'PC', 'VS7.1')) diff --git a/distutils2/command/build_py.py b/distutils2/command/build_py.py index c24a13b..0b6b247 100644 --- a/distutils2/command/build_py.py +++ b/distutils2/command/build_py.py @@ -8,7 +8,6 @@ import sys import logging from glob import glob -import distutils2 from distutils2.command.cmd import Command from distutils2.errors import DistutilsOptionError, DistutilsFileError from distutils2.util import convert_path @@ -66,10 +65,9 @@ class build_py(Command, Mixin2to3): self.packages = self.distribution.packages self.py_modules = self.distribution.py_modules self.package_data = self.distribution.package_data - self.package_dir = {} - if self.distribution.package_dir: - for name, path in self.distribution.package_dir.items(): - self.package_dir[name] = convert_path(path) + self.package_dir = None + if self.distribution.package_dir is not None: + self.package_dir = convert_path(self.distribution.package_dir) self.data_files = self.get_data_files() # Ick, copied straight from install_lib.py (fancy_getopt needs a @@ -164,11 +162,13 @@ class build_py(Command, Mixin2to3): Helper function for `run()`. """ + # FIXME add tests for this method for package, src_dir, build_dir, filenames in self.data_files: for filename in filenames: target = os.path.join(build_dir, filename) + srcfile = os.path.join(src_dir, filename) self.mkpath(os.path.dirname(target)) - outf, copied = self.copy_file(os.path.join(src_dir, filename), + outf, copied = self.copy_file(srcfile, target, preserve_mode=False) if copied and srcfile in self.distribution.convert_2to3.doctests: self._doctests_2to3.append(outf) @@ -179,41 +179,14 @@ class build_py(Command, Mixin2to3): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any).""" - path = package.split('.') + if self.package_dir is not None: + path.insert(0, self.package_dir) - if not self.package_dir: - if path: - return os.path.join(*path) - else: - return '' - else: - tail = [] - while path: - try: - pdir = self.package_dir['.'.join(path)] - except KeyError: - tail.insert(0, path[-1]) - del path[-1] - else: - tail.insert(0, pdir) - return os.path.join(*tail) - else: - # Oops, got all the way through 'path' without finding a - # match in package_dir. If package_dir defines a directory - # for the root (nameless) package, then fallback on it; - # otherwise, we might as well have not consulted - # package_dir at all, as we just use the directory implied - # by 'tail' (which should be the same as the original value - # of 'path' at this point). - pdir = self.package_dir.get('') - if pdir is not None: - tail.insert(0, pdir) - - if tail: - return os.path.join(*tail) - else: - return '' + if len(path) > 0: + return os.path.join(*path) + + return '' def check_package(self, package, package_dir): """Helper function for `find_package_modules()` and `find_modules()'. diff --git a/distutils2/command/check.py b/distutils2/command/check.py index 8bf55f1..03c48c3 100644 --- a/distutils2/command/check.py +++ b/distutils2/command/check.py @@ -52,18 +52,19 @@ class check(Command): def check_metadata(self): """Ensures that all required elements of metadata are supplied. - name, version, URL, (author and author_email) or - (maintainer and maintainer_email)). + name, version, URL, author Warns if any are missing. """ - missing, __ = self.distribution.metadata.check() + missing, warnings = self.distribution.metadata.check(strict=True) if missing != []: self.warn("missing required metadata: %s" % ', '.join(missing)) + for warning in warnings: + self.warn(warning) def check_restructuredtext(self): """Checks if the long string fields are reST-compliant.""" - missing, warnings = self.distribution.metadata.check() + missing, warnings = self.distribution.metadata.check(restructuredtext=True) if self.distribution.metadata.docutils_support: for warning in warnings: line = warning[-1].get('line') @@ -76,11 +77,11 @@ class check(Command): raise DistutilsSetupError('The docutils package is needed.') def check_hooks_resolvable(self): - for options in self.distribution.command_options.values(): + for options in self.distribution.command_options.itervalues(): for hook_kind in ("pre_hook", "post_hook"): if hook_kind not in options: break - for hook_name in options[hook_kind][1].values(): + for hook_name in options[hook_kind][1].itervalues(): try: resolve_name(hook_name) except ImportError: diff --git a/distutils2/command/clean.py b/distutils2/command/clean.py index 295cfac..3904085 100644 --- a/distutils2/command/clean.py +++ b/distutils2/command/clean.py @@ -48,7 +48,7 @@ class clean(Command): # gone) if os.path.exists(self.build_temp): if self.dry_run: - logger.info('Removing %s' % self.build_temp) + logger.info('removing %s', self.build_temp) else: rmtree(self.build_temp) else: @@ -62,7 +62,7 @@ class clean(Command): self.build_scripts): if os.path.exists(directory): if self.dry_run: - logger.info('Removing %s' % directory) + logger.info('removing %s', directory) else: rmtree(directory) else: diff --git a/distutils2/command/cmd.py b/distutils2/command/cmd.py index e63c46b..9cfc5d9 100644 --- a/distutils2/command/cmd.py +++ b/distutils2/command/cmd.py @@ -10,14 +10,7 @@ import logging from distutils2.errors import DistutilsOptionError from distutils2 import util from distutils2 import logger - -# XXX see if we want to backport this -from distutils2._backport.shutil import copytree, copyfile, move - -try: - from shutil import make_archive -except ImportError: - from distutils2._backport.shutil import make_archive +from distutils2._backport.shutil import copytree, copyfile, move, make_archive class Command(object): @@ -165,7 +158,10 @@ class Command(object): header = "command options for '%s':" % self.get_command_name() self.announce(indent + header, level=logging.INFO) indent = indent + " " + negative_opt = getattr(self, 'negative_opt', ()) for (option, _, _) in self.user_options: + if option in negative_opt: + continue option = option.replace('-', '_') if option[-1] == "=": option = option[:-1] @@ -186,6 +182,7 @@ class Command(object): raise RuntimeError( "abstract method -- subclass %s must override" % self.__class__) + # TODO remove this method, just use logging.info def announce(self, msg, level=logging.INFO): """If the current verbosity level is of greater than or equal to 'level' print 'msg' to stdout. @@ -367,8 +364,9 @@ class Command(object): # -- External world manipulation ----------------------------------- + # TODO remove this method, just use logging.warn def warn(self, msg): - logger.warning("warning: %s: %s\n" % (self.get_command_name(), msg)) + logger.warning("warning: %s: %s\n", self.get_command_name(), msg) def execute(self, func, args, msg=None, level=1): util.execute(func, args, msg, dry_run=self.dry_run) diff --git a/distutils2/command/config.py b/distutils2/command/config.py index 0f4ae9f..411ad26 100644 --- a/distutils2/command/config.py +++ b/distutils2/command/config.py @@ -345,7 +345,7 @@ def dump_file(filename, head=None): If head is not None, will be dumped before the file content. """ if head is None: - logger.info('%s' % filename) + logger.info(filename) else: logger.info(head) file = open(filename) diff --git a/distutils2/command/install_data.py b/distutils2/command/install_data.py index e77b11c..3179ebb 100644 --- a/distutils2/command/install_data.py +++ b/distutils2/command/install_data.py @@ -9,6 +9,8 @@ platform-independent data files.""" import os from distutils2.command.cmd import Command from distutils2.util import change_root, convert_path +from distutils2._backport.sysconfig import get_paths, format_value +from distutils2._backport.shutil import Error class install_data(Command): @@ -28,6 +30,7 @@ class install_data(Command): def initialize_options(self): self.install_dir = None self.outfiles = [] + self.data_files_out = [] self.root = None self.force = 0 self.data_files = self.distribution.data_files @@ -40,54 +43,38 @@ class install_data(Command): def run(self): self.mkpath(self.install_dir) - for f in self.data_files: - if isinstance(f, str): - # it's a simple file, so copy it - f = convert_path(f) - if self.warn_dir: - self.warn("setup script did not provide a directory for " - "'%s' -- installing right in '%s'" % - (f, self.install_dir)) - (out, _) = self.copy_file(f, self.install_dir) - self.outfiles.append(out) - else: - # it's a tuple with path to install to and a list of files - dir = convert_path(f[0]) - if not os.path.isabs(dir): - dir = os.path.join(self.install_dir, dir) - elif self.root: - dir = change_root(self.root, dir) - self.mkpath(dir) - - if f[1] == []: - # If there are no files listed, the user must be - # trying to create an empty directory, so add the - # directory to the list of output files. - self.outfiles.append(dir) - else: - # Copy files, adding them to the list of output files. - for data in f[1]: - data = convert_path(data) - (out, _) = self.copy_file(data, dir) - self.outfiles.append(out) + for file in self.data_files.items(): + destination = convert_path(self.expand_categories(file[1])) + dir_dest = os.path.abspath(os.path.dirname(destination)) + + self.mkpath(dir_dest) + try: + (out, _) = self.copy_file(file[0], dir_dest) + except Error, e: + self.warn(e) + out = destination + + self.outfiles.append(out) + self.data_files_out.append((file[0], destination)) + + def expand_categories(self, path_with_categories): + local_vars = get_paths() + local_vars['distribution.name'] = self.distribution.metadata['Name'] + expanded_path = format_value(path_with_categories, local_vars) + expanded_path = format_value(expanded_path, local_vars) + if '{' in expanded_path and '}' in expanded_path: + self.warn("Unable to expand %s, some categories may missing." % + path_with_categories) + return expanded_path def get_source_files(self): - sources = [] - for item in self.data_files: - if isinstance(item, str): # plain file - item = convert_path(item) - if os.path.isfile(item): - sources.append(item) - else: # a (dirname, filenames) tuple - dirname, filenames = item - for f in filenames: - f = convert_path(f) - if os.path.isfile(f): - sources.append(f) - return sources + return self.data_files.keys() def get_inputs(self): - return self.data_files or [] + return self.data_files.keys() def get_outputs(self): return self.outfiles + + def get_resources_out(self): + return self.data_files_out diff --git a/distutils2/command/install_dist.py b/distutils2/command/install_dist.py index f0233d1..baa5991 100644 --- a/distutils2/command/install_dist.py +++ b/distutils2/command/install_dist.py @@ -87,6 +87,8 @@ class install_dist(Command): ('record=', None, "filename in which to record a list of installed files " "(not PEP 376-compliant)"), + ('resources=', None, + "data files mapping"), # .dist-info related arguments, read by install_dist_info ('no-distinfo', None, @@ -184,12 +186,14 @@ class install_dist(Command): #self.install_info = None self.record = None + self.resources = None # .dist-info related options self.no_distinfo = None self.installer = None self.requested = None self.no_record = None + self.no_resources = None # -- Option finalizing methods ------------------------------------- # (This is rather more involved than for most commands, @@ -418,13 +422,13 @@ class install_dist(Command): else: opt_name = opt_name.replace('-', '_') val = getattr(self, opt_name) - logger.debug(" %s: %s" % (opt_name, val)) + logger.debug(" %s: %s", opt_name, val) def select_scheme(self, name): """Set the install directories by applying the install schemes.""" # it's the caller's problem if they supply a bad name! scheme = get_paths(name, expand=False) - for key, value in scheme.items(): + for key, value in scheme.iteritems(): if key == 'platinclude': key = 'headers' value = os.path.join(value, self.distribution.metadata['Name']) diff --git a/distutils2/command/install_distinfo.py b/distutils2/command/install_distinfo.py index 6e76546..b8cfcc0 100644 --- a/distutils2/command/install_distinfo.py +++ b/distutils2/command/install_distinfo.py @@ -12,12 +12,12 @@ automatically by the ``install_dist`` command. # This file was created from the code for the former command install_egg_info -import os import csv -import re -from distutils2.command.cmd import Command from distutils2 import logger from distutils2._backport.shutil import rmtree +from distutils2.command.cmd import Command +import os +import re try: import hashlib except ImportError: @@ -39,9 +39,11 @@ class install_distinfo(Command): "do not generate a REQUESTED file"), ('no-record', None, "do not generate a RECORD file"), + ('no-resources', None, + "do not generate a RESSOURCES list installed file") ] - boolean_options = ['requested', 'no-record'] + boolean_options = ['requested', 'no-record', 'no-resources'] negative_opt = {'no-requested': 'requested'} @@ -50,6 +52,7 @@ class install_distinfo(Command): self.installer = None self.requested = None self.no_record = None + self.no_resources = None def finalize_options(self): self.set_undefined_options('install_dist', @@ -66,13 +69,16 @@ class install_distinfo(Command): self.requested = True if self.no_record is None: self.no_record = False + if self.no_resources is None: + self.no_resources = False + metadata = self.distribution.metadata basename = "%s-%s.dist-info" % ( - to_filename(safe_name(metadata['Name'])), - to_filename(safe_version(metadata['Version'])), - ) + to_filename(safe_name(metadata['Name'])), + to_filename(safe_version(metadata['Version'])), + ) self.distinfo_dir = os.path.join(self.distinfo_dir, basename) self.outputs = [] @@ -113,6 +119,25 @@ class install_distinfo(Command): f.close() self.outputs.append(requested_path) + + if not self.no_resources: + install_data = self.get_finalized_command('install_data') + if install_data.get_resources_out() != []: + resources_path = os.path.join(self.distinfo_dir, + 'RESOURCES') + logger.info('creating %s', resources_path) + f = open(resources_path, 'wb') + try: + writer = csv.writer(f, delimiter=',', + lineterminator=os.linesep, + quotechar='"') + for tuple in install_data.get_resources_out(): + writer.writerow(tuple) + + self.outputs.append(resources_path) + finally: + f.close() + if not self.no_record: record_path = os.path.join(self.distinfo_dir, 'RECORD') logger.info('creating %s', record_path) @@ -142,6 +167,7 @@ class install_distinfo(Command): finally: f.close() + def get_outputs(self): return self.outputs diff --git a/distutils2/command/register.py b/distutils2/command/register.py index 687a514..f051622 100644 --- a/distutils2/command/register.py +++ b/distutils2/command/register.py @@ -11,13 +11,12 @@ import getpass import urlparse import StringIO import logging -from warnings import warn from distutils2.command.cmd import Command from distutils2 import logger -from distutils2.util import (metadata_to_dict, read_pypirc, generate_pypirc, - DEFAULT_REPOSITORY, DEFAULT_REALM, - get_pypirc_path) +from distutils2.metadata import metadata_to_dict +from distutils2.util import (read_pypirc, generate_pypirc, DEFAULT_REPOSITORY, + DEFAULT_REALM, get_pypirc_path) class register(Command): @@ -33,8 +32,7 @@ class register(Command): "stop the registration if the metadata is not fully compliant") ] - boolean_options = ['show-response', 'verify', 'list-classifiers', - 'strict'] + boolean_options = ['show-response', 'list-classifiers', 'strict'] def initialize_options(self): self.repository = None @@ -48,16 +46,15 @@ class register(Command): self.repository = DEFAULT_REPOSITORY if self.realm is None: self.realm = DEFAULT_REALM - # setting options for the `check` subcommand - check_options = {'strict': ('register', self.strict), - 'all': ('register', 1)} - self.distribution.command_options['check'] = check_options def run(self): self.finalize_options() self._set_config() # Check the package metadata + check = self.distribution.get_command_obj('check') + check.strict = self.strict + check.all = 1 self.run_command('check') if self.dry_run: @@ -67,16 +64,6 @@ class register(Command): else: self.send_metadata() - def check_metadata(self): - """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.all = 1 - check.run() - def _set_config(self): ''' Reads the configuration file and set attributes. ''' @@ -105,7 +92,7 @@ class register(Command): ''' # send the info to the server and report the result code, result = self.post_to_server(self.build_post_data('verify')) - logger.info('Server response (%s): %s' % (code, result)) + logger.info('server response (%s): %s', code, result) def send_metadata(self): @@ -219,18 +206,17 @@ Your selection [default 1]: ''', logging.INFO) data['email'] = raw_input(' EMail: ') code, result = self.post_to_server(data) if code != 200: - logger.info('Server response (%s): %s' % (code, result)) + logger.info('server response (%s): %s', code, result) else: - logger.info('You will receive an email shortly.') - logger.info(('Follow the instructions in it to ' - 'complete registration.')) + logger.info('you will receive an email shortly; follow the ' + 'instructions in it to complete registration.') elif choice == '3': data = {':action': 'password_reset'} data['email'] = '' while not data['email']: data['email'] = raw_input('Your email address: ') code, result = self.post_to_server(data) - logger.info('Server response (%s): %s' % (code, result)) + logger.info('server response (%s): %s', code, result) def build_post_data(self, action): # figure the data to send - the metadata plus some additional @@ -252,7 +238,7 @@ Your selection [default 1]: ''', logging.INFO) sep_boundary = '\n--' + boundary end_boundary = sep_boundary + '--' body = StringIO.StringIO() - for key, value in data.items(): + for key, value in data.iteritems(): # handle multiple entries for the same name if not isinstance(value, (tuple, list)): value = [value] diff --git a/distutils2/command/sdist.py b/distutils2/command/sdist.py index 0a83030..babf5ba 100644 --- a/distutils2/command/sdist.py +++ b/distutils2/command/sdist.py @@ -2,10 +2,7 @@ Implements the Distutils 'sdist' command (create a source distribution).""" import os -import string import sys -from glob import glob -from warnings import warn from shutil import rmtree import re from StringIO import StringIO @@ -18,10 +15,10 @@ except ImportError: from distutils2.command import get_command_names from distutils2.command.cmd import Command from distutils2.errors import (DistutilsPlatformError, DistutilsOptionError, - DistutilsTemplateError, DistutilsModuleError) + DistutilsModuleError, DistutilsFileError) from distutils2.manifest import Manifest from distutils2 import logger -from distutils2.util import convert_path, resolve_name +from distutils2.util import resolve_name def show_formats(): """Print all possible values for the 'formats' option (used by @@ -214,8 +211,6 @@ class sdist(Command): def add_defaults(self): """Add all the default files to self.filelist: - - README or README.txt - - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. @@ -225,32 +220,6 @@ class sdist(Command): Warns if (README or README.txt) or setup.py are missing; everything else is optional. """ - standards = [('README', 'README.txt')] - for fn in standards: - if isinstance(fn, tuple): - alts = fn - got_it = 0 - for fn in alts: - if os.path.exists(fn): - got_it = 1 - self.filelist.append(fn) - break - - if not got_it: - self.warn("standard file not found: should have one of " + - string.join(alts, ', ')) - else: - if os.path.exists(fn): - self.filelist.append(fn) - else: - self.warn("standard file '%s' not found" % fn) - - optional = ['test/test*.py', 'setup.cfg'] - for pattern in optional: - files = filter(os.path.isfile, glob(pattern)) - if files: - self.filelist.extend(files) - for cmd_name in get_command_names(): try: cmd_obj = self.get_finalized_command(cmd_name) @@ -319,9 +288,15 @@ class sdist(Command): logger.warn("no files to distribute -- empty manifest?") else: logger.info(msg) + + for file in self.distribution.metadata.requires_files: + if file not in files: + msg = "'%s' must be included explicitly in 'extra_files'" % file + raise DistutilsFileError(msg) + for file in files: if not os.path.isfile(file): - logger.warn("'%s' not a regular file -- skipping" % file) + logger.warn("'%s' not a regular file -- skipping", file) else: dest = os.path.join(base_dir, file) self.copy_file(file, dest, link=link) @@ -357,7 +332,7 @@ class sdist(Command): if not self.keep_temp: if self.dry_run: - logger.info('Removing %s' % base_dir) + logger.info('removing %s', base_dir) else: rmtree(base_dir) @@ -371,10 +346,8 @@ class sdist(Command): need_dir = {} for file in files: need_dir[os.path.join(base_dir, os.path.dirname(file))] = 1 - need_dirs = need_dir.keys() - need_dirs.sort() + need_dirs = sorted(need_dir) # Now create them for dir in need_dirs: self.mkpath(dir, mode, verbose=verbose, dry_run=dry_run) - diff --git a/distutils2/command/upload.py b/distutils2/command/upload.py index b5e072c..3bba7ae 100644 --- a/distutils2/command/upload.py +++ b/distutils2/command/upload.py @@ -20,8 +20,8 @@ except ImportError: from distutils2.errors import DistutilsOptionError from distutils2.util import spawn from distutils2.command.cmd import Command -from distutils2.util import (metadata_to_dict, read_pypirc, - DEFAULT_REPOSITORY, DEFAULT_REALM) +from distutils2.metadata import metadata_to_dict +from distutils2.util import read_pypirc, DEFAULT_REPOSITORY, DEFAULT_REALM class upload(Command): @@ -140,7 +140,7 @@ class upload(Command): body = StringIO() file_fields = ('content', 'gpg_signature') - for key, values in data.items(): + for key, values in data.iteritems(): # handle multiple entries for the same name if not isinstance(values, (tuple, list)): values = [values] |
