This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4328 from golemfactory/mwu/fix-numpy
Add hook for numpy in pyinstaller
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |