Fix loader in frozen executables.

This commit is contained in:
Bastian Kleineidam 2013-12-18 20:55:23 +01:00
parent e3ab43ada0
commit a1a773dd52

View file

@ -15,7 +15,8 @@ from .output import out
def is_frozen (): def is_frozen ():
"""Return True if running inside a py2exe-generated executable.""" """Return True if running inside a py2exe- or py2app-generated
executable."""
return hasattr(sys, "frozen") return hasattr(sys, "frozen")
@ -29,8 +30,8 @@ def get_modules(folder):
if is_frozen(): if is_frozen():
# find modules in library.zip filename # find modules in library.zip filename
zipname = os.path.dirname(os.path.dirname(__file__)) zipname = os.path.dirname(os.path.dirname(__file__))
parentmodule = os.path.basename(os.path.dirname(__file__))
with zipfile.ZipFile(zipname, 'r') as f: with zipfile.ZipFile(zipname, 'r') as f:
parentmodule = __loader__.fullname.split('.', 1)[0]
prefix = "%s/%s/" % (parentmodule, folder) prefix = "%s/%s/" % (parentmodule, folder)
modnames = [os.path.splitext(n[len(prefix):])[0] modnames = [os.path.splitext(n[len(prefix):])[0]
for n in f.namelist() for n in f.namelist()