def explicit(urls, prefix, verbose=True): import conda.fetch as fetch from conda.utils import md5_file dists = [] for url in urls: if url == '@EXPLICIT': continue print("Fetching: %s" % url) channel_url, fn = url.rsplit('/', 1) dists.append(fn[:-8]) index = fetch.fetch_index((channel_url + '/',)) info = index[fn] pkg_path = join(config.pkgs_dirs[0], fn) if isfile(pkg_path): try: if md5_file(pkg_path) != index[fn]['md5']: install.rm_rf(pkg_path) fetch.fetch_pkg(info) except KeyError: sys.stderr.write('Warning: cannot lookup MD5 of: %s' % fn) else: fetch.fetch_pkg(info) force_extract_and_link(dists, prefix, verbose=verbose)
def explicit(urls, prefix, verbose=True): import conda.fetch as fetch from conda.utils import md5_file dists = [] for url in urls: if url == '@EXPLICIT': continue print("Fetching: %s" % url) m = url_pat.match(url) if m is None: sys.exit("Error: Could not parse: %s" % url) fn = m.group('fn') dists.append(fn[:-8]) index = fetch.fetch_index((m.group('url') + '/',)) try: info = index[fn] except KeyError: sys.exit("Error: no package '%s' in index" % fn) if m.group('md5') and m.group('md5') != info['md5']: sys.exit("Error: MD5 in explicit files does not match index") pkg_path = join(config.pkgs_dirs[0], fn) if isfile(pkg_path): try: if md5_file(pkg_path) != info['md5']: install.rm_rf(pkg_path) fetch.fetch_pkg(info) except KeyError: sys.stderr.write('Warning: cannot lookup MD5 of: %s' % fn) else: fetch.fetch_pkg(info) force_extract_and_link(dists, prefix, verbose=verbose)
def fetch(info): download_dir = info['_download_dir'] if not isdir(download_dir): os.makedirs(download_dir) for fn in dists: path = join(download_dir, fn) url = urls.get(fn) md5 = md5s.get(fn) if url: url_index = fetch_index((url,)) try: pkginfo = url_index[fn] except KeyError: sys.exit("Error: no package '%s' in %s" % (fn, url)) else: pkginfo = index[fn] if md5 and md5 != pkginfo['md5']: sys.exit("Error: MD5 sum for '%s' does not match in remote " "repodata %s" % (fn, url)) if isfile(path) and md5_file(path) == pkginfo['md5']: continue print('fetching: %s' % fn) fetch_pkg(pkginfo, download_dir)
def fetch(info): download_dir = info['_download_dir'] if not isdir(download_dir): os.makedirs(download_dir) for fn in dists: path = join(download_dir, fn) url = urls.get(fn) md5 = md5s.get(fn) if url: url_index = fetch_index((url, )) try: pkginfo = url_index[fn] except KeyError: sys.exit("Error: no package '%s' in %s" % (fn, url)) else: pkginfo = index[fn] if md5 and md5 != pkginfo['md5']: sys.exit("Error: MD5 sum for '%s' does not match in remote " "repodata %s" % (fn, url)) if isfile(path) and md5_file(path) == pkginfo['md5']: continue print('fetching: %s' % fn) fetch_pkg(pkginfo, download_dir)
def fetch(info): global REPO_DIR REPO_DIR = join(expanduser('~'), '.conda', 'constructor', info['platform']) if not isdir(REPO_DIR): os.makedirs(REPO_DIR) for fn in DISTS: path = join(REPO_DIR, fn) if isfile(path) and md5_file(path) == INDEX[fn]['md5']: continue print('fetching: %s' % fn) fetch_pkg(INDEX[fn], REPO_DIR)
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 fetch(index, dist): assert index is not None fn = dist + '.tar.bz2' fetch_pkg(index[fn])
def FETCH_CMD(state, arg): fetch_pkg(state['index'][arg + '.tar.bz2'])