Skip to content

Commit

Permalink
hooks: add hook for gmsh
Browse files Browse the repository at this point in the history
  • Loading branch information
rokm committed Oct 5, 2023
1 parent 104c8dc commit 6968ca1
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ jobs:
sudo apt-get install -y libcairo2
# Install libdiscid (dependency of discid python package).
sudo apt-get install -y libdiscid0
# These are dependencies of gmsh
sudo apt-get install -y libglu1 libgl1 libxrender1 libxcursor1 libxft2 \
libxinerama1 libgomp1
- name: Install brew dependencies
if: startsWith(matrix.os, 'macos')
Expand Down
1 change: 1 addition & 0 deletions news/650.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add hook for ``gmsh``.
1 change: 1 addition & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ sudachidict-full==20230927
wxPython==4.2.1; sys_platform == 'darwin' or sys_platform == 'win32' # PyPI provides binary wheels for Windows and macOS
laonlp==1.1.2
pythainlp==4.1.0b5
gmsh==4.11.1

# ------------------- Platform (OS) specifics

Expand Down
28 changes: 28 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-gmsh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ------------------------------------------------------------------
# Copyright (c) 2023 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 logger, get_module_attribute

# Query the `libpath` attribute of the `gmsh` module to obtain the path to shared library. This way, we do not need to
# duplicate the discovery logic.
try:
lib_file = get_module_attribute('gmsh', 'libpath')
except Exception:
logger.warning("Failed to query gmsh.libpath!", exc_info=True)
lib_file = None

if lib_file and os.path.isfile(lib_file):
binaries = [(lib_file, '.')]
else:
logger.warning("Could not find gmsh shared library - gmsh will likely fail to load at run-time!")
7 changes: 7 additions & 0 deletions src/_pyinstaller_hooks_contrib/tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1849,3 +1849,10 @@ def test_pythainlp(pyi_builder):
pyi_builder.test_source("""
import pythainlp
""")


@importorskip('gmsh')
def test_gmsh(pyi_builder):
pyi_builder.test_source("""
import gmsh
""")

0 comments on commit 6968ca1

Please sign in to comment.