#!@PYTHON@

import os, sys

# add the development directories or the current prefix to PYTHONPATH
binpath = os.path.abspath(os.path.dirname(sys.argv[0]))
binname = os.path.basename(sys.argv[0])
if binpath.endswith("bin"):
    envpath = os.environ.get("PYTHONPATH")

    newpath = []
    if envpath is not None:
        newpath = envpath.split(os.pathsep)
    newpath.insert(0, "@PYTHONDIR@")
    newpath.insert(0, "@PYEXECDIR@")
    os.environ["PYTHONPATH"] = os.pathsep.join(newpath)

    script = os.path.join("@PKGLIBEXECDIR@",
                          os.path.basename(sys.argv[0]) + ".py")
else:
    script = os.path.join(binpath, binname + ".py")

argv = ["@PYTHON@", script]
argv.extend(sys.argv[1:])

os.execv("@PYTHON@", argv)
