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

improve error message when generated constraints file is invalid #503

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 9 additions & 2 deletions src/fromager/commands/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
sources,
wheels,
)
from .graph import find_why

# Map child_name==child_version to list of (parent_name==parent_version, Requirement)
ReverseRequirements = dict[str, list[tuple[str, Requirement]]]
Expand Down Expand Up @@ -167,6 +168,7 @@ def write_constraints_file(
# each package are needed.
conflicts = graph.get_install_dependency_versions()
ret = True
conflicting_deps = set()
for dep_name, nodes in sorted(conflicts.items()):
versions = [node.version for node in nodes]
if len(versions) == 0:
Expand Down Expand Up @@ -211,7 +213,7 @@ def write_constraints_file(
output.write(
f"# NOTE: fromager selected {dep_name}=={v} from: {version_strs}\n"
)
logging.debug(
logger.debug(
"%s: selecting %s from multiple candidates %s",
dep_name,
v,
Expand All @@ -226,9 +228,14 @@ def write_constraints_file(
output.write(
f"# ERROR: no single version of {dep_name} met all requirements\n"
)
logging.error("%s: no single version meets all requirements", dep_name)
logger.error("%s: no single version meets all requirements", dep_name)
conflicting_deps.add(dep_name)
for dv in sorted(versions):
output.write(f"{dep_name}=={dv}\n")
for dep_name in conflicting_deps:
logger.error("finding why %s was being used", dep_name)
for node in graph.get_nodes_by_name(dep_name):
find_why(graph, node, -1, 1, [])
dhellmann marked this conversation as resolved.
Show resolved Hide resolved
return ret


Expand Down
6 changes: 5 additions & 1 deletion src/fromager/commands/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,11 @@ def find_why(
req_type: list[RequirementType],
):
all_skipped = True
is_toplevel = False
for parent in node.parents:
if parent.destination_node.key == ROOT:
is_toplevel = True
print(f" * {node.key} is a toplevel dependency")
continue
if req_type and parent.req_type not in req_type:
continue
Expand All @@ -224,7 +227,8 @@ def find_why(
)
if max_depth and (max_depth == -1 or depth <= max_depth):
find_why(graph, parent.destination_node, max_depth, depth + 1, [])
if all_skipped:

if all_skipped and not is_toplevel:
print(
f" * couldn't find any dependencies to {node.canonicalized_name} that matches {[str(r) for r in req_type]}"
)
Expand Down
Loading