Skip to content

Commit

Permalink
supply PYTHONPATH to the terminal started from .build/shell.py
Browse files Browse the repository at this point in the history
  • Loading branch information
j4yk committed Sep 26, 2015
1 parent 12b14a9 commit b2b0ce3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .build/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
import environment, code
print "\033[33;5;7m \nUse terminal() to drop into a system console\n \033[0m"
def terminal():
module_path = os.path.abspath(os.path.dirname(__file__))
if module_path in sys.path:
paths = sys.path[:sys.path.index(module_path)]
else:
paths = sys.path
os.putenv("PYTHONPATH", os.pathsep.join(paths))
os.system(os.environ.get("COMSPEC") or os.environ.get("SHELL") or "/bin/sh")
code.interact(local=locals())

1 comment on commit b2b0ce3

@j4yk
Copy link
Contributor Author

@j4yk j4yk commented on b2b0ce3 Sep 26, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the paths before the current module path are exported to avoid including the site-packages etc. of the interpreter running the shell.py script. In case you want to use another interpreter once you are in the "inner" shell...

Please sign in to comment.