From 2a9eb402d56e98b92f42c9eee95af427d20163fa Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Fri, 31 Mar 2023 17:28:12 +0200 Subject: [PATCH] hooks: update scikit-image hooks for compatibility with 0.19.x series Update the `skimage.filters` hook to account for the lazy module loading within this module. --- news/565.update.rst | 2 ++ .../hooks/stdhooks/hook-skimage.filters.py | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 news/565.update.rst diff --git a/news/565.update.rst b/news/565.update.rst new file mode 100644 index 00000000..5e37b101 --- /dev/null +++ b/news/565.update.rst @@ -0,0 +1,2 @@ +Update ``scikit-image`` hooks for compatibility with the 0.19.x series; +account for lazy module loading in ``skimage.filters``. diff --git a/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-skimage.filters.py b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-skimage.filters.py index 36661bbb..c3b269dd 100644 --- a/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-skimage.filters.py +++ b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-skimage.filters.py @@ -10,9 +10,11 @@ # SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------ -from PyInstaller.utils.hooks import is_module_satisfies +from PyInstaller.utils.hooks import is_module_satisfies, collect_submodules -# The following missing module prevents import of skimage.feature -# with skimage 0.18.x. -if is_module_satisfies("scikit_image >= 0.18.0"): +if is_module_satisfies("scikit_image >= 0.19.0"): + # In scikit-image 0.19.0, `skimage.filters` switched to lazy module loading, so we need to collect all submodules. + hiddenimports = collect_submodules('skimage.filters', filter=lambda name: name != 'skimage.filters.tests') +elif is_module_satisfies("scikit_image >= 0.18.0"): + # The following missing module prevents import of skimage.feature with skimage 0.18.x. hiddenimports = ['skimage.filters.rank.core_cy_3d', ]