summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-12-19 20:59:13 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2015-12-19 20:59:13 -0800
commit9edba1848968ce6539e6c3ee51fe56180f02ada8 (patch)
treea2e4e9b0db3bbf436283fd0184c12339e8d1ff77 /lib
parent53cb7e828bdfd83a99e44e2c36bdf9219b941143 (diff)
parent527154e6dfa0c9e5f35aed56adad3279bac4eac3 (diff)
downloadspack-9edba1848968ce6539e6c3ee51fe56180f02ada8.tar.gz
spack-9edba1848968ce6539e6c3ee51fe56180f02ada8.tar.bz2
spack-9edba1848968ce6539e6c3ee51fe56180f02ada8.tar.xz
spack-9edba1848968ce6539e6c3ee51fe56180f02ada8.zip
Merge pull request #230 from nolta/fix-env-mod-sys-type
fix environment module path when $SYS_TYPE isn't defined
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/python.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/spack/spack/cmd/python.py b/lib/spack/spack/cmd/python.py
index e26b8d3e79..5325e8fd9a 100644
--- a/lib/spack/spack/cmd/python.py
+++ b/lib/spack/spack/cmd/python.py
@@ -32,13 +32,16 @@ import spack
def setup_parser(subparser):
subparser.add_argument(
+ '-c', dest='python_command', help='Command to execute.')
+ subparser.add_argument(
'python_args', nargs=argparse.REMAINDER, help="File to run plus arguments.")
description = "Launch an interpreter as spack would launch a command"
def python(parser, args):
# Fake a main python shell by setting __name__ to __main__.
- console = code.InteractiveConsole({'__name__' : '__main__'})
+ console = code.InteractiveConsole({'__name__' : '__main__',
+ 'spack' : spack})
if "PYTHONSTARTUP" in os.environ:
startup_file = os.environ["PYTHONSTARTUP"]
@@ -47,7 +50,10 @@ def python(parser, args):
console.runsource(startup.read(), startup_file, 'exec')
python_args = args.python_args
- if python_args:
+ python_command = args.python_command
+ if python_command:
+ console.runsource(python_command)
+ elif python_args:
sys.argv = python_args
with open(python_args[0]) as file:
console.runsource(file.read(), python_args[0], 'exec')