def execute_plan(plan, index=None, verbose=False): if verbose: from conda.console import setup_handlers setup_handlers() progress_cmds = set([EXTRACT, RM_EXTRACTED, LINK, UNLINK]) # set default prefix prefix = config.root_dir i = None cmds = cmds_from_plan(plan) for cmd, arg in cmds: if i is not None and cmd in progress_cmds: i += 1 getLogger('progress.update').info((name_dist(arg), i)) if cmd == PREFIX: prefix = arg elif cmd == PRINT: getLogger('print').info(arg) elif cmd == FETCH: fetch(index, arg) elif cmd == PROGRESS: i = 0 maxval = int(arg) getLogger('progress.start').info(maxval) elif cmd == EXTRACT: install.extract(config.pkgs_dir, arg) elif cmd == RM_EXTRACTED: install.rm_extracted(config.pkgs_dir, arg) elif cmd == RM_FETCHED: install.rm_fetched(config.pkgs_dir, arg) elif cmd == LINK: install.link(config.pkgs_dir, prefix, arg) elif cmd == UNLINK: install.unlink(prefix, arg) else: raise Exception("Did not expect command: %r" % cmd) if i is not None and cmd in progress_cmds and maxval == i: i = None getLogger('progress.stop').info(None) install.messages(prefix)
def _create_env_conda_42(prefix, index, full_list_of_packages): assert CONDA_VERSION_MAJOR_MINOR < (4, 3) from conda.install import is_extracted, is_fetched, extract, link from conda.fetch import fetch_pkg for tar_name in full_list_of_packages: pkg_info = index[tar_name] dist_name = tar_name[:-len('.tar.bz2')] log.info('Resolved package: {}'.format(tar_name)) # We force a lock on retrieving anything which needs access to a distribution of this # name. If other requests come in to get the exact same package they will have to wait # for this to finish (good). If conda itself it fetching these pacakges then there is # the potential for a race condition (bad) - there is no solution to this unless # conda/conda is updated to be more precise with its locks. lock_name = os.path.join(conda_execute.config.pkg_dir, dist_name) with Locked(lock_name): if not is_extracted(dist_name): if not is_fetched(dist_name): log.info('Fetching {}'.format(dist_name)) fetch_pkg(pkg_info, conda_execute.config.pkg_dir) extract(dist_name) link(prefix, dist_name)
def link(prefix, arg, index=None): dist, pkgs_dir, lt = split_linkarg(arg) install.link(pkgs_dir, prefix, dist, lt, index=index)
def link(prefix, arg): dist, pkgs_dir, lt = split_linkarg(arg) install.link(pkgs_dir, prefix, dist, lt)
def LINK_CMD(state, arg): dist, lt = split_linkarg(arg) install.link(state['prefix'], dist, lt, index=state['index'])
def LINK_CMD(state, dist, pkgs_dir=config.pkgs_dirs[0], lt=install.LINK_HARD): prefix = state['prefix'] index = state['index'] install.link(pkgs_dir, prefix, dist, lt, index=index)
'It may be that the content is out of synch. ' 'Have you run a build of this environment?\n' "One of the designs of the conda-manager is " 'that a MANIFEST does not guarantee that all ' 'of the distributions \nhave come from the existing ' "recipes (particularly if a recipe's version has " "been decreased).".format(dist, dist_tar)) src_pkgs = os.path.join(pkgs_dir, source_name) if not os.path.exists(src_pkgs): os.makedirs(src_pkgs) if not cinstall.is_extracted(src_pkgs, dist): placed_dist_file = os.path.join(src_pkgs, dist + '.tar.bz2') if not os.path.exists(placed_dist_file): import shutil shutil.copy(dist_tar, placed_dist_file) cinstall.extract(src_pkgs, dist) # Tidy up immediately by removing the distribution. os.remove(placed_dist_file) # Remove any packages which are no longer needed. for dist in ci.linked(prefix): if dist not in for_installation: cinstall.unlink(prefix, dist) # Install the packages. for source_name, packages in packages_by_source.items(): src_distro_dir = conda_manifest.config.src_distributions_dir(source) for dist in packages: src_pkgs = os.path.join(pkgs_dir, source_name) cinstall.link(src_pkgs, prefix, dist)