Skip to content
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
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requests
networkx
meson
ninja
pydotplus
pydot
nbsphinx
nbsphinx_link
Ipython
Expand Down
37 changes: 19 additions & 18 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ networkx = "*"
ninja = "*"
numpy = ">=1.20.3,<3"
pip = "*"
pydotplus = "*"
pydot = "*"
pytest = "!=8.1.0"
pytest-benchmark = "*"
pytest-cov = "*"
Expand Down
3 changes: 2 additions & 1 deletion pymake/plot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Functions to plot source code dependencies determined using a directed
acyclic graph (DAG). pydotplus is used to plot the DAG.
acyclic graph (DAG). pydot, which is an optional dependency, is used to
plot the DAG.
"""
20 changes: 18 additions & 2 deletions pymake/plot/dependency_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,26 @@

from pathlib import Path

import pydotplus.graphviz as pydot

from ..utils._compiler_language_files import (
_get_ordered_srcfiles,
_get_srcfiles,
)
from ..utils._dag import _get_f_nodelist

try:
import pydot
except ImportError:
pydot = None


def _check_pydot():
"""Raise an error if pydot, which is an optional dependency, is missing."""
if pydot is None:
raise ImportError(
"pydot is required to plot dependency graphs, install it with "
"'pip install mfpymake[plot]'"
)


def to_pydot(dag, filename="mygraph.png"):
"""Create a png file of a Directed Acyclic Graph.
Expand All @@ -44,6 +56,8 @@ def to_pydot(dag, filename="mygraph.png"):
-------

"""
_check_pydot()

# Create the graph
graph = pydot.Dot(graph_type="digraph")

Expand Down Expand Up @@ -156,6 +170,8 @@ def make_plots(
-------

"""
_check_pydot()

srcfiles = _get_ordered_srcfiles(_get_srcfiles(srcdir, include_subdir))
nodelist = _get_f_nodelist(srcfiles)
for idx, n in enumerate(nodelist):
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ dependencies = [
"networkx",
"meson>=1.3.1",
"ninja",
"pydotplus",
]
dynamic = ["version"]

[project.optional-dependencies]
plot = [
"pydot",
]
lint = [
"cffconvert",
"ruff",
]
test = [
"mfpymake[lint]",
"mfpymake[lint,plot]",
"coverage!=7.6.5",
"flaky",
"filelock",
Expand Down
Loading