mirror of
https://github.com/esphome/esphome.git
synced 2026-10-22 05:46:12 +00:00
Drop what only a yielded library needed
After a library fetched by name yields to an explicit one, the components no top-level library reaches any more are not converted either.
This commit is contained in:
@@ -1510,6 +1510,7 @@ def convert_libraries(
|
||||
# same name, whichever round brought it in; the settle step applied that
|
||||
# rule to the names it could match up front
|
||||
explicit = {k: c for k, c in components.items() if not fetched_by_name(k)}
|
||||
yielded = False
|
||||
for key in [k for k in components if fetched_by_name(k)]:
|
||||
node = nodes[key]
|
||||
match = _satisfying_key(node.pkgname, node.owner, key, nodes, explicit)
|
||||
@@ -1517,10 +1518,22 @@ def convert_libraries(
|
||||
continue
|
||||
_LOGGER.debug("Library %s fetched by name yields to %s", key, match)
|
||||
del components[key]
|
||||
yielded = True
|
||||
for other in nodes.values():
|
||||
if key in other.edges:
|
||||
other.edges.remove(key)
|
||||
other.edges.add(match)
|
||||
if yielded:
|
||||
# What only the yielded library needed is not built either
|
||||
reachable: set[str] = set()
|
||||
stack = [key for key in top_level if key in components]
|
||||
while stack:
|
||||
if (key := stack.pop()) in reachable:
|
||||
continue
|
||||
reachable.add(key)
|
||||
stack.extend(edge for edge in nodes[key].edges if edge in components)
|
||||
for key in [key for key in components if key not in reachable]:
|
||||
del components[key]
|
||||
|
||||
# Two graph nodes that resolve to the same component name (e.g. a package
|
||||
# referenced both bare and as ``owner/name``) are not deduplicated and can
|
||||
|
||||
@@ -1471,7 +1471,9 @@ def test_by_name_fetch_yields_to_a_fork_pulled_in_later(tmp_path, monkeypatch) -
|
||||
{
|
||||
"esphome/A": {"name": "A", "dependencies": [{"name": "B"}]},
|
||||
"esphome/X": {"name": "X", "dependencies": [{"name": "C"}]},
|
||||
"B": {"name": "B"},
|
||||
# The upstream B pulls in D, which nothing else needs
|
||||
"B": {"name": "B", "dependencies": {"esphome/D": "1.0.0"}},
|
||||
"esphome/D": {"name": "D"},
|
||||
"C": {"name": "C", "dependencies": {"custom/B-fork": "1.0.0"}},
|
||||
"custom/B-fork": {"name": "B"},
|
||||
},
|
||||
@@ -1482,7 +1484,7 @@ def test_by_name_fetch_yields_to_a_fork_pulled_in_later(tmp_path, monkeypatch) -
|
||||
_backend(emit=lambda c: emitted.append(c.name)),
|
||||
)
|
||||
assert [d.name for d in top[0].dependencies] == ["custom/B-fork"]
|
||||
assert "B" not in emitted
|
||||
assert sorted(emitted) == ["C", "custom/B-fork", "esphome/A", "esphome/X"]
|
||||
|
||||
|
||||
def test_registry_miss_resolves_again_as_a_git_source(tmp_path, monkeypatch) -> None:
|
||||
|
||||
Reference in New Issue
Block a user