Skip to content

Commit

Permalink
Hooks: Fix numpy and scipy hooks to find dlls in extra locations.
Browse files Browse the repository at this point in the history
On windows, numpy and scipy package dlls under the extra-dlls directory
under site-packages. However, if you install numpy/scipy on windows
through a mingw compatible terminal like git bash, then those dlls are
packaged under the .libs directory.

hook-numpy and hook-scipy are written based on native windows installs.
This breaks if you use pyinstaller from a mingw compatible terminal.
Update the hooks to account for this difference.
  • Loading branch information
createdbysk authored and htgoebel committed Jan 9, 2020
1 parent 2c16311 commit 0d7ac32
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
13 changes: 9 additions & 4 deletions PyInstaller/hooks/hook-numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
binaries = []

# package the DLL bundle that official numpy wheels for Windows ship
# The DLL bundle will either be in extra-dll on windows proper
# and in .libs if installed on a virtualenv created from MinGW (Git-Bash
# for example)
if is_win:
dll_glob = os.path.join(os.path.dirname(
get_module_file_attribute('numpy')), 'extra-dll', "*.dll")
if glob.glob(dll_glob):
binaries.append((dll_glob, "."))
extra_dll_locations = ['extra-dll', '.libs']
for location in extra_dll_locations:
dll_glob = os.path.join(os.path.dirname(
get_module_file_attribute('numpy')), location, "*.dll")
if glob.glob(dll_glob):
binaries.append((dll_glob, "."))
13 changes: 9 additions & 4 deletions PyInstaller/hooks/hook-scipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
binaries = []

# package the DLL bundle that official scipy wheels for Windows ship
# The DLL bundle will either be in extra-dll on windows proper
# and in .libs if installed on a virtualenv created from MinGW (Git-Bash
# for example)
if is_win:
dll_glob = os.path.join(os.path.dirname(
get_module_file_attribute('scipy')), 'extra-dll', "*.dll")
if glob.glob(dll_glob):
binaries.append((dll_glob, "."))
extra_dll_locations = ['extra-dll', '.libs']
for location in extra_dll_locations:
dll_glob = os.path.join(os.path.dirname(
get_module_file_attribute('scipy')), location, "*.dll")
if glob.glob(dll_glob):
binaries.append((dll_glob, "."))

# collect library-wide utility extension modules
hiddenimports = ['scipy._lib.%s' % m for m in [
Expand Down
2 changes: 2 additions & 0 deletions news/4593.hooks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix hook numpy and hook scipy to account for differences in location of extra
dlls on Windows.

0 comments on commit 0d7ac32

Please sign in to comment.