From ad6431ea5999b066b8025725a3d09097fd0213b5 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 18 Apr 2025 22:57:06 +0100 Subject: [PATCH] Check Axes/Figure import paths in boilerplate.py --- tools/boilerplate.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/boilerplate.py b/tools/boilerplate.py index 7055fa4077f9..f018dfc887c8 100644 --- a/tools/boilerplate.py +++ b/tools/boilerplate.py @@ -459,5 +459,13 @@ def update_sig_from_node(node, sig): if len(sys.argv) > 1: pyplot_path = Path(sys.argv[1]) else: - pyplot_path = Path(__file__).parent / "../lib/matplotlib/pyplot.py" + mpl_path = (Path(__file__).parent / ".." /"lib"/"matplotlib").resolve() + pyplot_path = mpl_path / "pyplot.py" + for cls in [Axes, Figure]: + if mpl_path not in Path(inspect.getfile(cls)).parents: + raise RuntimeError( + f"{cls.__name__} import path is not {mpl_path}.\n" + "Please make sure your Matplotlib installation " + "is from the same source checkout as boilerplate.py" + ) build_pyplot(pyplot_path)