From 3c9a055c747e6180d01d43716e77090e2e4038eb Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Thu, 5 May 2022 22:24:51 +0200 Subject: [PATCH] hooks: mariadb: always collect decimal module as hidden import Always collect the `decimal` module as a hidden import, even if it seems to be automatically picked up on recent python versions. That likely happens due to import in some other module (e.g., from standard library), but may be subject to change in the future, so we should not be relying on it. Besides, the hidden import does no harm, even if it is redundant. --- news/426.update.rst | 3 +++ .../hooks/stdhooks/hook-mariadb.py | 14 ++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 news/426.update.rst diff --git a/news/426.update.rst b/news/426.update.rst new file mode 100644 index 00000000..6b3c0ac3 --- /dev/null +++ b/news/426.update.rst @@ -0,0 +1,3 @@ +Update ``mariadb`` hook to always include the ``decimal`` module as a +hidden import, instead of implicitly relying on it being picked up due +to import in some other, unrelated module. diff --git a/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-mariadb.py b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-mariadb.py index 2b978b34..328d66d1 100644 --- a/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-mariadb.py +++ b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-mariadb.py @@ -10,11 +10,9 @@ # SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------ - -from PyInstaller.compat import is_py38 - - -# The MariaDB uses a .pyd file and uses import within its __init__.py -# The decimal import seems to be hidden in Python version 3.7 and older -if not is_py38: - hiddenimports = ['decimal'] +# The MariaDB uses a .pyd file that imports ``decimal`` module within its +# module initialization function. On recent python versions (> 3.8), the decimal +# module seems to be picked up nevertheless (presumably due to import in some +# other module), but it is better not to rely on that, and ensure it is always +# collected as a hidden import. +hiddenimports = ['decimal']