This commit is contained in:
Kovid Goyal 2017-02-01 10:17:39 +05:30
parent 71e4857a47
commit 59a430f23a

View File

@ -8,11 +8,16 @@ __docformat__ = 'restructuredtext en'
import sys, os
def check_version_info():
vi = sys.version_info
if vi[0] == 2 and vi[1:3] >= (7, 9):
return None
raise SystemExit('calibre requires python >= 2.7.9 and < 3. Current python version: %s' % vi)
return
raise SystemExit(
'calibre requires python >= 2.7.9 and < 3. Current python version: %s'
% vi)
check_version_info()
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
@ -20,18 +25,30 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import setup.commands as commands
from setup import prints, get_warnings
def option_parser():
import optparse
parser = optparse.OptionParser()
parser.add_option('-c', '--clean', default=False, action='store_true',
parser.add_option(
'-c',
'--clean',
default=False,
action='store_true',
help=('Instead of running the command delete all files generated '
'by the command'))
parser.add_option('--clean-backups', default=False, action='store_true',
parser.add_option(
'--clean-backups',
default=False,
action='store_true',
help='Delete all backup files from the source tree')
parser.add_option('--clean-all', default=False, action='store_true',
parser.add_option(
'--clean-all',
default=False,
action='store_true',
help='Delete all machine generated files from the source tree')
return parser
def clean_backups():
for root, _, files in os.walk('.'):
for name in files:
@ -46,7 +63,7 @@ def main(args=sys.argv):
print('\nWhere command is one of:')
print()
for x in sorted(commands.__all__):
print('%-20s -'%x, end=' ')
print('%-20s -' % x, end=' ')
c = getattr(commands, x)
desc = getattr(c, 'short_description', c.description)
print(desc)
@ -57,15 +74,15 @@ def main(args=sys.argv):
command = args[1]
if command not in commands.__all__:
print (command, 'is not a recognized command.')
print ('Valid commands:', ', '.join(commands.__all__))
print(command, 'is not a recognized command.')
print('Valid commands:', ', '.join(commands.__all__))
return 1
command = getattr(commands, command)
parser = option_parser()
command.add_all_options(parser)
parser.set_usage('Usage: python setup.py %s [options]\n\n'%args[1]+
parser.set_usage('Usage: python setup.py %s [options]\n\n' % args[1] +
command.description)
opts, args = parser.parse_args(args)
@ -97,5 +114,6 @@ def main(args=sys.argv):
return 0
if __name__ == '__main__':
sys.exit(main())