diff options
Diffstat (limited to 'setuptools')
| -rw-r--r-- | setuptools/__init__.py | 35 | ||||
| -rw-r--r-- | setuptools/command/bdist_egg.py | 14 | ||||
| -rw-r--r-- | setuptools/dist.py | 83 |
3 files changed, 122 insertions, 10 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 12850965..0523d160 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -4,7 +4,7 @@ import distutils.core, setuptools.command from setuptools.dist import Distribution, Feature from setuptools.extension import Extension from setuptools.depends import Require -from distutils.core import Command +from distutils.core import Command as _Command from distutils.util import convert_path import os.path @@ -37,6 +37,8 @@ def find_packages(where='.'): return out + + def setup(**attrs): """Do package setup @@ -47,3 +49,34 @@ def setup(**attrs): """ attrs.setdefault("distclass",Distribution) return distutils.core.setup(**attrs) + + +class Command(_Command): + __doc__ = _Command.__doc__ + + command_consumes_arguments = False + + def reinitialize_command(self, command, reinit_subcommands=0, **kw): + cmd = _Command.reinitialize_command(self, command, reinit_subcommands) + for k,v in kw.items(): + setattr(cmd,k,v) # update command with keywords + return cmd + + + + + + + + + + + + + + + + + + + diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index ee6f2e80..18001eff 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -4,7 +4,7 @@ Build .egg distributions""" # This module should be kept compatible with Python 2.3 import os -from distutils.core import Command +from setuptools import Command from distutils.util import get_platform from distutils.dir_util import create_tree, remove_tree, ensure_relative,mkpath from distutils.sysconfig import get_python_version, get_python_lib @@ -234,16 +234,16 @@ class bdist_egg(Command): return match.group(1) def call_command(self,cmdname,**kw): - cmd = self.reinitialize_command(cmdname) + """Invoke reinitialized command `cmdname` with keyword args""" for dirname in INSTALL_DIRECTORY_ATTRS: - if dirname in cmd.__dict__: # don't overwrite methods! - setattr(cmd,dirname,self.bdist_dir) - cmd.skip_build = self.skip_build - for k,v in kw.items(): - setattr(cmd,k,v) + kw.setdefault(dirname,self.bdist_dir) + kw.setdefault('skip_build',self.skip_build) + + cmd = self.reinitialize_command(cmdname, **kw) self.run_command(cmdname) return cmd + # Attribute names of options for commands that might need to be convinced to # install to the egg build directory diff --git a/setuptools/dist.py b/setuptools/dist.py index 4d297c93..a39b4a13 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -1,4 +1,5 @@ __all__ = ['Distribution', 'Feature'] + from distutils.core import Distribution as _Distribution from distutils.core import Extension from setuptools.depends import Require @@ -7,8 +8,37 @@ from setuptools.command.install import install from setuptools.command.install_lib import install_lib from distutils.errors import DistutilsOptionError, DistutilsPlatformError from distutils.errors import DistutilsSetupError + sequence = tuple, list + + + + + + + + + + + + + + + + + + + + + + + + + + + + class Distribution(_Distribution): """Distribution with support for features, tests, and package data @@ -54,7 +84,6 @@ class Distribution(_Distribution): the distribution. They are used by the feature subsystem to configure the distribution for the included and excluded features. """ - def __init__ (self, attrs=None): have_package_data = hasattr(self, "package_data") if not have_package_data: @@ -83,6 +112,15 @@ class Distribution(_Distribution): """Convert feature name to corresponding option attribute name""" return 'with_'+name.replace('-','_') + + + + + + + + + def _set_global_opts_from_features(self): """Add --with-X/--without-X options based on optional features""" @@ -277,17 +315,58 @@ class Distribution(_Distribution): ) map(self.exclude_package, packages) + + + + + + + + + + + def _parse_command_opts(self, parser, args): # Remove --with-X/--without-X options when processing command args self.global_options = self.__class__.global_options self.negative_opt = self.__class__.negative_opt - return _Distribution._parse_command_opts(self, parser, args) + + # Handle commands that want to consume all remaining arguments + command = args[0] + nargs = _Distribution._parse_command_opts(self, parser, args) + + cmd_class = self.get_command_class(command) + if getattr(cmd_class,'command_consumes_arguments',None): + self.get_option_dict(command)['args'] = ("command line", nargs) + if nargs is not None: + return [] + + return nargs + def has_dependencies(self): return not not self.requires + + + + + + + + + + + + + + + + + + def get_cmdline_options(self): """Return a '{cmd: {opt:val}}' map of all command-line options |
