Skip to content

Commit 7efd1c5

Browse files
maresbricardoV94
authored andcommitted
Get rid of pydot-ng because it's deprecated since 7 years
1 parent 73c0d4d commit 7efd1c5

File tree

2 files changed

+13
-37
lines changed

2 files changed

+13
-37
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ tests = [
7878
"pytest-mock",
7979
"pytest-sphinx",
8080
]
81-
rtd = ["sphinx>=5.1.0,<6", "pygments", "pydot", "pydot2", "pydot-ng"]
81+
rtd = ["sphinx>=5.1.0,<6", "pygments", "pydot"]
8282
jax = ["jax", "jaxlib"]
8383
numba = ["numba>=0.57", "llvmlite"]
8484

pytensor/printing.py

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,45 +1188,21 @@ def __call__(self, *args):
11881188

11891189

11901190
def _try_pydot_import():
1191-
pydot_imported = False
1192-
pydot_imported_msg = ""
11931191
try:
1194-
# pydot-ng is a fork of pydot that is better maintained
1195-
import pydot_ng as pd
1192+
import pydot as pd
11961193

1197-
if pd.find_graphviz():
1198-
pydot_imported = True
1199-
else:
1200-
pydot_imported_msg = "pydot-ng can't find graphviz. Install graphviz."
1194+
pd.Dot.create(pd.Dot())
1195+
return pd
12011196
except ImportError:
1202-
try:
1203-
# fall back on pydot if necessary
1204-
import pydot as pd
1205-
1206-
if hasattr(pd, "find_graphviz"):
1207-
if pd.find_graphviz():
1208-
pydot_imported = True
1209-
else:
1210-
pydot_imported_msg = "pydot can't find graphviz"
1211-
else:
1212-
pd.Dot.create(pd.Dot())
1213-
pydot_imported = True
1214-
except ImportError:
1215-
# tests should not fail on optional dependency
1216-
pydot_imported_msg = (
1217-
"Install the python package pydot or pydot-ng. Install graphviz."
1218-
)
1219-
except Exception as e:
1220-
pydot_imported_msg = "An error happened while importing/trying pydot: "
1221-
pydot_imported_msg += str(e.args)
1222-
1223-
if not pydot_imported:
1224-
raise ImportError(
1225-
"Failed to import pydot. You must install graphviz "
1226-
"and either pydot or pydot-ng for "
1227-
f"`pydotprint` to work:\n {pydot_imported_msg}",
1228-
)
1229-
return pd
1197+
# tests should not fail on optional dependency
1198+
extra_msg = ""
1199+
except Exception as e:
1200+
extra_msg = f"\nAn error happened while importing/trying pydot: {e!r}"
1201+
1202+
raise ImportError(
1203+
"Failed to import pydot. You must install graphviz and pydot for "
1204+
f"`pydotprint` to work.{extra_msg}",
1205+
)
12301206

12311207

12321208
def pydotprint(

0 commit comments

Comments
 (0)