diff --git a/PyInstaller/hooks/hook-pandas.py b/PyInstaller/hooks/hook-pandas.py index 22d76b8b3a..a130977782 100644 --- a/PyInstaller/hooks/hook-pandas.py +++ b/PyInstaller/hooks/hook-pandas.py @@ -9,7 +9,13 @@ # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception) #----------------------------------------------------------------------------- -from PyInstaller.utils.hooks import collect_submodules +from PyInstaller.utils.hooks import collect_submodules, is_module_satisfies # Pandas keeps Python extensions loaded with dynamic imports here. hiddenimports = collect_submodules('pandas._libs') + +# Pandas 1.2.0 and later require cmath hidden import on linux and macOS. +# On Windows, this is not strictly required, but we add it anyway to keep +# things simple (and future-proof). +if is_module_satisfies('pandas >= 1.2.0'): + hiddenimports += ['cmath'] diff --git a/news/5630.hooks.rst b/news/5630.hooks.rst new file mode 100644 index 0000000000..30503c131b --- /dev/null +++ b/news/5630.hooks.rst @@ -0,0 +1 @@ +Update ``pandas`` hook for compatibility with version 1.2.0 and later.