hook-wx.lib.activex.py 970 B

123456789101112131415161718192021222324252627
  1. # ------------------------------------------------------------------
  2. # Copyright (c) 2020 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 import isolated
  13. # This is necessary because on first import, `wx.lib.activex` generates .tlb file for `comtypes`, unless running in a
  14. # frozen application (in which case, the .tlb file is expected to exist already). So if we are building in a completely
  15. # clean python environment (for example, in a CI/CD pipeline), we need to ensure that .tlb file is generated.
  16. @isolated.decorate
  17. def _ensure_tlb_file_exists():
  18. try:
  19. import wx.lib.activex # noqa: F401
  20. except Exception:
  21. pass
  22. _ensure_tlb_file_exists()