Fix setup commands help messages

This commit is contained in:
Kovid Goyal 2009-09-07 13:48:26 -06:00
parent 039aab161c
commit 1ce7847d8d
4 changed files with 31 additions and 26 deletions

View File

@ -42,9 +42,8 @@ def main(args=sys.argv):
parser = option_parser() parser = option_parser()
command.add_all_options(parser) command.add_all_options(parser)
lines = parser.usage.splitlines() parser.set_usage('Usage: python setup.py %s [options]\n\n'%args[1]+\
lines[0] = 'Usage: python setup.py %s [options]'%args[1] command.description)
parser.set_usage('\n'.join(lines))
opts, args = parser.parse_args(args) opts, args = parser.parse_args(args)
command.run_all(opts) command.run_all(opts)

View File

@ -11,7 +11,7 @@ __all__ = [
'build', 'build',
'gui', 'gui',
'develop', 'develop',
'clean' 'clean', 'clean_backups',
] ]
import os, shutil import os, shutil
@ -32,6 +32,22 @@ develop = Develop()
from setup.gui import GUI from setup.gui import GUI
gui = 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): class Clean(Command):
description='''Delete all computer generated files in the source tree''' description='''Delete all computer generated files in the source tree'''
@ -55,13 +71,6 @@ class Clean(Command):
cmd.clean() cmd.clean()
def clean(self): 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')): for dir in ('dist', os.path.join('src', 'calibre.egg-info')):
shutil.rmtree(dir, ignore_errors=True) shutil.rmtree(dir, ignore_errors=True)

View File

@ -157,9 +157,7 @@ if iswindows:
class Build(Command): class Build(Command):
def add_options(self, parser): description = textwrap.dedent('''\
parser.set_usage(parser.usage + textwrap.dedent('''
calibre depends on several python extensions written in C/C++. calibre depends on several python extensions written in C/C++.
This command will compile them. You can influence the compile This command will compile them. You can influence the compile
process by several environment variables, listed below: process by several environment variables, listed below:
@ -179,9 +177,11 @@ class Build(Command):
PODOFO_LIB_DIR - podofo library files PODOFO_LIB_DIR - podofo library files
QMAKE - Path to qmake 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'] choices = [e.name for e in extensions]+['all']
parser.add_option('-1', '--only', choices=choices, default='all', parser.add_option('-1', '--only', choices=choices, default='all',
help=('Build only the named extension. Available: '+ help=('Build only the named extension. Available: '+

View File

@ -30,21 +30,18 @@ sys.exit({func!s}())
class Develop(Command): 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 <prefix>/bin where <prefix> is
the prefix of your python installation. This can be controlled
via the --prefix option.
''')
MODE = 0755 MODE = 0755
sub_commands = ['build', 'translations'] sub_commands = ['build', 'translations']
def add_options(self, parser): 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 <prefix>/bin where <prefix> is
the prefix of your python installation. This can be controlled
via the --prefix option.
'''))
parser.add_option('--prefix', parser.add_option('--prefix',
help='Binaries will be installed in <prefix>/bin') help='Binaries will be installed in <prefix>/bin')