Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hooks: update scikit-image hooks for compatibility with 0.19.x and 0.20.0 #566

Merged
merged 4 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions news/565.update.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Update ``scikit-image`` hooks for compatibility with the 0.20.x series;
account for switch to ``lazy_module`` in ``skimage.data`` and
``skimage.filters`` as well as in main package. Collect new data files
that are now required by ``skimage.morphology``.
2 changes: 2 additions & 0 deletions news/565.update.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Update ``scikit-image`` hooks for compatibility with the 0.19.x series;
account for lazy module loading in ``skimage.filters``.
1 change: 1 addition & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ exchangelib==4.9.0
NBT==1.5.1
minecraft-launcher-lib==5.3; python_version >= '3.8'
scikit-learn==1.2.2; python_version >= '3.8'
scikit-image==0.20.0; python_version >= '3.8'


# ------------------- Platform (OS) specifics
Expand Down
19 changes: 19 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-skimage.data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ------------------------------------------------------------------
# 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
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import is_module_satisfies, collect_data_files, collect_submodules

# As of scikit-image 0.20.0, we need to collect the __init__.pyi file for `lazy_loader`, as well as collect submodules
# due to lazy loading.
if is_module_satisfies('scikit-image >= 0.20.0'):
datas = collect_data_files("skimage.data", includes=["*.pyi"])
hiddenimports = collect_submodules('skimage.data', filter=lambda name: name != 'skimage.data.tests')
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
# 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_data_files, 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.x, `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')

# In scikit-image 0.20.0, `lazy_loader` is used, so we need to collect `__init__.pyi` file.
if is_module_satisfies("scikit-image >= 0.20.0"):
datas = collect_data_files("skimage.filters", includes=["*.pyi"])
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', ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ------------------------------------------------------------------
# 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
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import collect_data_files, is_module_satisfies

# As of scikit-image 0.20.0, we need to collect .npy data files for `skimage.morphology`
if is_module_satisfies('scikit-image >= 0.20'):
datas = collect_data_files("skimage.morphology", includes=["*.npy"])
17 changes: 17 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-skimage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ------------------------------------------------------------------
# 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
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import collect_data_files, is_module_satisfies

# As of scikit-image 0.20.0, we need to collect the __init__.pyi file for `lazy_loader`.
if is_module_satisfies('scikit-image >= 0.20.0'):
datas = collect_data_files("skimage", includes=["*.pyi"])
2 changes: 1 addition & 1 deletion src/_pyinstaller_hooks_contrib/tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def test_pydivert(pyi_builder):
@pytest.mark.parametrize('submodule', [
'color', 'data', 'draw', 'exposure', 'feature', 'filters', 'future',
'graph', 'io', 'measure', 'metrics', 'morphology', 'registration',
'restoration', 'segmentation', 'transform', 'util', 'viewer'
'restoration', 'segmentation', 'transform', 'util'
])
def test_skimage(pyi_builder, submodule):
pyi_builder.test_source("""
Expand Down