def install_ipython_profile(install_lib_dir):
    from evo.tools.compat import which
    home_dir = _get_home_dir()
    ipython_dir = os.path.join(home_dir, ".ipython")
    os.environ["IPYTHONDIR"] = ipython_dir
    print("Installing evo IPython profile...")
    ipython = "ipython3" if sys.version_info >= (3, 0) else "ipython2"
    if which(ipython) is None:
        # Use the non-explicit ipython name if ipython2/3 is not in PATH.
        ipython = "ipython"
        if which(ipython) is None:
            print("IPython is not installed", file=sys.stderr)
            return
    try:
        sp.check_call([ipython, "profile", "create", "evo",
                       "--ipython-dir", ipython_dir],
                       preexec_fn=_run_as_caller)
        profile_dir = sp.check_output([ipython, "profile", "locate", "evo"],
                                      preexec_fn=_run_as_caller)
        if sys.version_info >= (3, 0):
            profile_dir = profile_dir.decode("UTF-8").replace("\n", "")
        else:
            profile_dir = profile_dir.replace("\n", "")
        shutil.copy(os.path.join(install_lib_dir, "evo", "ipython_config.py"),
                    os.path.join(profile_dir, "ipython_config.py"))
    except sp.CalledProcessError as e:
        print("IPython error:", e.output, file=sys.stderr)
    except Exception as e:
        print("Unexpected error:", e.message, file=sys.stderr)
示例#2
0
def main():
    main_parser = argparse.ArgumentParser(
        description=DESC, formatter_class=argparse.RawTextHelpFormatter)
    args, other_args = main_parser.parse_known_args()
    other_args = [] if other_args is None else other_args
    FNULL = open(os.devnull, 'w')

    # check if IPython is installed properly
    ipython = "ipython3" if six.PY3 else "ipython2"
    if which(ipython) is None:
        # fall back to the non-explicit ipython name if ipython2/3 is not in PATH
        ipython = "ipython"
        if which(ipython) is None:
            print("IPython is not installed", file=sys.stderr)
            sys.exit(1)

    try:
        sp.check_call([ipython, "profile", "locate", "evo"],
                      stdout=FNULL,
                      stderr=FNULL)
    except sp.CalledProcessError:
        print("IPython profile for evo is not installed", file=sys.stderr)
        sp.call([ipython, "profile", "create", "evo"])
        config = os.path.join(PACKAGE_BASE_PATH, "ipython_config.py")
        profile_dir = sp.check_output([ipython, "profile", "locate",
                                       "evo"]).decode("utf-8")
        profile_dir = profile_dir.rstrip()
        shutil.copy(config, os.path.join(profile_dir, "ipython_config.py"))
    try:
        sp.check_call([ipython, "--profile", "evo"] + other_args)
    except sp.CalledProcessError as e:
        print("IPython error", e.output, file=sys.stderr)
        sys.exit(1)
示例#3
0
def main():
    main_parser = argparse.ArgumentParser(description=DESC,
                                          formatter_class=argparse.RawTextHelpFormatter)
    args, other_args = main_parser.parse_known_args()
    other_args = [] if other_args is None else other_args
    FNULL = open(os.devnull, 'w')

    # check if IPython is installed properly
    ipython = "ipython3" if six.PY3 else "ipython2"
    if which(ipython) is None:
        # fall back to the non-explicit ipython name if ipython2/3 is not in PATH
        ipython = "ipython"
        if which(ipython) is None:
            print("IPython is not installed", file=sys.stderr)
            sys.exit(1)

    try:
        sp.check_call([ipython, "profile", "locate", "evo"], stdout=FNULL, stderr=FNULL)
    except sp.CalledProcessError:
        print("IPython profile for evo is not installed", file=sys.stderr)
        sp.call([ipython, "profile", "create", "evo"])
        config=os.path.join(PACKAGE_BASE_PATH, "ipython_config.py")
        profile_dir = sp.check_output([ipython, "profile", "locate", "evo"]).decode("utf-8")
        profile_dir = profile_dir.rstrip()
        shutil.copy(config, os.path.join(profile_dir, "ipython_config.py"))
    try:
        sp.check_call([ipython, "--profile", "evo"] + other_args)
    except sp.CalledProcessError as e:
        print("IPython error", e.output, file=sys.stderr)
        sys.exit(1)
示例#4
0
文件: setup.py 项目: xepost/evo
def _post_install(install_lib_dir):
    from evo.tools.compat import which
    # argcomplete
    print("activating argcomplete")
    try:
        sp.check_call("activate-global-python-argcomplete", shell=True)
        print("done - argcomplete should work now")
    except sp.CalledProcessError as e:
        print("error:", e.output, file=sys.stderr)
    # IPython profile
    user = os.environ[
        "SUDO_USER"] if "SUDO_USER" in os.environ else os.environ["USER"]
    home_dir = os.path.expanduser("~{}".format(user))
    ipython_dir = os.path.join(home_dir, ".ipython")
    os.environ["IPYTHONDIR"] = ipython_dir
    print("installing evo IPython profile for user", user)
    ipython = "ipython3" if sys.version_info >= (3, 0) else "ipython2"
    if which(ipython) is None:
        # fall back to the non-explicit ipython name if ipython2/3 is not in PATH
        ipython = "ipython"
        if which(ipython) is None:
            print("IPython is not installed", file=sys.stderr)
            return
    try:
        sp.check_call([
            ipython, "profile", "create", "evo", "--ipython-dir", ipython_dir
        ],
                      preexec_fn=run_as_caller)
        profile_dir = sp.check_output([ipython, "profile", "locate", "evo"],
                                      preexec_fn=run_as_caller)
        if sys.version_info >= (3, 0):
            profile_dir = profile_dir.decode("UTF-8").replace("\n", "")
        else:
            profile_dir = profile_dir.replace("\n", "")
        shutil.copy(os.path.join(install_lib_dir, "evo", "ipython_config.py"),
                    os.path.join(profile_dir, "ipython_config.py"))
    except sp.CalledProcessError as e:
        print("IPython error", e.output, file=sys.stderr)
    except Exception as e:
        print("unexpected error", e.message, file=sys.stderr)