Skip to content

Commit

Permalink
Hooks: numpy: Add filter for valid binaries.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoodsend committed Sep 17, 2020
1 parent 3cb512f commit 5c0b1ab
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions PyInstaller/hooks/hook-numpy.py
Expand Up @@ -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_dest[0].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)]

0 comments on commit 5c0b1ab

Please sign in to comment.