Exemple #1
0
def init(venv_name):
    """Initializez a virtualenv"""
    inenv = InenvManager()
    inenv.get_prepped_venv(venv_name, skip_cached=False)
    if not os.getenv(INENV_ENV_VAR):
        activator_warn(inenv)
    click.echo(click.style("Your venv is ready. Enjoy!", fg='green'))
Exemple #2
0
def init(venv_name):
    """Initializez a virtualenv"""
    inenv = InenvManager()
    inenv.get_prepped_venv(venv_name, skip_cached=False)
    if not os.getenv(INENV_ENV_VAR):
        activator_warn(inenv)
    click.echo(click.style("Your venv is ready. Enjoy!", fg='green'))
Exemple #3
0
def run_cli():
    try:
        inenv = InenvManager()
        for venv in inenv.registered_venvs.keys():
            new_switch = copy.deepcopy(switch_or_run)
            for param in new_switch.params:
                if param.name == 'venv_name':
                    param.default = venv
            main_cli.add_command(new_switch, name=venv, sort_later=True)
        main_cli(obj={}, prog_name="inenv")
    except InenvException as e:
        click.echo(click.style("{}".format(e.message), fg='red'))
Exemple #4
0
def switch_or_run(cmd, venv_name=None):
    """Switch or run in this env"""
    if cmd:
        return _run(venv_name, cmd)
    inenv = InenvManager()
    if not os.getenv(INENV_ENV_VAR):
        activator_warn(inenv)
        return
    else:
        venv = inenv.get_prepped_venv(venv_name)
        inenv.clear_extra_source_file()
        inenv.write_extra_source_file("source {}".format(venv.activate_shell_file))
        sys.exit(EVAL_EXIT_CODE)
Exemple #5
0
def switch_or_run(cmd, venv_name=None):
    """Switch or run in this env"""
    if cmd:
        return _run(venv_name, cmd)
    inenv = InenvManager()
    if not os.getenv(INENV_ENV_VAR):
        activator_warn(inenv)
        return
    else:
        venv = inenv.get_prepped_venv(venv_name)
        inenv.clear_extra_source_file()
        inenv.write_extra_source_file("source {}".format(
            venv.activate_shell_file))
        inenv.write_extra_source_file(
            override_envars_and_deactivate(inenv.get_envvars(venv_name)))
        if autojump_enabled():
            dir = inenv.guess_contents_dir(venv_name)
            inenv.write_extra_source_file('cd {}'.format(dir))
            click.echo(click.style("Jumping to {}".format(dir), fg='green'))
        sys.exit(EVAL_EXIT_CODE)
Exemple #6
0
def _run(venv_name, cmd):
    if len(cmd) == 1:
        cmd = cmd[0].split()
    inenv = InenvManager()
    venv = inenv.get_prepped_venv(venv_name)
    venv.run(cmd, always_exit=True)
Exemple #7
0
def extra_source():
    """Path to file sourced after an inenv switch"""
    inenv = InenvManager()
    print(inenv.extra_source_file)
Exemple #8
0
def root(venv_name):
    """ Removes the venv by name """
    inenv = InenvManager()
    inenv.get_venv(venv_name)
    venv = inenv.registered_venvs[venv_name]
    click.echo(venv['root'])
Exemple #9
0
def rm(venv_name):
    """ Removes the venv by name """
    inenv = InenvManager()
    venv = inenv.get_venv(venv_name)
    click.confirm("Delete dir {}".format(venv.path))
    shutil.rmtree(venv.path)
Exemple #10
0
def switch_or_run(cmd, venv_name=None):
    """Switch or run in this env"""
    if cmd:
        return _run(venv_name, cmd)
    inenv = InenvManager()
    if not os.getenv(INENV_ENV_VAR):
        activator_warn(inenv)
        return
    else:
        venv = inenv.get_prepped_venv(venv_name)
        inenv.clear_extra_source_file()
        inenv.write_extra_source_file("source {}".format(venv.activate_shell_file))
        inenv.write_extra_source_file(override_envars_and_deactivate(inenv.get_envvars(venv_name)))
        if autojump_enabled():
            dir = inenv.guess_contents_dir(venv_name)
            inenv.write_extra_source_file('cd {}'.format(dir))
            click.echo(click.style("Jumping to {}".format(dir), fg='green'))
        sys.exit(EVAL_EXIT_CODE)
Exemple #11
0
def _run(venv_name, cmd):
    if len(cmd) == 1:
        cmd = cmd[0].split()
    inenv = InenvManager()
    venv = inenv.get_prepped_venv(venv_name)
    venv.run(cmd, always_exit=True)
Exemple #12
0
def root(venv_name):
    """ Removes the venv by name """
    inenv = InenvManager()
    inenv.get_venv(venv_name)
    venv = inenv.registered_venvs[venv_name]
    click.echo(venv['root'])
Exemple #13
0
def rm(venv_name):
    """ Removes the venv by name """
    inenv = InenvManager()
    venv = inenv.get_venv(venv_name)
    click.confirm("Delete dir {}".format(venv.path))
    shutil.rmtree(venv.path)
Exemple #14
0
def init(venv_name):
    """Initializez a virtualenv"""
    inenv = InenvManager()
    inenv.get_prepped_venv(venv_name)
    activator_warn(inenv)
Exemple #15
0
def clean(venv_name):
    inenv = InenvManager()
    venv = inenv.get_venv(venv_name)
    click.confirm("Delete dir {}".format(venv.path))
    shutil.rmtree(venv.path)