#!/usr/bin/env python

import os, sys
from subprocess import call

parent = os.path.dirname
os.environ['VIRTUAL_ENV'] = parent(parent(__file__))
os.environ['PATH'] = os.pathsep.join([
    parent(__file__),
    os.environ['PATH'],
])

os.unsetenv('PYTHONHOME')
os.unsetenv('__PYVENV_LAUNCHER__')

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


def exe(args, shell=False):
    try:
        return call(args, shell=shell)
    except OSError as e:
        if e.errno == 2:
            sys.stderr.write("Unable to find %s\n" % args[0])
        else:
            raise

try:
    sys.exit(exe(sys.argv[1:], shell=shellout))
except IndexError:
    sys.exit("Command not specified")
