diff --git a/PyInstaller/hooks/hook-numpy.py b/PyInstaller/hooks/hook-numpy.py index 214361ecf51..f60593c7656 100644 --- a/PyInstaller/hooks/hook-numpy.py +++ b/PyInstaller/hooks/hook-numpy.py @@ -147,3 +147,23 @@ def _is_required(name): # from PyInstaller.utils.hooks import collect_submodules # is_tests = lambda x: "tests" in x.split(".") # excludedimports += collect_submodules("numpy", filter=is_tests) + + +# --- Remove binaries that aren't DLLs --- + + +import ctypes + +def _is_valid(source, dest): + # There really should be a less brute-force way of doing this. + if source.endswith(".pdb"): + # Attempting to load a pdb causes a pop-up window. Check for and exclude + # them here. + return False + try: + ctypes.CDLL(source) + return True + except OSError: + return False + +binaries = [i for i in binaries if _is_valid(*i)]