From 86c9277faa9956387210de13a42a295b3677883d Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 7 May 2024 14:21:55 +0200 Subject: [PATCH 1/4] handle constraints from run_exports previous handling added any unrecognized keys (e.g. strong_constrains) to weak requirements resulting in "package not found: strong_constrains" and constraints being ignored --- .../mamba_solver.py | 24 ++++++++++++------- tests/test_mamba_solvable.py | 24 +++++++++++++++++++ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/conda_forge_feedstock_check_solvable/mamba_solver.py b/conda_forge_feedstock_check_solvable/mamba_solver.py index 78138e7..705ee8b 100644 --- a/conda_forge_feedstock_check_solvable/mamba_solver.py +++ b/conda_forge_feedstock_check_solvable/mamba_solver.py @@ -24,6 +24,7 @@ import time import traceback from collections import defaultdict +from collections.abc import Mapping from dataclasses import dataclass, field from typing import Dict, FrozenSet, Iterable, List, Set, Tuple @@ -53,6 +54,8 @@ "weak": set(), "strong": set(), "noarch": set(), + "strong_constrains": set(), + "weak_constrains": set(), } MAX_GLIBC_MINOR = 50 @@ -421,25 +424,28 @@ def _get_run_export(link_tuple): if isinstance(rx, str): # some packages have a single string # eg pyqt - rx = [rx] + rx = {"weak": [rx]} - for k in rx: + if not isinstance(rx, Mapping): + # list is equivalent to weak + rx = {"weak": rx} + + for k, spec_list in rx.items(): if k in DEFAULT_RUN_EXPORTS: print_debug( "RUN EXPORT: %s %s %s", name, k, - rx[k], + spec_list, ) - run_exports[k].update(rx[k]) + run_exports[k].update(spec_list) else: - print_debug( - "RUN EXPORT: %s %s %s", + print_warning( + "RUN EXPORT: unrecognized run_export key in %s: %s=%s", name, - "weak", - [k], + k, + spec_list, ) - run_exports["weak"].add(k) return run_exports diff --git a/tests/test_mamba_solvable.py b/tests/test_mamba_solvable.py index 3cd832f..17b992a 100644 --- a/tests/test_mamba_solvable.py +++ b/tests/test_mamba_solvable.py @@ -346,6 +346,30 @@ def test_cupy_solvable(tmp_path): assert solvable, pprint.pformat(errors) +@flaky +def test_run_exports_strong_constrains_solvable(tmp_path): + """dolfinx_mpc depends on fenics-basix which has strong_constrained in run_exports""" + feedstock_dir = clone_and_checkout_repo( + tmp_path, + "https://github.com/conda-forge/dolfinx_mpc-feedstock", + ref="main", + ) + subprocess.run( + "git checkout 26bb83149573c285cd596fbca2db89a4c69435c3", + cwd=feedstock_dir, + shell=True, + check=True, + ) + # keep only one variant, avoid unnecessary solves + # every variant exercises this issue and this feedstock has ~100 variants + for cbc in pathlib.Path(feedstock_dir).glob(".ci_support/*.yaml"): + if cbc.name != "linux_64_mpimpichpython3.10.____cpythonscalarreal.yaml": + cbc.unlink() + solvable, errors, solvable_by_variant = is_recipe_solvable(feedstock_dir) + pprint.pprint(solvable_by_variant) + assert solvable, pprint.pformat(errors) + + @flaky def test_is_recipe_solvable_notok(feedstock_dir): recipe_file = os.path.join(feedstock_dir, "recipe", "meta.yaml") From a0992220986a5bbecea0349f14e55a7ae633fcdb Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 7 May 2024 15:24:48 +0200 Subject: [PATCH 2/4] include constraints in run dependencies --- .../mamba_solver.py | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/conda_forge_feedstock_check_solvable/mamba_solver.py b/conda_forge_feedstock_check_solvable/mamba_solver.py index 705ee8b..c26dca1 100644 --- a/conda_forge_feedstock_check_solvable/mamba_solver.py +++ b/conda_forge_feedstock_check_solvable/mamba_solver.py @@ -1039,19 +1039,37 @@ def _is_recipe_solvable_on_platform( errors.append(_err) if m.is_cross: - host_req = list(set(host_req) | build_rx["strong"]) + host_req = list( + set(host_req) | build_rx["strong"] | build_rx["strong_constrains"] + ) if not (m.noarch or m.noarch_python): - run_req = list(set(run_req) | build_rx["strong"]) + run_req = list( + set(run_req) + | build_rx["strong"] + | build_rx["strong_constrains"] + ) else: if m.noarch or m.noarch_python: if m.build_is_host: run_req = list(set(run_req) | build_rx["noarch"]) else: - run_req = list(set(run_req) | build_rx["strong"]) + run_req = list( + set(run_req) + | build_rx["strong"] + | build_rx["strong_constrains"] + ) if m.build_is_host: - run_req = list(set(run_req) | build_rx["weak"]) + run_req = list( + set(run_req) + | build_rx["weak"] + | build_rx["weak_constrains"] + ) else: - host_req = list(set(host_req) | build_rx["strong"]) + host_req = list( + set(host_req) + | build_rx["strong"] + | build_rx["strong_constrains"] + ) if host_req: host_req = _clean_reqs(host_req, outnames) From 4601b45329fe00a52b6faa184bf27d7e8ebf915a Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 7 May 2024 15:30:02 +0200 Subject: [PATCH 3/4] add constraints from host run_exports both weak and strong apply from host environment, not just weak --- conda_forge_feedstock_check_solvable/mamba_solver.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/conda_forge_feedstock_check_solvable/mamba_solver.py b/conda_forge_feedstock_check_solvable/mamba_solver.py index c26dca1..5b123dd 100644 --- a/conda_forge_feedstock_check_solvable/mamba_solver.py +++ b/conda_forge_feedstock_check_solvable/mamba_solver.py @@ -1087,7 +1087,13 @@ def _is_recipe_solvable_on_platform( if m.noarch or m.noarch_python: run_req = list(set(run_req) | host_rx["noarch"]) else: - run_req = list(set(run_req) | host_rx["weak"]) + run_req = list( + set(run_req) + | host_rx["weak"] + | host_rx["weak_constrains"] + | host_rx["strong"] + | host_rx["strong_constrains"] + ) if run_req: run_req = apply_pins(run_req, host_req or [], build_req or [], outnames, m) From 4b87f9afa34fa5647a50422ac7ca0f9d11ca15b3 Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Tue, 7 May 2024 09:10:20 -0500 Subject: [PATCH 4/4] do not use constrains in run --- .../mamba_solver.py | 36 ++++--------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/conda_forge_feedstock_check_solvable/mamba_solver.py b/conda_forge_feedstock_check_solvable/mamba_solver.py index 5b123dd..705ee8b 100644 --- a/conda_forge_feedstock_check_solvable/mamba_solver.py +++ b/conda_forge_feedstock_check_solvable/mamba_solver.py @@ -1039,37 +1039,19 @@ def _is_recipe_solvable_on_platform( errors.append(_err) if m.is_cross: - host_req = list( - set(host_req) | build_rx["strong"] | build_rx["strong_constrains"] - ) + host_req = list(set(host_req) | build_rx["strong"]) if not (m.noarch or m.noarch_python): - run_req = list( - set(run_req) - | build_rx["strong"] - | build_rx["strong_constrains"] - ) + run_req = list(set(run_req) | build_rx["strong"]) else: if m.noarch or m.noarch_python: if m.build_is_host: run_req = list(set(run_req) | build_rx["noarch"]) else: - run_req = list( - set(run_req) - | build_rx["strong"] - | build_rx["strong_constrains"] - ) + run_req = list(set(run_req) | build_rx["strong"]) if m.build_is_host: - run_req = list( - set(run_req) - | build_rx["weak"] - | build_rx["weak_constrains"] - ) + run_req = list(set(run_req) | build_rx["weak"]) else: - host_req = list( - set(host_req) - | build_rx["strong"] - | build_rx["strong_constrains"] - ) + host_req = list(set(host_req) | build_rx["strong"]) if host_req: host_req = _clean_reqs(host_req, outnames) @@ -1087,13 +1069,7 @@ def _is_recipe_solvable_on_platform( if m.noarch or m.noarch_python: run_req = list(set(run_req) | host_rx["noarch"]) else: - run_req = list( - set(run_req) - | host_rx["weak"] - | host_rx["weak_constrains"] - | host_rx["strong"] - | host_rx["strong_constrains"] - ) + run_req = list(set(run_req) | host_rx["weak"]) if run_req: run_req = apply_pins(run_req, host_req or [], build_req or [], outnames, m)