Skip to content

Commit

Permalink
Add iminuit hooks (#26)
Browse files Browse the repository at this point in the history
iminuit uses a cython module which imports sub-modules. These are not
normally detected by pyinstaller. This hook uses collect_submodules
to add the missing modules as hidden imports, excluding tests.
  • Loading branch information
jeremysanders committed Aug 11, 2020
1 parent 9de3616 commit d747791
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/26.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a hook for ``iminuit`` which has hidden imports.
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ boto==2.49.0
boto3==1.12.33
botocore==1.15.33
h5py==2.10.0
iminuit==1.4.0
markdown==3.2.1
pendulum==2.0.5
phonenumbers==8.12.1
Expand Down
25 changes: 25 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-iminuit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ------------------------------------------------------------------
# Copyright (c) 2020 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
# ------------------------------------------------------------------

# add hooks for iminuit: https://github.com/scikit-hep/iminuit

# iminuit imports subpackages through a cython module which aren't
# found by default

from PyInstaller.utils.hooks import collect_submodules

hiddenimports = []

# the iminuit package contains tests which aren't needed when distributing
for mod in collect_submodules('iminuit'):
if not mod.startswith('iminuit.tests'):
hiddenimports.append(mod)
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 @@ -296,3 +296,10 @@ def test_sentry(pyi_builder):
import sentry_sdk
sentry_sdk.init()
""")


@importorskip('iminuit')
def test_iminuit(pyi_builder):
pyi_builder.test_source("""
from iminuit import Minuit
""")

0 comments on commit d747791

Please sign in to comment.