diff --git a/setup.py b/setup.py index 76ddd8b43a..516a3ad198 100644 --- a/setup.py +++ b/setup.py @@ -42,9 +42,8 @@ def main(args=sys.argv): parser = option_parser() command.add_all_options(parser) - lines = parser.usage.splitlines() - lines[0] = 'Usage: python setup.py %s [options]'%args[1] - parser.set_usage('\n'.join(lines)) + parser.set_usage('Usage: python setup.py %s [options]\n\n'%args[1]+\ + command.description) opts, args = parser.parse_args(args) command.run_all(opts) diff --git a/setup/commands.py b/setup/commands.py index a05d158e01..1d71d4753e 100644 --- a/setup/commands.py +++ b/setup/commands.py @@ -11,7 +11,7 @@ __all__ = [ 'build', 'gui', 'develop', - 'clean' + 'clean', 'clean_backups', ] import os, shutil @@ -32,6 +32,22 @@ develop = Develop() from setup.gui import GUI gui = GUI() +class CleanBackups(Command): + + description='Delete all backup files in the calibre source tree' + + def clean(self): + return self.run(None) + + def run(self, opts=None): + for root, _, files in os.walk(self.d(self.SRC)): + for name in files: + for t in ('.pyc', '.pyo', '~', '.swp', '.swo'): + if name.endswith(t): + os.remove(os.path.join(root, name)) + +clean_backups = CleanBackups() + class Clean(Command): description='''Delete all computer generated files in the source tree''' @@ -55,13 +71,6 @@ class Clean(Command): cmd.clean() def clean(self): - for root, _, files in os.walk(self.d(self.SRC)): - for name in files: - for t in ('.pyc', '.pyo', '~', '.swp', '.swo'): - if name.endswith(t): - os.remove(os.path.join(root, name)) - break - for dir in ('dist', os.path.join('src', 'calibre.egg-info')): shutil.rmtree(dir, ignore_errors=True) diff --git a/setup/extensions.py b/setup/extensions.py index 25b4979022..1be58a5839 100644 --- a/setup/extensions.py +++ b/setup/extensions.py @@ -157,9 +157,7 @@ if iswindows: class Build(Command): - def add_options(self, parser): - parser.set_usage(parser.usage + textwrap.dedent(''' - + description = textwrap.dedent('''\ calibre depends on several python extensions written in C/C++. This command will compile them. You can influence the compile process by several environment variables, listed below: @@ -179,9 +177,11 @@ class Build(Command): PODOFO_LIB_DIR - podofo library files QMAKE - Path to qmake - VS90COMNTOOLS - Location of Microsoft Visual Studio 9 Tools + VS90COMNTOOLS - Location of Microsoft Visual Studio 9 Tools (windows only) - ''')) + ''') + + def add_options(self, parser): choices = [e.name for e in extensions]+['all'] parser.add_option('-1', '--only', choices=choices, default='all', help=('Build only the named extension. Available: '+ diff --git a/setup/install.py b/setup/install.py index 540de730e6..bf726899c0 100644 --- a/setup/install.py +++ b/setup/install.py @@ -30,21 +30,18 @@ sys.exit({func!s}()) class Develop(Command): - description = 'Setup a development environment' + description = textwrap.dedent('''\ + Setup a development environment for calibre. + This allows you to run calibre directly from the source tree. + Binaries will be installed in /bin where is + the prefix of your python installation. This can be controlled + via the --prefix option. + ''') MODE = 0755 sub_commands = ['build', 'translations'] def add_options(self, parser): - parser.set_usage(textwrap.dedent('''\ - *** - - Setup a development environment for calibre. - This allows you to run calibre directly from the source tree. - Binaries will be installed in /bin where is - the prefix of your python installation. This can be controlled - via the --prefix option. - ''')) parser.add_option('--prefix', help='Binaries will be installed in /bin')