hook-mariadb.py 1.1 KB

12345678910111213141516171819202122232425
  1. # ------------------------------------------------------------------
  2. # Copyright (c) 2021 PyInstaller Development Team.
  3. #
  4. # This file is distributed under the terms of the GNU General Public
  5. # License (version 2.0 or later).
  6. #
  7. # The full license is available in LICENSE, distributed with
  8. # this software.
  9. #
  10. # SPDX-License-Identifier: GPL-2.0-or-later
  11. # ------------------------------------------------------------------
  12. from PyInstaller.utils.hooks import is_module_satisfies, collect_submodules
  13. # The MariaDB uses a .pyd file that imports ``decimal`` module within its
  14. # module initialization function. On recent python versions (> 3.8), the decimal
  15. # module seems to be picked up nevertheless (presumably due to import in some
  16. # other module), but it is better not to rely on that, and ensure it is always
  17. # collected as a hidden import.
  18. hiddenimports = ['decimal']
  19. # mariadb >= 1.1.0 requires several hidden imports from mariadb.constants.
  20. # Collect them all, just to be on the safe side...
  21. if is_module_satisfies("mariadb >= 1.1.0"):
  22. hiddenimports += collect_submodules("mariadb.constants")