def exec_file(path):
    """Execute file and return globals."""
    with open(path, 'rb') as fp:
        code = compile(fp.read(), path, 'exec')
    globs = {
        '__file__': path,
        '__name__': '__main__',
        '__package__': None,
        '__cached__': None,
    }
    exec(code, globs, None)
    return globs