提交 7efd1c59 authored 作者: Ben Mares's avatar Ben Mares 提交者: Ricardo Vieira

Get rid of pydot-ng because it's deprecated since 7 years

上级 73c0d4d7
...@@ -78,7 +78,7 @@ tests = [ ...@@ -78,7 +78,7 @@ tests = [
"pytest-mock", "pytest-mock",
"pytest-sphinx", "pytest-sphinx",
] ]
rtd = ["sphinx>=5.1.0,<6", "pygments", "pydot", "pydot2", "pydot-ng"] rtd = ["sphinx>=5.1.0,<6", "pygments", "pydot"]
jax = ["jax", "jaxlib"] jax = ["jax", "jaxlib"]
numba = ["numba>=0.57", "llvmlite"] numba = ["numba>=0.57", "llvmlite"]
......
...@@ -1188,45 +1188,21 @@ default_colorCodes = { ...@@ -1188,45 +1188,21 @@ default_colorCodes = {
def _try_pydot_import(): def _try_pydot_import():
pydot_imported = False
pydot_imported_msg = ""
try: try:
# pydot-ng is a fork of pydot that is better maintained
import pydot_ng as pd
if pd.find_graphviz():
pydot_imported = True
else:
pydot_imported_msg = "pydot-ng can't find graphviz. Install graphviz."
except ImportError:
try:
# fall back on pydot if necessary
import pydot as pd import pydot as pd
if hasattr(pd, "find_graphviz"):
if pd.find_graphviz():
pydot_imported = True
else:
pydot_imported_msg = "pydot can't find graphviz"
else:
pd.Dot.create(pd.Dot()) pd.Dot.create(pd.Dot())
pydot_imported = True return pd
except ImportError: except ImportError:
# tests should not fail on optional dependency # tests should not fail on optional dependency
pydot_imported_msg = ( extra_msg = ""
"Install the python package pydot or pydot-ng. Install graphviz."
)
except Exception as e: except Exception as e:
pydot_imported_msg = "An error happened while importing/trying pydot: " extra_msg = f"\nAn error happened while importing/trying pydot: {e!r}"
pydot_imported_msg += str(e.args)
if not pydot_imported:
raise ImportError( raise ImportError(
"Failed to import pydot. You must install graphviz " "Failed to import pydot. You must install graphviz and pydot for "
"and either pydot or pydot-ng for " f"`pydotprint` to work.{extra_msg}",
f"`pydotprint` to work:\n {pydot_imported_msg}",
) )
return pd
def pydotprint( def pydotprint(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论