2013-02-19 07:52:50 +00:00
|
|
|
#!/usr/bin/env python2.7
|
2013-02-14 01:50:44 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
# Find spack's location and its prefix.
|
2013-05-15 23:47:50 +00:00
|
|
|
SPACK_FILE = os.path.realpath(os.path.expanduser(__file__))
|
|
|
|
os.environ["SPACK_FILE"] = SPACK_FILE
|
2013-02-14 01:50:44 +00:00
|
|
|
SPACK_PREFIX = os.path.dirname(os.path.dirname(SPACK_FILE))
|
|
|
|
|
|
|
|
# Allow spack libs to be imported in our scripts
|
|
|
|
SPACK_LIB_PATH = os.path.join(SPACK_PREFIX, "lib", "spack")
|
|
|
|
sys.path.insert(0, SPACK_LIB_PATH)
|
|
|
|
|
|
|
|
# clean up the scope and start using spack package instead.
|
|
|
|
del SPACK_FILE, SPACK_PREFIX, SPACK_LIB_PATH
|
|
|
|
import spack
|
2013-04-04 16:52:15 +00:00
|
|
|
import spack.tty as tty
|
2013-02-14 01:50:44 +00:00
|
|
|
|
|
|
|
# Command parsing
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description='Spack: the Supercomputing PACKage Manager.')
|
2013-02-22 08:20:24 +00:00
|
|
|
parser.add_argument('-V', '--version', action='version',
|
|
|
|
version="%s" % spack.spack_version)
|
|
|
|
parser.add_argument('-v', '--verbose', action='store_true', dest='verbose',
|
|
|
|
help="print additional output during builds")
|
|
|
|
parser.add_argument('-d', '--debug', action='store_true', dest='debug',
|
|
|
|
help="write out debug logs during compile")
|
2013-02-14 01:50:44 +00:00
|
|
|
|
|
|
|
# each command module implements a parser() function, to which we pass its
|
|
|
|
# subparser for setup.
|
2013-04-09 06:00:42 +00:00
|
|
|
subparsers = parser.add_subparsers(
|
|
|
|
title="commands", metavar='<command>', dest="command")
|
2013-02-14 01:50:44 +00:00
|
|
|
|
|
|
|
import spack.cmd
|
|
|
|
for cmd in spack.cmd.commands:
|
|
|
|
module = spack.cmd.get_module(cmd)
|
2013-02-22 08:20:24 +00:00
|
|
|
subparser = subparsers.add_parser(cmd, help=module.description)
|
2013-02-14 01:50:44 +00:00
|
|
|
module.setup_parser(subparser)
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# Set up environment based on args.
|
|
|
|
spack.verbose = args.verbose
|
2013-02-22 03:27:27 +00:00
|
|
|
spack.debug = args.debug
|
2013-02-14 01:50:44 +00:00
|
|
|
|
|
|
|
# Try to load the particular command asked for and run it
|
|
|
|
command = spack.cmd.get_command(args.command)
|
2013-04-04 16:52:15 +00:00
|
|
|
try:
|
|
|
|
command(parser, args)
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
tty.die("Got a keyboard interrupt from the user.")
|