Command to launch interpreter with spack in sys.path
This commit is contained in:
parent
09fd944de5
commit
3fb7699e1e
1 changed files with 21 additions and 0 deletions
21
lib/spack/spack/cmd/python.py
Normal file
21
lib/spack/spack/cmd/python.py
Normal file
|
@ -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()))
|
Loading…
Reference in a new issue