def get_jpp_env(jpp_dir):
    """Return the environment dict of a loaded Jpp env.

    The returned env can be passed to `subprocess.Popen("J...", env=env)`
    to execute Jpp commands.

    """
    env = {
        v[0]: ''.join(v[1:])
        for v in [
            l.split('=') for l in os.popen(
                "source {0}/setenv.sh {0} && env".format(jpp_dir)
            ).read().split('\n') if '=' in l
        ]
    }
    return env