resolve#

用于经典求解器的低级 SAT 求解器包装器/接口。

有关高级 API,请参阅 conda.core.solver.Solver。

#

函数#

_get_sat_solver_cls([sat_solver_choice])

exactness_and_number_of_deps(resolve_obj, ms)

排序键,用于强调具有更严格要求的软件包

属性#

stdoutlog#
Unsatisfiable#
ResolvePackageNotFound#
_sat_solvers#
_get_sat_solver_cls(sat_solver_choice=SatSolverChoice.PYCOSAT)#
exactness_and_number_of_deps(resolve_obj, ms)#

排序键,用于强调具有更严格要求的软件包。更严格意味着可以更多地减少缩减索引,因此我们希望在缩减索引时更早地考虑这些受约束更多的依赖项。

class Resolve(index, processed=False, channels=())#
__hash__()#

返回 hash(self)。

default_filter(features=None, filter=None)#
valid(spec_or_prec, filter, optional=True)#

测试软件包、MatchSpec 或两者列表是否具有可满足的依赖项,假设循环依赖项始终有效。

参数:
  • spec_or_prec -- 软件包记录、MatchSpec 或这些的可迭代对象。

  • filter -- (fkey,valid) 对的字典,用于考虑依赖项的子集,并消除重复搜索。

  • optional -- 如果为 True(默认),则在考虑有效性时不强制使用可选规范。如果为 False,则强制使用它们。

返回:

如果可以满足全套依赖项,则为 True;否则为 False。如果提供了过滤器并且 update 为 True,则将使用搜索结果更新它。

valid2(spec_or_prec, filter_out, optional=True)#
invalid_chains(spec, filter, optional=True)#

为无效规范构造一组“依赖链”。

依赖链是 MatchSpec 对象的元组,从请求的规范开始,沿着依赖树向下进行,在无法满足的规范处结束。

参数:
  • spec -- 软件包键或 MatchSpec

  • filter -- (prec, valid) 对的字典,在测试软件包有效性时使用。

返回:

元组的元组,如果 MatchSpec 有效,则为空。

verify_specs(specs)#

执行快速验证,以确保规范和依赖项是合理的。

参数:

specs -- 要测试的字符串或 MatchSpec 对象的可迭代对象。

返回:

无,但是如果存在冲突,则会抛出错误。

请注意,这不会尝试解决循环依赖项。

_classify_bad_deps(bad_deps, specs_to_add, history_specs, strict_channel_priority)#
find_matches_with_strict(ms, strict_channel_priority)#
find_conflicts(specs, specs_to_add=None, history_specs=None)#
breadth_first_search_for_dep_graph(root_spec, target_name, dep_graph, num_targets=1)#

返回从 root_spec 到 target_name 的最短路径

build_graph_of_deps(spec)#
build_conflict_map(specs, specs_to_add=None, history_specs=None)#

通过尝试查找可能是冲突原因的常见依赖项,对冲突规范执行更深入的分析。

参数:
  • specs -- 要测试的字符串或 MatchSpec 对象的可迭代对象。

  • conflict. (假设规范)

返回:

错误依赖项的列表的列表

返回类型:

bad_deps

策略

如果我们在这里,我们知道规范存在冲突。这可能是因为:- 一个规范与另一个规范冲突;例如

['numpy 1.5*', 'numpy >=1.6']

  • 一个规范与另一个规范的依赖项冲突;例如

    ['numpy 1.5*', 'scipy 0.12.0b1']

  • 每个规范都依赖于相同的软件包,但方式不同;例如,

    ['A', 'B'],其中 A 依赖于 numpy 1.5,而 B 依赖于 numpy 1.6。

从技术上讲,如果我们将规范本身视为“依赖项”之一,则所有这三种情况都可以归结为最后一种情况。可能存在更复杂的冲突原因,但此代码仅考虑上述原因。

然后,此代码的目的是识别所有规范都依赖但方式不同的软件包(如上面的 numpy)。然后,我们识别导致这些软件包的依赖链。

_get_strict_channel(package_name)#
_broader(ms, specs_by_name)#

防止引入拓宽我们选择范围的匹配规范。

_get_package_pool(specs)#
get_reduced_index(explicit_specs, sort_by_exactness=True, exit_on_conflict=False)#
match_any(mss, prec)#
find_matches(spec: conda.models.match_spec.MatchSpec) tuple[conda.models.records.PackageRecord]#
ms_depends(prec: conda.models.records.PackageRecord) list[conda.models.match_spec.MatchSpec]#
version_key(prec, vtype=None)#
static _make_channel_priorities(channels)#
get_pkgs(ms, emptyok=False)#
static to_sat_name(val)#
static to_feature_metric_id(prec_dist_str, feat)#
push_MatchSpec(C, spec)#
gen_clauses()#
generate_spec_constraints(C, specs)#
generate_feature_count(C)#
generate_update_count(C, specs)#
generate_feature_metric(C)#
generate_removal_count(C, specs)#
generate_install_count(C, specs)#
generate_package_count(C, missing)#
generate_version_metrics(C, specs, include0=False)#
dependency_sort(must_have: dict[str, conda.models.records.PackageRecord]) list[conda.models.records.PackageRecord]#
environment_is_consistent(installed)#
get_conflicting_specs(specs, explicit_specs)#
bad_installed(installed, new_specs)#
restore_bad(pkgs, preserve)#
install_specs(specs, installed, update_deps=True)#
install(specs, installed=None, update_deps=True, returnall=False)#
remove_specs(specs, installed)#
remove(specs, installed)#
solve(specs: list, returnall: bool = False, _remove=False, specs_to_add=None, history_specs=None, should_retry_solve=False) list[conda.models.records.PackageRecord]#