def _create_env_conda_43(prefix, index, full_list_of_packages): assert CONDA_VERSION_MAJOR_MINOR >= (4, 3) from conda.core.package_cache import ProgressiveFetchExtract from conda.core.link import UnlinkLinkTransaction from conda.gateways.disk.create import mkdir_p pfe = ProgressiveFetchExtract(index, full_list_of_packages) pfe.execute() mkdir_p(prefix) txn = UnlinkLinkTransaction.create_from_dists(index, prefix, (), full_list_of_packages) txn.execute()
def create_env(repo, pkgs, target): with Locked(target): spec_fname = os.path.join(repo.working_dir, 'env.spec') with open(spec_fname, 'r') as fh: spec = yaml.safe_load(fh) channels = prioritize_channels(spec.get('channels', [])) # Build reverse look-up from channel URL to channel name. channel_by_url = {url: channel for url, (channel, _) in channels.items()} index = fetch_index(channels, use_cache=False) resolver = Resolve(index) # Create the package distribution from the manifest. Ensure to replace # channel-URLs with channel names, otherwise the fetch-extract may fail. dists = [Dist.from_string(pkg, channel_override=channel_by_url.get(url, url)) for url, pkg in pkgs] # Use the resolver to sort packages into the appropriate dependency # order. sorted_dists = resolver.dependency_sort({dist.name: dist for dist in dists}) pfe = ProgressiveFetchExtract(index, sorted_dists) pfe.execute() mkdir_p(target) txn = UnlinkLinkTransaction.create_from_dists(index, target, (), sorted_dists) txn.execute()