summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2013-02-13 17:50:44 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2013-02-13 17:50:44 -0800
commitcc76c0f5f9f8021cfb7423a226bd431c00d791ce (patch)
tree44bdf9954ab913a17ca3bd01ec6042fb34a18694 /bin
downloadspack-cc76c0f5f9f8021cfb7423a226bd431c00d791ce.tar.gz
spack-cc76c0f5f9f8021cfb7423a226bd431c00d791ce.tar.bz2
spack-cc76c0f5f9f8021cfb7423a226bd431c00d791ce.tar.xz
spack-cc76c0f5f9f8021cfb7423a226bd431c00d791ce.zip
Initial version of spack with one package: cmake
Diffstat (limited to 'bin')
-rwxr-xr-xbin/spack41
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/spack b/bin/spack
new file mode 100755
index 0000000000..1fd47d5e8c
--- /dev/null
+++ b/bin/spack
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import argparse
+
+# Find spack's location and its prefix.
+SPACK_FILE = os.environ["SPACK_FILE"] = os.path.expanduser(__file__)
+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
+
+# Command parsing
+parser = argparse.ArgumentParser(
+ description='Spack: the Supercomputing PACKage Manager.')
+parser.add_argument('-V', '--version', action='version', version="%s" % spack.version)
+parser.add_argument('-v', '--verbose', action='store_true', dest='verbose')
+
+# each command module implements a parser() function, to which we pass its
+# subparser for setup.
+subparsers = parser.add_subparsers(title="subcommands", dest="command")
+
+import spack.cmd
+for cmd in spack.cmd.commands:
+ subparser = subparsers.add_parser(cmd)
+ module = spack.cmd.get_module(cmd)
+ module.setup_parser(subparser)
+args = parser.parse_args()
+
+# Set up environment based on args.
+spack.verbose = args.verbose
+
+# Try to load the particular command asked for and run it
+command = spack.cmd.get_command(args.command)
+command(args)