blob: d2f857198408bc4241e950fc274e8fb95c7cd85a [file] [log] [blame] [edit]
#!/usr/bin/env python
from __future__ import print_function
import sys
from subprocess import call
def usage():
print("""\
usage: run COMMAND
Where COMMAND is one of:
build build an installable package
checks runs lint, build, coverage
clean remove any derived objects
coverage run test coverage
develop install a 'developable' package
format run autopep8 over the source
install install a complete package
lint run lint over the source
pull pull latest sources from repo
push push latest sources from repo
tests run tests""")
def main(argv):
if len(argv) != 1 or argv[0] in ('-h', '--help', 'help'):
usage()
return 2
return run(argv[0])
def run(cmd):
if cmd == 'build':
return call([sys.executable, 'setup.py', 'build', '--quiet'])
if cmd == 'checks':
ret = run('lint')
if not ret:
ret = run('build')
if not ret:
ret = run('coverage')
return ret
if cmd == 'clean':
return call(['git', 'clean', '-fxd'])
if cmd == 'coverage':
ret = call(['coverage', 'erase'])
if not ret:
ret = call(['coverage', 'run', '-m', 'typ', '-j', '1'])
if not ret:
ret = call(['coverage', 'report', '-i',
'--omit', '*/site-packages/*'])
return ret
if cmd == 'develop':
ret = call([sys.executable, 'setup.py', 'develop'])
if cmd == 'format':
return call('autopep8 --in-place *.py */*.py */*/*.py', shell=True)
if cmd == 'install':
ret = call([sys.executable, 'setup.py', 'install', '--user'])
if cmd == 'lint':
ret = call('pylint --rcfile=pylintrc */*.py */*/*.py', shell=True)
sret = call('pep8 *.py */*.py */*/*.py', shell=True)
return ret or sret
if cmd == 'install':
return call([sys.executable, 'setup.py', 'install'])
if cmd == 'pull':
return call(['git', 'pull'])
if cmd == 'push':
return call(['git', 'push'])
if cmd == 'tests':
return call([sys.executable, '-m', 'typ'])
else:
print('Unknown command "%s"' % cmd)
usage()
return 2
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))