Skip to content
Snippets Groups Projects
Commit 6786cc8a authored by Christian Dreher's avatar Christian Dreher
Browse files

feature: Implement both cases where an optional dependency becomes explicit.

parent 54b558c4
No related branches found
No related tags found
1 merge request!1Resolve "Optional dependency support"
......@@ -51,10 +51,15 @@ class ModuleGraph(nx.DiGraph):
self.add_module(required_module, ws=module.ws)
# Add optional dependencies.
for _, module_in_graph in self.nodes(data="module"):
# If this module is an optional dependency of any module in the graph,
# make it required now to retain correct order.
if module.name in module_in_graph.optional_modules:
self.add_edge(module_in_graph.name, module.name)
for optional_name in module.optional_modules:
# If the dependency is already in the graph, it is a manually set
# dependency through the workspace or via a required_module earlier,
# and thus not optional.
# If an optional dependency of this module is already in the graph, it
# was either manually set in the workspace or via a required_module earlier.
# Make it an explicit dependency in the graph in this case.
if optional_name in self:
self.add_edge(module.name, optional_name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment