From 9c4a79185360862084ea1d2a9fd0597be91a60ea Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Fri, 8 Mar 2019 23:46:50 +0100 Subject: [PATCH] Repair loader for PyInstaller 3.4 --- dosagelib/loader.py | 22 +++++++++++++--------- scripts/dosage.spec | 6 ++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/dosagelib/loader.py b/dosagelib/loader.py index 1ecac2c1b..7c8cc61d9 100644 --- a/dosagelib/loader.py +++ b/dosagelib/loader.py @@ -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 diff --git a/scripts/dosage.spec b/scripts/dosage.spec index 730e2c4c7..bb3310eeb 100644 --- a/scripts/dosage.spec +++ b/scripts/dosage.spec @@ -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)