summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hydrilla/proxy/simple_dependency_satisfying.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/hydrilla/proxy/simple_dependency_satisfying.py b/src/hydrilla/proxy/simple_dependency_satisfying.py
index f1371db..78a1197 100644
--- a/src/hydrilla/proxy/simple_dependency_satisfying.py
+++ b/src/hydrilla/proxy/simple_dependency_satisfying.py
@@ -25,7 +25,11 @@
# in a proprietary program, I am not going to enforce this in court.
"""
-.....
+This module contains logic to construct the dependency graph of Haketilo
+packages and to perform dependency resolution.
+
+The approach taken here is a very simplified one. Hopefully, this will at some
+point be replaced by a solution based on some SAT solver.
"""
# Enable using with Python 3.7.
@@ -39,8 +43,9 @@ from .. import item_infos
from .. import url_patterns
+@dc.dataclass(frozen=True)
class ImpossibleSituation(HaketiloException):
- pass
+ bad_mapping_identifiers: frozenset[str]
@dc.dataclass(frozen=True)
@@ -219,13 +224,16 @@ class _ComputationData:
if self.mappings.get(depended_identifier) not in choices:
_mark_mappings(depended_identifier, reverse_deps, bad_mappings)
- if any(identifier in self.required for identifier in bad_mappings):
- raise ImpossibleSituation()
+ bad_required_mappings: list[str] = []
- for identifier in bad_mappings:
- if identifier in self.required:
- raise ImpossibleSituation()
+ for identifier in self.required:
+ if identifier in bad_mappings or identifier not in choices:
+ bad_required_mappings.append(identifier)
+
+ if len(bad_required_mappings) > 0:
+ raise ImpossibleSituation(frozenset(bad_required_mappings))
+ for identifier in bad_mappings:
if identifier in self.mappings:
choices.pop(identifier, None)