diff options
| author | ?ric Araujo <merwok@netwok.org> | 2010-11-06 05:34:26 +0100 |
|---|---|---|
| committer | ?ric Araujo <merwok@netwok.org> | 2010-11-06 05:34:26 +0100 |
| commit | 1ba779a9ac2a14a707a576dc121d4bee9deb0d42 (patch) | |
| tree | 5c9f9086a66c65873b28127e49f8d8375f742707 /distutils2/command | |
| parent | 8f2fdfad831885fe5048fc0205b3b48dad54ea98 (diff) | |
| parent | 3b95c92aeaf8b4c4b13bddd462fd0d4a99826acb (diff) | |
| download | disutils2-1ba779a9ac2a14a707a576dc121d4bee9deb0d42.tar.gz | |
Branch merge
Diffstat (limited to 'distutils2/command')
25 files changed, 137 insertions, 148 deletions
diff --git a/distutils2/command/__init__.py b/distutils2/command/__init__.py index c817b4f..cb2fa3f 100644 --- a/distutils2/command/__init__.py +++ b/distutils2/command/__init__.py @@ -12,7 +12,7 @@ __all__ = ['check', 'build_clib', 'build_scripts', 'clean', - 'install', + 'install_dist', 'install_lib', 'install_headers', 'install_scripts', diff --git a/distutils2/command/bdist.py b/distutils2/command/bdist.py index 1b7ce16..c7ffc7f 100644 --- a/distutils2/command/bdist.py +++ b/distutils2/command/bdist.py @@ -2,12 +2,10 @@ Implements the Distutils 'bdist' command (create a built [binary] distribution).""" - - import os from distutils2.util import get_platform -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import DistutilsPlatformError, DistutilsOptionError diff --git a/distutils2/command/bdist_dumb.py b/distutils2/command/bdist_dumb.py index c02d6e0..8aed45c 100644 --- a/distutils2/command/bdist_dumb.py +++ b/distutils2/command/bdist_dumb.py @@ -12,9 +12,9 @@ try: except ImportError: from distutils2._backport.sysconfig import get_python_version from distutils2.util import get_platform -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import DistutilsPlatformError -from distutils2 import log +from distutils2 import logger class bdist_dumb (Command): @@ -82,13 +82,13 @@ class bdist_dumb (Command): if not self.skip_build: self.run_command('build') - install = self.get_reinitialized_command('install', reinit_subcommands=1) + install = self.get_reinitialized_command('install_dist', reinit_subcommands=1) install.root = self.bdist_dir install.skip_build = self.skip_build install.warn_dir = 0 - log.info("installing to %s" % self.bdist_dir) - self.run_command('install') + logger.info("installing to %s" % self.bdist_dir) + self.run_command('install_dist') # And make an archive relative to the root of the # pseudo-installation tree. @@ -129,7 +129,7 @@ class bdist_dumb (Command): if not self.keep_temp: if self.dry_run: - log.info('Removing %s' % self.bdist_dir) + logger.info('Removing %s' % self.bdist_dir) else: rmtree(self.bdist_dir) diff --git a/distutils2/command/bdist_msi.py b/distutils2/command/bdist_msi.py index 3728fe5..e2176a7 100644 --- a/distutils2/command/bdist_msi.py +++ b/distutils2/command/bdist_msi.py @@ -174,7 +174,7 @@ class bdist_msi (Command): if not self.skip_build: self.run_command('build') - install = self.get_reinitialized_command('install', reinit_subcommands=1) + install = self.get_reinitialized_command('install_dist', reinit_subcommands=1) install.prefix = self.bdist_dir install.skip_build = self.skip_build install.warn_dir = 0 diff --git a/distutils2/command/bdist_wininst.py b/distutils2/command/bdist_wininst.py index 67a514d..40f151f 100644 --- a/distutils2/command/bdist_wininst.py +++ b/distutils2/command/bdist_wininst.py @@ -12,9 +12,9 @@ try: from sysconfig import get_python_version except ImportError: from distutils2._backport.sysconfig import get_python_version -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import DistutilsOptionError, DistutilsPlatformError -from distutils2 import log +from distutils2 import logger from distutils2.util import get_platform class bdist_wininst (Command): @@ -160,7 +160,7 @@ class bdist_wininst (Command): 'install_' + key, value) - log.info("installing to %s", self.bdist_dir) + logger.info("installing to %s", self.bdist_dir) install.ensure_finalized() # avoid warning of 'install_lib' about installing @@ -187,12 +187,12 @@ class bdist_wininst (Command): self.distribution.dist_files.append(('bdist_wininst', pyversion, self.get_installer_filename(fullname))) # remove the zip-file again - log.debug("removing temporary file '%s'", arcname) + logger.debug("removing temporary file '%s'", arcname) os.remove(arcname) if not self.keep_temp: if self.dry_run: - log.info('Removing %s' % self.bdist_dir) + logger.info('Removing %s' % self.bdist_dir) else: rmtree(self.bdist_dir) diff --git a/distutils2/command/build.py b/distutils2/command/build.py index 6336ac4..ed2ccdf 100644 --- a/distutils2/command/build.py +++ b/distutils2/command/build.py @@ -6,7 +6,7 @@ Implements the Distutils 'build' command.""" import sys, os from distutils2.util import get_platform -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import DistutilsOptionError def show_compilers(): diff --git a/distutils2/command/build_clib.py b/distutils2/command/build_clib.py index 0c8701e..5f20bb0 100644 --- a/distutils2/command/build_clib.py +++ b/distutils2/command/build_clib.py @@ -16,10 +16,10 @@ module.""" # cut 'n paste. Sigh. import os -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import DistutilsSetupError from distutils2.compiler.ccompiler import customize_compiler -from distutils2 import log +from distutils2 import logger def show_compilers(): from distutils2.compiler.ccompiler import show_compilers @@ -185,7 +185,7 @@ class build_clib(Command): "a list of source filenames") % lib_name sources = list(sources) - log.info("building '%s' library", lib_name) + logger.info("building '%s' library", lib_name) # First, compile the source code to object files in the library # directory. (This should probably change to putting object diff --git a/distutils2/command/build_ext.py b/distutils2/command/build_ext.py index cb4f691..df71f1c 100644 --- a/distutils2/command/build_ext.py +++ b/distutils2/command/build_ext.py @@ -9,13 +9,13 @@ import sys, os, re from warnings import warn from distutils2.util import get_platform -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import (CCompilerError, CompileError, DistutilsError, DistutilsPlatformError, DistutilsSetupError) from distutils2.compiler.ccompiler import customize_compiler from distutils2.util import newer_group from distutils2.extension import Extension -from distutils2 import log +from distutils2 import logger try: import sysconfig except ImportError: @@ -449,10 +449,10 @@ class build_ext(Command): ext_path = self.get_ext_fullpath(ext.name) depends = sources + ext.depends if not (self.force or newer_group(depends, ext_path, 'newer')): - log.debug("skipping '%s' extension (up-to-date)", ext.name) + logger.debug("skipping '%s' extension (up-to-date)", ext.name) return else: - log.info("building '%s' extension", ext.name) + logger.info("building '%s' extension", ext.name) # First, scan the sources for SWIG definition files (.i), run # SWIG on 'em to create .c files, and modify the sources list @@ -536,7 +536,7 @@ class build_ext(Command): # the temp dir. if self.swig_cpp: - log.warn("--swig-cpp is deprecated - use --swig-opts=-c++") + logger.warn("--swig-cpp is deprecated - use --swig-opts=-c++") if self.swig_cpp or ('-c++' in self.swig_opts) or \ ('-c++' in extension.swig_opts): @@ -569,7 +569,7 @@ class build_ext(Command): for source in swig_sources: target = swig_targets[source] - log.info("swigging %s to %s", source, target) + logger.info("swigging %s to %s", source, target) self.spawn(swig_cmd + ["-o", target, source]) return new_sources diff --git a/distutils2/command/build_py.py b/distutils2/command/build_py.py index 92a8d9e..c24a13b 100644 --- a/distutils2/command/build_py.py +++ b/distutils2/command/build_py.py @@ -9,7 +9,7 @@ import logging from glob import glob import distutils2 -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import DistutilsOptionError, DistutilsFileError from distutils2.util import convert_path from distutils2.compat import Mixin2to3 diff --git a/distutils2/command/build_scripts.py b/distutils2/command/build_scripts.py index b76d2b5..e0c8bcb 100644 --- a/distutils2/command/build_scripts.py +++ b/distutils2/command/build_scripts.py @@ -5,9 +5,10 @@ Implements the Distutils 'build_scripts' command.""" import os, re from stat import ST_MODE -from distutils2.core import Command + +from distutils2.command.cmd import Command from distutils2.util import convert_path, newer -from distutils2 import log +from distutils2 import logger try: import sysconfig except ImportError: @@ -73,7 +74,7 @@ class build_scripts (Command, Mixin2to3): outfiles.append(outfile) if not self.force and not newer(script, outfile): - log.debug("not copying %s (up-to-date)", script) + logger.debug("not copying %s (up-to-date)", script) continue # Always open the file, but ignore failures in dry-run mode -- @@ -97,7 +98,7 @@ class build_scripts (Command, Mixin2to3): post_interp = match.group(1) or '' if adjust: - log.info("copying and adjusting %s -> %s", script, + logger.info("copying and adjusting %s -> %s", script, self.build_dir) if not self.dry_run: outf = open(outfile, "w") @@ -124,12 +125,12 @@ class build_scripts (Command, Mixin2to3): if os.name == 'posix': for file in outfiles: if self.dry_run: - log.info("changing mode of %s", file) + logger.info("changing mode of %s", file) else: oldmode = os.stat(file)[ST_MODE] & 07777 newmode = (oldmode | 0555) & 07777 if newmode != oldmode: - log.info("changing mode of %s from %o to %o", + logger.info("changing mode of %s from %o to %o", file, oldmode, newmode) os.chmod(file, newmode) return outfiles diff --git a/distutils2/command/check.py b/distutils2/command/check.py index c661e6f..8bf55f1 100644 --- a/distutils2/command/check.py +++ b/distutils2/command/check.py @@ -3,7 +3,7 @@ Implements the Distutils 'check' command. """ -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import DistutilsSetupError from distutils2.util import resolve_name diff --git a/distutils2/command/clean.py b/distutils2/command/clean.py index dc2ef0b..295cfac 100644 --- a/distutils2/command/clean.py +++ b/distutils2/command/clean.py @@ -7,8 +7,8 @@ Implements the Distutils 'clean' command.""" import os from shutil import rmtree -from distutils2.core import Command -from distutils2 import log +from distutils2.command.cmd import Command +from distutils2 import logger class clean(Command): @@ -48,11 +48,11 @@ class clean(Command): # gone) if os.path.exists(self.build_temp): if self.dry_run: - log.info('Removing %s' % self.build_temp) + logger.info('Removing %s' % self.build_temp) else: rmtree(self.build_temp) else: - log.debug("'%s' does not exist -- can't clean it", + logger.debug("'%s' does not exist -- can't clean it", self.build_temp) if self.all: @@ -62,19 +62,19 @@ class clean(Command): self.build_scripts): if os.path.exists(directory): if self.dry_run: - log.info('Removing %s' % directory) + logger.info('Removing %s' % directory) else: rmtree(directory) else: - log.warn("'%s' does not exist -- can't clean it", - directory) + logger.warn("'%s' does not exist -- can't clean it", + directory) # just for the heck of it, try to remove the base build directory: # we might have emptied it right now, but if not we don't care if not self.dry_run: try: os.rmdir(self.build_base) - log.info("removing '%s'", self.build_base) + logger.info("removing '%s'", self.build_base) except OSError: pass diff --git a/distutils2/command/cmd.py b/distutils2/command/cmd.py index 4dd825f..91b5589 100644 --- a/distutils2/command/cmd.py +++ b/distutils2/command/cmd.py @@ -3,12 +3,13 @@ Provides the Command class, the base class for the command classes in the distutils.command package. """ +import os +import re +import logging - -import os, re from distutils2.errors import DistutilsOptionError from distutils2 import util -from distutils2 import log +from distutils2 import logger # XXX see if we want to backport this from distutils2._backport.shutil import copytree, copyfile, move @@ -35,7 +36,7 @@ class Command(object): """ # 'sub_commands' formalizes the notion of a "family" of commands, - # eg. "install" as the parent with sub-commands "install_lib", + # eg. "install_dist" as the parent with sub-commands "install_lib", # "install_headers", etc. The parent of a family of commands # defines 'sub_commands' as a class attribute; it's a list of # (command_name : string, predicate : unbound_method | string | None) @@ -47,7 +48,7 @@ class Command(object): # # 'sub_commands' is usually defined at the *end* of a class, because # predicates can be unbound methods, so they must already have been - # defined. The canonical example is the "install" command. + # defined. The canonical example is the "install_dist" command. sub_commands = [] # Pre and post command hooks are run just before or just after the command @@ -163,7 +164,7 @@ class Command(object): def dump_options(self, header=None, indent=""): if header is None: header = "command options for '%s':" % self.get_command_name() - self.announce(indent + header, level=log.INFO) + self.announce(indent + header, level=logging.INFO) indent = indent + " " for (option, _, _) in self.user_options: option = option.replace('-', '_') @@ -171,7 +172,7 @@ class Command(object): option = option[:-1] value = getattr(self, option) self.announce(indent + "%s = %s" % (option, value), - level=log.INFO) + level=logging.INFO) def run(self): """A command's raison d'etre: carry out the action it exists to @@ -186,11 +187,11 @@ class Command(object): raise RuntimeError, \ "abstract method -- subclass %s must override" % self.__class__ - def announce(self, msg, level=1): + def announce(self, msg, level=logging.INFO): """If the current verbosity level is of greater than or equal to 'level' print 'msg' to stdout. """ - log.log(level, msg) + logger.log(level, msg) # -- External interface -------------------------------------------- # (called by outsiders) @@ -367,7 +368,7 @@ class Command(object): # -- External world manipulation ----------------------------------- def warn(self, msg): - log.warn("warning: %s: %s\n" % + logger.warning("warning: %s: %s\n" % (self.get_command_name(), msg)) def execute(self, func, args, msg=None, level=1): @@ -382,7 +383,7 @@ class Command(object): if dry_run: head = '' for part in name.split(os.sep): - log.info("created directory %s%s", head, part) + logger.info("created directory %s%s", head, part) head += part + os.sep return os.makedirs(name, mode) @@ -459,7 +460,7 @@ class Command(object): # Otherwise, print the "skip" message else: - log.debug(skip_msg) + logger.debug(skip_msg) # XXX 'install_misc' class not currently used -- it was the base class for # both 'install_scripts' and 'install_data', but they outgrew it. It might @@ -478,7 +479,7 @@ class install_misc(Command): self.outfiles = [] def _install_dir_from(self, dirname): - self.set_undefined_options('install', (dirname, 'install_dir')) + self.set_undefined_options('install_dist', (dirname, 'install_dir')) def _copy_files(self, filelist): self.outfiles = [] diff --git a/distutils2/command/config.py b/distutils2/command/config.py index 5bea91e..20c3a2c 100644 --- a/distutils2/command/config.py +++ b/distutils2/command/config.py @@ -13,10 +13,10 @@ this header file lives". import os import re -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import DistutilsExecError from distutils2.compiler.ccompiler import customize_compiler -from distutils2 import log +from distutils2 import logger LANG_EXT = {'c': '.c', 'c++': '.cxx'} @@ -156,7 +156,7 @@ class config(Command): if not filenames: filenames = self.temp_files self.temp_files = [] - log.info("removing: %s", ' '.join(filenames)) + logger.info("removing: %s", ' '.join(filenames)) for filename in filenames: try: os.remove(filename) @@ -233,7 +233,7 @@ class config(Command): except CompileError: ok = 0 - log.info(ok and "success!" or "failure.") + logger.info(ok and "success!" or "failure.") self._clean() return ok @@ -252,7 +252,7 @@ class config(Command): except (CompileError, LinkError): ok = 0 - log.info(ok and "success!" or "failure.") + logger.info(ok and "success!" or "failure.") self._clean() return ok @@ -272,7 +272,7 @@ class config(Command): except (CompileError, LinkError, DistutilsExecError): ok = 0 - log.info(ok and "success!" or "failure.") + logger.info(ok and "success!" or "failure.") self._clean() return ok @@ -346,11 +346,11 @@ def dump_file(filename, head=None): If head is not None, will be dumped before the file content. """ if head is None: - log.info('%s' % filename) + logger.info('%s' % filename) else: - log.info(head) + logger.info(head) file = open(filename) try: - log.info(file.read()) + logger.info(file.read()) finally: file.close() diff --git a/distutils2/command/install_data.py b/distutils2/command/install_data.py index 1d5828f..e77b11c 100644 --- a/distutils2/command/install_data.py +++ b/distutils2/command/install_data.py @@ -7,7 +7,7 @@ platform-independent data files.""" import os -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.util import change_root, convert_path class install_data(Command): @@ -34,7 +34,7 @@ class install_data(Command): self.warn_dir = 1 def finalize_options(self): - self.set_undefined_options('install', + self.set_undefined_options('install_dist', ('install_data', 'install_dir'), 'root', 'force') diff --git a/distutils2/command/install.py b/distutils2/command/install_dist.py index b059fd9..f0233d1 100644 --- a/distutils2/command/install.py +++ b/distutils2/command/install_dist.py @@ -1,6 +1,6 @@ """distutils.command.install -Implements the Distutils 'install' command.""" +Implements the Distutils 'install_dist' command.""" import sys @@ -10,8 +10,8 @@ from distutils2._backport import sysconfig from distutils2._backport.sysconfig import (get_config_vars, get_paths, get_path, get_config_var) -from distutils2 import log -from distutils2.core import Command +from distutils2 import logger +from distutils2.command.cmd import Command from distutils2.errors import DistutilsPlatformError from distutils2.util import write_file from distutils2.util import convert_path, change_root, get_platform @@ -24,7 +24,7 @@ else: HAS_USER_SITE = True -class install(Command): +class install_dist(Command): description = "install everything from build directory" @@ -406,7 +406,7 @@ class install(Command): def dump_dirs(self, msg): """Dump the list of user options.""" - log.debug(msg + ":") + logger.debug(msg + ":") for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": @@ -418,7 +418,7 @@ class install(Command): else: opt_name = opt_name.replace('-', '_') val = getattr(self, opt_name) - log.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.""" @@ -513,7 +513,7 @@ class install(Command): self.run_command('build') # If we built for any other platform, we can't install. build_plat = self.distribution.get_command_obj('build').plat_name - # check warn_dir - it is a clue that the 'install' is happening + # check warn_dir - it is a clue that the 'install_dist' is happening # internally, and not to sys.path, so we don't check the platform # matches what we are running. if self.warn_dir and build_plat != get_platform(): @@ -545,7 +545,7 @@ class install(Command): if (self.warn_dir and not (self.path_file and self.install_path_file) and install_lib not in sys_path): - log.debug(("modules installed to '%s', which is not in " + logger.debug(("modules installed to '%s', which is not in " "Python's module search path (sys.path) -- " "you'll have to change the search path yourself"), self.install_lib) diff --git a/distutils2/command/install_distinfo.py b/distutils2/command/install_distinfo.py index 64174dd..6e76546 100644 --- a/distutils2/command/install_distinfo.py +++ b/distutils2/command/install_distinfo.py @@ -7,7 +7,7 @@ distutils.command.install_distinfo This module implements the ``install_distinfo`` command that creates the ``.dist-info`` directory for the distribution, as specified in :pep:`376`. Usually, you do not have to call this command directly, it gets called -automatically by the ``install`` command. +automatically by the ``install_dist`` command. """ # This file was created from the code for the former command install_egg_info @@ -16,7 +16,7 @@ import os import csv import re from distutils2.command.cmd import Command -from distutils2 import log +from distutils2 import logger from distutils2._backport.shutil import rmtree try: import hashlib @@ -52,7 +52,7 @@ class install_distinfo(Command): self.no_record = None def finalize_options(self): - self.set_undefined_options('install', + self.set_undefined_options('install_dist', 'installer', 'requested', 'no_record') self.set_undefined_options('install_lib', @@ -93,12 +93,12 @@ class install_distinfo(Command): self.execute(os.makedirs, (target,), "creating " + target) metadata_path = os.path.join(self.distinfo_dir, 'METADATA') - log.info('creating %s', metadata_path) + logger.info('creating %s', metadata_path) self.distribution.metadata.write(metadata_path) self.outputs.append(metadata_path) installer_path = os.path.join(self.distinfo_dir, 'INSTALLER') - log.info('creating %s', installer_path) + logger.info('creating %s', installer_path) f = open(installer_path, 'w') try: f.write(self.installer) @@ -108,21 +108,21 @@ class install_distinfo(Command): if self.requested: requested_path = os.path.join(self.distinfo_dir, 'REQUESTED') - log.info('creating %s', requested_path) + logger.info('creating %s', requested_path) f = open(requested_path, 'w') f.close() self.outputs.append(requested_path) if not self.no_record: record_path = os.path.join(self.distinfo_dir, 'RECORD') - log.info('creating %s', record_path) + logger.info('creating %s', record_path) f = open(record_path, 'wb') try: writer = csv.writer(f, delimiter=',', lineterminator=os.linesep, quotechar='"') - install = self.get_finalized_command('install') + install = self.get_finalized_command('install_dist') for fpath in install.get_outputs(): if fpath.endswith('.pyc') or fpath.endswith('.pyo'): diff --git a/distutils2/command/install_headers.py b/distutils2/command/install_headers.py index bece686..86db07f 100644 --- a/distutils2/command/install_headers.py +++ b/distutils2/command/install_headers.py @@ -4,7 +4,7 @@ Implements the Distutils 'install_headers' command, to install C/C++ header files to the Python include directory.""" -from distutils2.core import Command +from distutils2.command.cmd import Command # XXX force is never used @@ -26,7 +26,7 @@ class install_headers(Command): self.outfiles = [] def finalize_options(self): - self.set_undefined_options('install', + self.set_undefined_options('install_dist', ('install_headers', 'install_dir'), 'force') diff --git a/distutils2/command/install_lib.py b/distutils2/command/install_lib.py index 223205e..f9de095 100644 --- a/distutils2/command/install_lib.py +++ b/distutils2/command/install_lib.py @@ -7,7 +7,7 @@ Implements the Distutils 'install_lib' command import os import sys -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import DistutilsOptionError @@ -52,7 +52,7 @@ class install_lib(Command): negative_opt = {'no-compile' : 'compile'} def initialize_options(self): - # let the 'install' command dictate our installation directory + # let the 'install_dist' command dictate our installation directory self.install_dir = None self.build_dir = None self.force = 0 @@ -62,9 +62,9 @@ class install_lib(Command): def finalize_options(self): # Get all the information we need to install pure Python modules - # from the umbrella 'install' command -- build (source) directory, + # from the umbrella 'install_dist' command -- build (source) directory, # install (target) directory, and whether to compile .py files. - self.set_undefined_options('install', + self.set_undefined_options('install_dist', ('build_lib', 'build_dir'), ('install_lib', 'install_dir'), 'force', 'compile', 'optimize', 'skip_build') @@ -121,11 +121,11 @@ class install_lib(Command): from distutils2.util import byte_compile - # Get the "--root" directory supplied to the "install" command, + # Get the "--root" directory supplied to the "install_dist" command, # and use it as a prefix to strip off the purported filename # encoded in bytecode files. This is far from complete, but it # should at least generate usable bytecode in RPM distributions. - install_root = self.get_finalized_command('install').root + install_root = self.get_finalized_command('install_dist').root if self.compile: byte_compile(files, optimize=0, diff --git a/distutils2/command/install_scripts.py b/distutils2/command/install_scripts.py index 3fe6f9b..c0b35b1 100644 --- a/distutils2/command/install_scripts.py +++ b/distutils2/command/install_scripts.py @@ -7,8 +7,8 @@ Python scripts.""" import os -from distutils2.core import Command -from distutils2 import log +from distutils2.command.cmd import Command +from distutils2 import logger from stat import ST_MODE class install_scripts (Command): @@ -33,7 +33,7 @@ class install_scripts (Command): def finalize_options (self): self.set_undefined_options('build', ('build_scripts', 'build_dir')) - self.set_undefined_options('install', + self.set_undefined_options('install_dist', ('install_scripts', 'install_dir'), 'force', 'skip_build') @@ -46,10 +46,10 @@ class install_scripts (Command): # all the scripts we just installed. for file in self.get_outputs(): if self.dry_run: - log.info("changing mode of %s", file) + logger.info("changing mode of %s", file) else: mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777 - log.info("changing mode of %s to %o", file, mode) + logger.info("changing mode of %s to %o", file, mode) os.chmod(file, mode) def get_inputs (self): diff --git a/distutils2/command/register.py b/distutils2/command/register.py index 07d692e..687a514 100644 --- a/distutils2/command/register.py +++ b/distutils2/command/register.py @@ -10,10 +10,11 @@ import urllib2 import getpass import urlparse import StringIO +import logging from warnings import warn from distutils2.command.cmd import Command -from distutils2 import log +from distutils2 import logger from distutils2.util import (metadata_to_dict, read_pypirc, generate_pypirc, DEFAULT_REPOSITORY, DEFAULT_REALM, get_pypirc_path) @@ -97,14 +98,14 @@ class register(Command): ''' Fetch the list of classifiers from the server. ''' response = urllib2.urlopen(self.repository+'?:action=list_classifiers') - log.info(response.read()) + logger.info(response.read()) def verify_metadata(self): ''' Send the metadata to the package index server to be checked. ''' # send the info to the server and report the result - (code, result) = self.post_to_server(self.build_post_data('verify')) - log.info('Server response (%s): %s' % (code, result)) + code, result = self.post_to_server(self.build_post_data('verify')) + logger.info('Server response (%s): %s' % (code, result)) def send_metadata(self): @@ -154,7 +155,7 @@ We need to know who you are, so please choose either: 2. register as a new user, 3. have the server generate a new password for you (and email it to you), or 4. quit -Your selection [default 1]: ''', log.INFO) +Your selection [default 1]: ''', logging.INFO) choice = raw_input() if not choice: @@ -177,7 +178,7 @@ Your selection [default 1]: ''', log.INFO) code, result = self.post_to_server(self.build_post_data('submit'), auth) self.announce('Server response (%s): %s' % (code, result), - log.INFO) + logging.INFO) # possibly save the login if code == 200: @@ -187,9 +188,10 @@ Your selection [default 1]: ''', log.INFO) self.distribution.password = password else: self.announce(('I can store your PyPI login so future ' - 'submissions will be faster.'), log.INFO) + 'submissions will be faster.'), + logging.INFO) self.announce('(the login will be stored in %s)' % \ - get_pypirc_path(), log.INFO) + get_pypirc_path(), logging.INFO) choice = 'X' while choice.lower() not in 'yn': choice = raw_input('Save your login (y/N)?') @@ -217,18 +219,18 @@ Your selection [default 1]: ''', log.INFO) data['email'] = raw_input(' EMail: ') code, result = self.post_to_server(data) if code != 200: - log.info('Server response (%s): %s' % (code, result)) + logger.info('Server response (%s): %s' % (code, result)) else: - log.info('You will receive an email shortly.') - log.info(('Follow the instructions in it to ' - 'complete registration.')) + logger.info('You will receive an email shortly.') + logger.info(('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) - log.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 @@ -244,7 +246,7 @@ Your selection [default 1]: ''', log.INFO) if 'name' in data: self.announce('Registering %s to %s' % (data['name'], self.repository), - log.INFO) + logging.INFO) # Build up the MIME payload for the urllib2 POST data boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' sep_boundary = '\n--' + boundary diff --git a/distutils2/command/sdist.py b/distutils2/command/sdist.py index 50c685a..b15f0a2 100644 --- a/distutils2/command/sdist.py +++ b/distutils2/command/sdist.py @@ -1,8 +1,6 @@ """distutils.command.sdist Implements the Distutils 'sdist' command (create a source distribution).""" - - import os import string import sys @@ -10,17 +8,18 @@ from glob import glob from warnings import warn from shutil import rmtree import re +from StringIO import StringIO try: from shutil import get_archive_formats except ImportError: from distutils2._backport.shutil import get_archive_formats -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import (DistutilsPlatformError, DistutilsOptionError, DistutilsTemplateError) from distutils2.manifest import Manifest -from distutils2 import log +from distutils2 import logger from distutils2.util import convert_path def show_formats(): @@ -44,8 +43,6 @@ class sdist(Command): description = "create a source distribution (tarball, zip file, etc.)" user_options = [ - ('template=', 't', - "name of manifest template file [default: MANIFEST.in]"), ('manifest=', 'm', "name of manifest file [default: MANIFEST]"), ('use-defaults', None, @@ -93,9 +90,6 @@ class sdist(Command): 'nt': 'zip' } def initialize_options(self): - # 'template' and 'manifest' are, respectively, the names of - # the manifest template and manifest file. - self.template = None self.manifest = None # 'use_defaults': if true, we will include the default file set @@ -123,8 +117,6 @@ class sdist(Command): def finalize_options(self): if self.manifest is None: self.manifest = "MANIFEST" - if self.template is None: - self.template = "MANIFEST.in" self.ensure_string_list('formats') if self.formats is None: @@ -176,18 +168,16 @@ class sdist(Command): reading the manifest, or just using the default file set -- it all depends on the user's options. """ - template_exists = os.path.isfile(self.template) + template_exists = len(self.distribution.extra_files) > 0 if not template_exists: - self.warn(("manifest template '%s' does not exist " + - "(using default file list)") % - self.template) - + self.warn('Using default file list') self.filelist.findall() if self.use_defaults: self.add_defaults() if template_exists: - self.filelist.read_template(self.template) + template = '\n'.join(self.distribution.extra_files) + self.filelist.read_template(StringIO(template)) if self.prune: self.prune_file_list() @@ -297,12 +287,12 @@ class sdist(Command): msg = "copying files to %s..." % base_dir if not files: - log.warn("no files to distribute -- empty manifest?") + logger.warn("no files to distribute -- empty manifest?") else: - log.info(msg) + logger.info(msg) for file in files: if not os.path.isfile(file): - log.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) @@ -338,7 +328,7 @@ class sdist(Command): if not self.keep_temp: if self.dry_run: - log.info('Removing %s' % base_dir) + logger.info('Removing %s' % base_dir) else: rmtree(base_dir) diff --git a/distutils2/command/test.py b/distutils2/command/test.py index d64ebd3..57c23bf 100644 --- a/distutils2/command/test.py +++ b/distutils2/command/test.py @@ -2,7 +2,7 @@ import os import sys import unittest -from distutils2.core import Command +from distutils2.command.cmd import Command from distutils2.errors import DistutilsOptionError from distutils2.util import resolve_name diff --git a/distutils2/command/upload.py b/distutils2/command/upload.py index 3fdb5b3..b5e072c 100644 --- a/distutils2/command/upload.py +++ b/distutils2/command/upload.py @@ -4,6 +4,7 @@ Implements the Distutils 'upload' subcommand (upload package to PyPI).""" import os import socket import platform +import logging from urllib2 import urlopen, Request, HTTPError from base64 import standard_b64encode import urlparse @@ -18,9 +19,7 @@ except ImportError: from distutils2.errors import DistutilsOptionError from distutils2.util import spawn -from distutils2 import log from distutils2.command.cmd import Command -from distutils2 import log from distutils2.util import (metadata_to_dict, read_pypirc, DEFAULT_REPOSITORY, DEFAULT_REALM) @@ -173,7 +172,7 @@ class upload(Command): body = body.getvalue() self.announce("Submitting %s to %s" % (filename, self.repository), - log.INFO) + logging.INFO) # build the Request headers = {'Content-type': @@ -189,7 +188,7 @@ class upload(Command): status = result.code reason = result.msg except socket.error, e: - self.announce(str(e), log.ERROR) + self.announce(str(e), logging.ERROR) return except HTTPError, e: status = e.code @@ -197,11 +196,11 @@ class upload(Command): if status == 200: self.announce('Server response (%s): %s' % (status, reason), - log.INFO) + logging.INFO) else: self.announce('Upload failed (%s): %s' % (status, reason), - log.ERROR) + logging.ERROR) if self.show_response: msg = '\n'.join(('-' * 75, result.read(), '-' * 75)) - self.announce(msg, log.INFO) + self.announce(msg, logging.INFO) diff --git a/distutils2/command/upload_docs.py b/distutils2/command/upload_docs.py index 79f204f..8147f98 100644 --- a/distutils2/command/upload_docs.py +++ b/distutils2/command/upload_docs.py @@ -4,12 +4,13 @@ import httplib import socket import urlparse import zipfile +import logging try: from cStringIO import StringIO except ImportError: from StringIO import StringIO -from distutils2 import log +from distutils2 import logger from distutils2.command.upload import upload from distutils2.command.cmd import Command from distutils2.errors import DistutilsFileError @@ -114,8 +115,7 @@ class upload_docs(Command): credentials = self.username + ':' + self.password auth = "Basic " + base64.encodestring(credentials).strip() - self.announce("Submitting documentation to %s" % (self.repository), - log.INFO) + self.announce("Submitting documentation to %s" % (self.repository)) schema, netloc, url, params, query, fragments = \ urlparse.urlparse(self.repository) @@ -135,24 +135,22 @@ class upload_docs(Command): conn.endheaders() conn.send(body) except socket.error, e: - self.announce(str(e), log.ERROR) + self.announce(str(e), logging.ERROR) return r = conn.getresponse() if r.status == 200: - self.announce('Server response (%s): %s' % (r.status, r.reason), - log.INFO) + self.announce('Server response (%s): %s' % (r.status, r.reason)) elif r.status == 301: location = r.getheader('Location') if location is None: location = 'http://packages.python.org/%s/' % name - self.announce('Upload successful. Visit %s' % location, - log.INFO) + self.announce('Upload successful. Visit %s' % location) else: self.announce('Upload failed (%s): %s' % (r.status, r.reason), - log.ERROR) + logging.ERROR) if self.show_response: msg = '\n'.join(('-' * 75, r.read(), '-' * 75)) - self.announce(msg, log.INFO) + self.announce(msg) |
