Repair loader for PyInstaller 3.4

This commit is contained in:
Tobias Gruetzmacher 2019-03-08 23:46:50 +01:00
parent 3a26737b03
commit 9c4a791853
2 changed files with 17 additions and 11 deletions

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2016 Tobias Gruetzmacher
# Copyright (C) 2016-2019 Tobias Gruetzmacher
"""
Functions to load plugin modules.
@ -11,8 +11,8 @@ Example usage:
"""
from __future__ import absolute_import, division, print_function
import pkgutil
import importlib
import pkgutil
from .output import out
@ -25,13 +25,7 @@ def get_modules(folder):
prefix = mod.__name__ + "."
modules = [m[1] for m in pkgutil.iter_modules(mod.__path__, prefix)]
# special handling for PyInstaller
importers = map(pkgutil.get_importer, mod.__path__)
toc = set()
for i in importers:
if hasattr(i, 'toc'):
toc |= i.toc
for elm in toc:
for elm in _get_all_modules_pyinstaller():
if elm.startswith(prefix):
modules.append(elm)
@ -42,6 +36,16 @@ def get_modules(folder):
out.error("could not load module %s: %s" % (name, msg))
def _get_all_modules_pyinstaller():
# Special handling for PyInstaller
toc = set()
importers = pkgutil.iter_importers(__package__)
for i in importers:
if hasattr(i, 'toc'):
toc |= i.toc
return toc
def get_plugins(modules, classobj):
"""Find all class objects in all modules.
@param modules: the modules to search

View file

@ -1,4 +1,4 @@
# -*- mode: python -*-
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
@ -13,7 +13,8 @@ a = Analysis(['../dosage'],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
cipher=block_cipher,
noarchive=False)
a.binaries = [x for x in a.binaries if not x[1].lower().startswith(r'c:\windows')]
@ -28,4 +29,5 @@ exe = EXE(pyz,
debug=False,
strip=False,
upx=False,
runtime_tmpdir=None,
console=True)