Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4328 from golemfactory/mwu/fix-numpy
Browse files Browse the repository at this point in the history
Add hook for numpy in pyinstaller
  • Loading branch information
maaktweluit authored Jun 13, 2019
2 parents 52611d8 + 015ac51 commit 27d254c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/pyinstaller/hooks/hook-numpy.core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2013-2018, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
# -----------------------------------------------------------------------------
# If numpy is built with MKL support it depends on a set of libraries loaded
# at runtime. Since PyInstaller's static analysis can't find them they must be
# included manually.
#
# See
# https://github.com/pyinstaller/pyinstaller/issues/1881
# https://github.com/pyinstaller/pyinstaller/issues/1969
# for more information
import os.path
import re
from PyInstaller.utils.hooks import get_package_paths
from PyInstaller import log as logging
from typing import List

binaries: List = []

logger = logging.getLogger(__name__)

# look for libraries in numpy package path
pkg_base, pkg_dir = get_package_paths('numpy')
dll_dir = os.path.join(pkg_dir, 'DLLs')
logger.info("pkg_base=%r, pkg_dir=%r, dll_dir=%r", pkg_base, pkg_dir, dll_dir)
if os.path.exists(dll_dir):
re_anylib = re.compile(r'\w+\.(?:dll|so|dylib)', re.IGNORECASE)
dlls_pkg = [f for f in os.listdir(dll_dir) if re_anylib.match(f)]
logger.info("dlls_pkg=%r", dlls_pkg)
binaries += [(os.path.join(dll_dir, f), '.') for f in dlls_pkg]

0 comments on commit 27d254c

Please # to comment.