def cp_cmd(): """Duplicate the named virtualenv to make a new one.""" parser = argparse.ArgumentParser() parser.add_argument('source') parser.add_argument('target', nargs='?') parser.add_argument('-d', '--dont-activate', action='store_false', default=True, dest='activate', help="After \ creation, continue with the existing shell (don't \ activate the new environment).") args = parser.parse_args() source_name = sys.argv[1] if os.path.exists(args.source): source = expandpath(args.source) else: source = expandpath(os.path.join(workon_home, args.source)) if not os.path.exists(source): sys.exit('Please provide a valid virtualenv to copy') target_name = args.target or os.path.basename(source) target = os.path.join(workon_home, target_name) if os.path.exists(target): sys.exit('%s virtualenv already exists in %s.' % (target_name, workon_home)) print('Copying {0} in {1}'.format(source, target_name)) clone_virtualenv(source, target) inve = get_inve(target_name) deploy_inve(inve) if args.activate: invoke(inve)
def cp_cmd(): """Duplicate the named virtualenv to make a new one.""" parser = argparse.ArgumentParser() parser.add_argument("source") parser.add_argument("target", nargs="?") parser.add_argument( "-d", "--dont-activate", action="store_false", default=True, dest="activate", help="After \ creation, continue with the existing shell (don't \ activate the new environment).", ) args = parser.parse_args() source = expandpath(args.source) if not source.exists(): source = workon_home / args.source if not source.exists(): sys.exit("Please provide a valid virtualenv to copy") target_name = args.target or source.name target = workon_home / target_name if target.exists(): sys.exit("%s virtualenv already exists in %s." % (target_name, workon_home)) print("Copying {0} in {1}".format(source, target_name)) clone_virtualenv(str(source), str(target)) if args.activate: shell(target_name)
def cp_cmd(): """Duplicate the named virtualenv to make a new one.""" parser = argparse.ArgumentParser() parser.add_argument('source') parser.add_argument('target', nargs='?') parser.add_argument('-d', '--dont-activate', action='store_false', default=True, dest='activate', help="After \ creation, continue with the existing shell (don't \ activate the new environment).") args = parser.parse_args() source = expandpath(args.source) if not source.exists(): source = workon_home / args.source if not source.exists(): sys.exit('Please provide a valid virtualenv to copy') target_name = args.target or source.name target = workon_home / target_name if target.exists(): sys.exit('%s virtualenv already exists in %s.' % (target_name, workon_home)) print('Copying {0} in {1}'.format(source, target_name)) clone_virtualenv(str(source), str(target)) if args.activate: shell(target_name)
def before_scenario(context, scenario): if FRESH_VENV_TAG in scenario.tags: new_venv_dir = _create_tmp_dir() / "temp" # need to use virtualenv-clone instead of just a bare copy to resolve sys.paths and the like clonevirtualenv.clone_virtualenv(str(context.base_venv_dir), str(new_venv_dir)) context = _setup_context_with_venv(context, new_venv_dir) context.temp_dir = Path(tempfile.mkdtemp())
def before_scenario(context, scenario): if FRESH_VENV_TAG in scenario.tags: new_venv_dir = _create_tmp_dir() / "temp" # need to use virtualenv-clone instead of just a bare copy to resolve sys.paths and the like clonevirtualenv.clone_virtualenv(str(context.base_venv_dir), str(new_venv_dir)) context = _setup_context_with_venv(context, new_venv_dir) elif os.name != "posix": # On Windows virtual env cloning doesn't work properly. # This is a temporary workaround to make several tests pass. context = _setup_kedro_install_venv(context) context.temp_dir = Path(tempfile.mkdtemp())
def _setup_kedro_install_venv(context): kedro_install_venv_dir = _create_tmp_dir() / "ked-install" # need to use virtualenv-clone instead of just a bare copy to resolve sys.paths and the like clonevirtualenv.clone_virtualenv(str(context.base_venv_dir), str(kedro_install_venv_dir)) context.kedro_install_venv_dir = kedro_install_venv_dir context = _setup_context_with_venv(context, kedro_install_venv_dir) install_reqs = (Path( "kedro/templates/project/{{ cookiecutter.repo_name }}/src/requirements.txt" ).read_text().splitlines()) install_reqs = [req for req in install_reqs if "{" not in req] install_reqs.append(".[pandas.CSVDataSet]") call([context.pip, "install", *install_reqs], env=context.env) return context
def do_clone(self, arg): """Make a copy of the specified virtualenv""" root = self._getroot() active = _get_active_venv(root) if not active: print >> sys.stdout, "no active venv to clone" sys.exit(1) newvenv = _new_venv_path(root) try: clone.clone_virtualenv(active, newvenv) except Exception, e: if os.path.exists(newvenv): _rm_r(newvenv) print >> sys.stdout, "cloning active virtualenv failed" sys.exit(1)
def copy_virtualenv_project(source, target): source = expandpath(source) if not source.exists(): source = workon_home / source if not source.exists(): sys.exit("Please provide a valid virtualenv to copy") target_name = target or source.name target = workon_home / target_name if target.exists(): sys.exit("%s virtualenv already exists in %s." % (target_name, workon_home)) print("Copying {0} in {1}".format(source, target_name)) clone_virtualenv(str(source), str(target)) return target_name
def copy_virtualenv_project(source, target): source = expandpath(source) if not source.exists(): source = workon_home / source if not source.exists(): sys.exit('Please provide a valid virtualenv to copy') target_name = target or source.name target = workon_home / target_name if target.exists(): sys.exit('%s virtualenv already exists in %s.' % (target_name, workon_home)) print('Copying {0} in {1}'.format(source, target_name)) clone_virtualenv(str(source), str(target)) return target_name