def get_command_class(self, command): # Better raising an error than having some weird behavior for a command # we don't support if self.script_args is not None \ and command in self.script_args \ and command not in _BENTO_MONKEYED_CLASSES: raise ValueError("Command %s is not supported by bento.distutils compat layer" % command) return Distribution.get_command_class(self, command)
def get_command_class(self, command): klass = Distribution.get_command_class(self, command) if command in ['build', 'install']: class klass(klass): sub_commands = klass.sub_commands + [ ('%s_ram' % command, lambda self: True), ] klass.__name__ = command return klass
try: from setuptools import setup as setup_orig, Distribution, Command except ImportError: from distutils.core import setup as setup_orig, Distribution, Command dist = Distribution() build_orig = dist.get_command_class('build') sdist_orig = dist.get_command_class('sdist') class generate_man(Command): description = 'Generate man files' # Some boilerplate code: user_options = [] def initialize_options(self): pass def finalize_options(self): pass def run(self): self.spawn(['misc/git-blackhole.1.sh']) self.spawn(['misc/git-blackhole-basic-usage.5.sh']) class build(build_orig): def run(self): self.run_command('generate_man') build_orig.run(self)