Skip to content

Commit

Permalink
Simplify marker simplification (#530)
Browse files Browse the repository at this point in the history
Try to use reduction to DNF and CNF as much as possible to achieve marker simplifications, in the hope that:

   - it's more general than the collection of heuristics we currently have
   - it simplifies the code

The potential downside of this approach is that cnf() and dnf() can,
in the worst case, be exponentially expensive.

eg `cnf((a1 and b1) or (a2 and b2) or ... (an and bn))` generates 2^n
intersections.

In practice, markers on python packages seem not to get long enough for
this to be an issue.

Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com>
  • Loading branch information
dimbleby and radoering committed Dec 18, 2022
1 parent 2fd5c3b commit 5b361d7
Show file tree
Hide file tree
Showing 5 changed files with 351 additions and 233 deletions.
4 changes: 2 additions & 2 deletions src/poetry/core/packages/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def add_constraint(
for i, sub_marker in enumerate(conjunctions):
if isinstance(sub_marker, MultiMarker):
for m in sub_marker.markers:
if isinstance(m, SingleMarker):
add_constraint(m.name, (m.operator, m.value), i)
assert isinstance(m, SingleMarker)
add_constraint(m.name, (m.operator, m.value), i)
elif isinstance(sub_marker, SingleMarker):
add_constraint(sub_marker.name, (sub_marker.operator, sub_marker.value), i)

Expand Down
Loading

0 comments on commit 5b361d7

Please sign in to comment.