From dabd9d79a6e89debe27147419d27ae017872b716 Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Fri, 12 Mar 2021 13:30:42 +0100 Subject: [PATCH] hooks: matplotlib: assert that mpl_data_dir is not empty If the statement in exec_statement() fails for whatever reason, mpl_data_dir ends up empty, which in turn cases the current working directory being collected as matplotlib/mpl-data. This leads to difficult-to-debug issues (see confusion around .git directory under #5504), so it's better to just signal the error. --- PyInstaller/hooks/hook-matplotlib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PyInstaller/hooks/hook-matplotlib.py b/PyInstaller/hooks/hook-matplotlib.py index 9e4f92ba9c3..10667dc75a0 100644 --- a/PyInstaller/hooks/hook-matplotlib.py +++ b/PyInstaller/hooks/hook-matplotlib.py @@ -14,6 +14,7 @@ mpl_data_dir = exec_statement( "import matplotlib; print(matplotlib.get_data_path())") +assert mpl_data_dir, "Failed to determine matplotlib's data directory!" datas = [ (mpl_data_dir, "matplotlib/mpl-data"),