def __init__(self):
"""
Load, unzip and initialize the Zip archive bundled with the executable.
"""
# Examine all items in sys.path and the one like /path/executable_name?117568
# is the correct executable with bundled zip archive. Use this value
# for the ZlibArchive class and remove this item from sys.path.
# It was needed only for FrozenImporter class. Wrong path from sys.path
# Raises ArchiveReadError exception.
for pyz_filepath in sys.path:
print pyz_filepath
try:
# Unzip zip archive bundled with the executable.
self._pyz_archive = ZlibArchive(pyz_filepath)
# Verify the integrity of the zip archive with Python modules.
self._pyz_archive.checkmagic()
# End this method since no Exception was raised we can assume
# ZlibArchive was successfully loaded. Let's remove 'pyz_filepath'
# from sys.path.
sys.path.remove(pyz_filepath)
# Some runtime hook might need access to the list of available
# frozen module. Let's make them accessible as a set().
self.toc = set(self._pyz_archive.toc.keys())
# Return - no error was raised.
return
except IOError:
# Item from sys.path is not ZlibArchive let's try next.
continue
except ArchiveReadError:
# Item from sys.path is not ZlibArchive let's try next.
continue
# sys.path does not contain filename of executable with bundled zip archive.
# Raise import error.
raise ImportError("Can't load frozen modules.")