-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hook: add hook for gribapi package from eccodes dist
Add hook for `gribapi` package from `eccodes` dist, in order to collect bundled headers and ensure that the eccodes shared library is collected from the build environment.
- Loading branch information
Showing
5 changed files
with
73 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
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,3 @@ | ||
Add hook for ``gribapi`` package from ``eccodes`` dist, in order to | ||
collect bundled headers and ensure that the eccodes shared library is | ||
collected from the build environment. |
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
42 changes: 42 additions & 0 deletions
42
src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-gribapi.py
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,42 @@ | ||
# ------------------------------------------------------------------ | ||
# Copyright (c) 2024 PyInstaller Development Team. | ||
# | ||
# This file is distributed under the terms of the GNU General Public | ||
# License (version 2.0 or later). | ||
# | ||
# The full license is available in LICENSE.GPL.txt, distributed with | ||
# this software. | ||
# | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
# ------------------------------------------------------------------ | ||
|
||
import os | ||
|
||
from PyInstaller.utils.hooks import collect_data_files, get_module_attribute, logger | ||
|
||
# Collect the headers (eccodes.h, gribapi.h) that are bundled with the package. | ||
datas = collect_data_files('gribapi') | ||
|
||
# Collect the eccodes shared library | ||
binaries = [] | ||
try: | ||
library_path = get_module_attribute('gribapi.bindings', 'library_path') | ||
except Exception: | ||
logger.warning("hook-gribapi: failed to query gribapi.bindings.library_path!", exc_info=True) | ||
library_path = None | ||
|
||
if library_path: | ||
if not os.path.isabs(library_path): | ||
from PyInstaller.depend.utils import _resolveCtypesImports | ||
resolved_binary = _resolveCtypesImports([os.path.basename(library_path)]) | ||
if resolved_binary: | ||
library_path = resolved_binary[0][1] | ||
else: | ||
logger.warning("hook-gribapi: failed to resolve shared library name %r!", library_path) | ||
library_path = None | ||
else: | ||
logger.warning("hook-gribapi: could not determine path to eccodes shared library!") | ||
|
||
if library_path: | ||
logger.debug("hook-gribapi: collecting eccodes shared library: %r", library_path) | ||
binaries.append((library_path, '.')) |
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