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)