summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2013-10-11 23:24:06 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2013-10-11 23:24:06 -0700
commit3fb7699e1ee9f8fcc43040fd17158a07cc03091f (patch)
treef754da0fcd0a1c46b8f6058908761018a6a33cd5 /lib
parent09fd944de5445a29aa1828cd74d0083dcee057cb (diff)
downloadspack-3fb7699e1ee9f8fcc43040fd17158a07cc03091f.tar.gz
spack-3fb7699e1ee9f8fcc43040fd17158a07cc03091f.tar.bz2
spack-3fb7699e1ee9f8fcc43040fd17158a07cc03091f.tar.xz
spack-3fb7699e1ee9f8fcc43040fd17158a07cc03091f.zip
Command to launch interpreter with spack in sys.path
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/python.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/spack/spack/cmd/python.py b/lib/spack/spack/cmd/python.py
new file mode 100644
index 0000000000..746f0fbe50
--- /dev/null
+++ b/lib/spack/spack/cmd/python.py
@@ -0,0 +1,21 @@
+import code
+import os
+import platform
+from contextlib import closing
+
+import spack
+
+description = "Launch an interpreter as spack would launch a command"
+
+def python(parser, args):
+ console = code.InteractiveConsole()
+
+ if "PYTHONSTARTUP" in os.environ:
+ startup_file = os.environ["PYTHONSTARTUP"]
+ if os.path.isfile(startup_file):
+ with closing(open(startup_file)) as startup:
+ console.runsource(startup.read(), startup_file, 'exec')
+
+ console.interact("Spack version %s\nPython %s, %s %s"""
+ % (spack.spack_version, platform.python_version(),
+ platform.system(), platform.machine()))