Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle constraints from run_exports #30

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 45 additions & 15 deletions conda_forge_feedstock_check_solvable/mamba_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -53,6 +54,8 @@
"weak": set(),
"strong": set(),
"noarch": set(),
"strong_constrains": set(),
"weak_constrains": set(),
}

MAX_GLIBC_MINOR = 50
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -1033,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"]
)
beckermr marked this conversation as resolved.
Show resolved Hide resolved
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"]
)
beckermr marked this conversation as resolved.
Show resolved Hide resolved
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"]
)
beckermr marked this conversation as resolved.
Show resolved Hide resolved
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"]
)
beckermr marked this conversation as resolved.
Show resolved Hide resolved
else:
host_req = list(set(host_req) | build_rx["strong"])
host_req = list(
set(host_req)
| build_rx["strong"]
| build_rx["strong_constrains"]
)
beckermr marked this conversation as resolved.
Show resolved Hide resolved

if host_req:
host_req = _clean_reqs(host_req, outnames)
Expand All @@ -1063,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"]
)
beckermr marked this conversation as resolved.
Show resolved Hide resolved

if run_req:
run_req = apply_pins(run_req, host_req or [], build_req or [], outnames, m)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_mamba_solvable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down