diff --git a/news/100.new.rst b/news/100.new.rst new file mode 100644 index 00000000..b3cf4649 --- /dev/null +++ b/news/100.new.rst @@ -0,0 +1 @@ +Added a hook for ``statsmodels``, which adds ``statsmodels.tsa.statespace`` as a hidden import diff --git a/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-statsmodels.tsa.statespace.py b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-statsmodels.tsa.statespace.py new file mode 100644 index 00000000..c09d95a6 --- /dev/null +++ b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-statsmodels.tsa.statespace.py @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------ +# Copyright (c) 2021 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 +# ------------------------------------------------------------------ + +from PyInstaller.utils.hooks import collect_submodules + +hiddenimports = collect_submodules('statsmodels.tsa.statespace._filters') \ + + collect_submodules('statsmodels.tsa.statespace._smoothers') diff --git a/src/_pyinstaller_hooks_contrib/tests/test_libraries.py b/src/_pyinstaller_hooks_contrib/tests/test_libraries.py index 5435ca9f..15db8f65 100644 --- a/src/_pyinstaller_hooks_contrib/tests/test_libraries.py +++ b/src/_pyinstaller_hooks_contrib/tests/test_libraries.py @@ -395,6 +395,15 @@ def test_sklearn(pyi_builder, submodule): """.format(submodule)) +@importorskip('statsmodels') +@pytest.mark.skipif(not is_module_satisfies('statsmodels >= 0.12'), + reason='This has only been tested with statsmodels >= 0.12.') +def test_statsmodels(pyi_builder): + pyi_builder.test_source(""" + import statsmodels.api as sm + """) + + @importorskip('win32ctypes') @pytest.mark.skipif(not is_win, reason='pywin32-ctypes is supported only on Windows') @pytest.mark.parametrize('submodule', ['win32api', 'win32cred', 'pywintypes'])