pyi_hooksample/ - Hook sample package

This is a trivial package, which contains a hidden import and depends on a data file. For these reasons, this library needs PyInstaller hooks in order to be frozen properly by PyInstaller.

import pkgutil
import importlib

__version__ = "0.1"
__all__ = ["do_import", "print_message"]


Uses importlib to import the - A hidden import module. Since PyInstaller only performs static analysis, it cannot detect this import.

def do_import():

Direct use of __import__() is discouraged in favor of importlib.import_module().

    importlib.import_module('._hidden', __name__)