From 49591407b12224f899b828e2b4efb198adeb93ec Mon Sep 17 00:00:00 2001 From: Marcel Bargull Date: Sat, 16 Mar 2024 18:54:02 +0100 Subject: [PATCH] Stop using conda_build.conda_interface conda_build.conda_interface is being deprecated. conda_build.conda_interface.get_index (which is conda.exports.get_index) is using the conda.models.dist.Dist -> conda.models.records.PackageRecord mapping. Dist class is legacy code that's being phased out, so avoid it. refs: - https://github.com/conda/conda-build/pull/5152 - https://github.com/conda/conda-build/pull/5222 Signed-off-by: Marcel Bargull --- .ci_support/build_all.py | 12 +++++---- .ci_support/compute_build_graph.py | 39 +++++++++++++++++------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.ci_support/build_all.py b/.ci_support/build_all.py index b75681ef4666c..fa7702d4fdd69 100644 --- a/.ci_support/build_all.py +++ b/.ci_support/build_all.py @@ -1,7 +1,9 @@ -import conda_build.conda_interface -import networkx as nx +import conda.base.context +import conda.core.index +import conda.resolve import conda_build.api import conda_index.api +import networkx as nx from compute_build_graph import construct_graph import argparse import os @@ -120,7 +122,7 @@ def build_all(recipes_dir, arch): def get_config(arch, channel_urls): - exclusive_config_files = [os.path.join(conda_build.conda_interface.root_dir, + exclusive_config_files = [os.path.join(conda.base.context.root_prefix, 'conda_build_config.yaml')] script_dir = os.path.dirname(os.path.realpath(__file__)) # since variant builds override recipe/conda_build_config.yaml, see @@ -144,8 +146,8 @@ def build_folders(recipes_dir, folders, arch, channel_urls): index_path = os.path.join(sys.exec_prefix, 'conda-bld') os.makedirs(index_path, exist_ok=True) conda_index.api.update_index(index_path) - index = conda_build.conda_interface.get_index(channel_urls=channel_urls) - conda_resolve = conda_build.conda_interface.Resolve(index) + index = conda.core.index.get_index(channel_urls=channel_urls) + conda_resolve = conda.resolve.Resolve(index) config = get_config(arch, channel_urls) platform = get_host_platform() diff --git a/.ci_support/compute_build_graph.py b/.ci_support/compute_build_graph.py index 6789d337f3609..076c3c77cccbc 100644 --- a/.ci_support/compute_build_graph.py +++ b/.ci_support/compute_build_graph.py @@ -36,9 +36,12 @@ import pkg_resources import re import subprocess +from functools import lru_cache import networkx as nx -from conda_build import api, conda_interface +from conda.models.match_spec import MatchSpec +from conda.models.records import PackageRecord +from conda_build import api from conda_build.metadata import find_recipe, MetaData from conda_build.utils import HashableDict @@ -199,7 +202,7 @@ def get_run_test_deps(meta): _rendered_recipes = {} -@conda_interface.memoized +@lru_cache(maxsize=None) def _get_or_render_metadata(meta_file_or_recipe_dir, worker, finalize, config=None): global _rendered_recipes platform = worker['platform'] @@ -253,15 +256,14 @@ def match_peer_job(target_matchspec, other_m, this_m=None): match_dict = {'name': other_m.name(), 'version': other_m.version(), 'build': _fix_any(other_m.build_id(), other_m.config), } - match_dict = conda_interface.Dist(name=match_dict['name'], - dist_name='-'.join((match_dict['name'], - match_dict['version'], - match_dict['build'])), - version=match_dict['version'], - build_string=match_dict['build'], - build_number=int(other_m.build_number() or 0), - channel=None) - matchspec_matches = target_matchspec.match(match_dict) + match_record = PackageRecord( + name=match_dict['name'], + version=match_dict['version'], + build=match_dict['build'], + build_number=int(other_m.build_number() or 0), + channel=None, + ) + matchspec_matches = target_matchspec.match(match_record) variant_matches = True if this_m: @@ -294,13 +296,13 @@ def add_intradependencies(graph): log.info(" test: {}".format(test_requires)) deps = set(m.ms_depends('build') + m.ms_depends('host') + m.ms_depends('run') + - [conda_interface.MatchSpec(dep) for dep in test_requires or []]) + [MatchSpec(dep) for dep in test_requires or []]) for dep in deps: name_matches = (n for n in graph.nodes() if graph.nodes[n]['meta'].name() == dep.name) for matching_node in name_matches: # are any of these build dependencies also nodes in our graph? - if (match_peer_job(conda_interface.MatchSpec(dep), + if (match_peer_job(MatchSpec(dep), graph.nodes[matching_node]['meta'], m) and (node, matching_node) not in graph.edges()): @@ -409,11 +411,14 @@ def _fix_any(value, config): return value -@conda_interface.memoized +@lru_cache(maxsize=None) def _installable(name, version, build_string, config, conda_resolve): """Can Conda install the package we need?""" - ms = conda_interface.MatchSpec(" ".join([name, _fix_any(version, config), - _fix_any(build_string, config)])) + ms = MatchSpec( + " ".join( + [name, _fix_any(version, config), _fix_any(build_string, config)] + ) + ) installable = conda_resolve.find_matches(ms) if not installable: log.warn("Dependency {name}, version {ver} is not installable from your " @@ -435,7 +440,7 @@ def _buildable(name, version, recipes_dir, worker, config, finalize): path), worker, finalize=finalize)] # this is our target match - ms = conda_interface.MatchSpec(" ".join([name, _fix_any(version, config)])) + ms = MatchSpec(" ".join([name, _fix_any(version, config)])) available = False for m in metadata_tuples: available = match_peer_job(ms, m)