#!/usr/bin/env python

import os, sys
from subprocess import check_call

parent = os.path.dirname
os.environ['VIRTUAL_ENV'] = parent(parent(__file__))
os.environ['PATH'] = os.pathsep.join([
		parent(__file__),
		os.environ['PATH'],
	])
try:
	del os.environ['PYTHONHOME']
except KeyError:
	pass

shellout = sys.platform == 'win32'
# need to have shell=True on windows, otherwise the PYTHONPATH
# won't inherit the PATH

args = sys.argv[1:]
if args:
	check_call(args, shell=shellout)
else:
	sys.stderr.write("Launching subshell in virtual environment. Type 'exit' \
or 'Ctrl+D' to return.\n")
	check_call([os.environ['SHELL']], shell=shellout)

