From 1e67ef6a34b636237e693833fdfb80ee202c0f03 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Mon, 6 May 2019 21:18:14 +0100 Subject: [PATCH] Ignore warning for pyinstaller dependency search. --- vol.spec | 4 +--- volatility/__init__.py | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/vol.spec b/vol.spec index a9c420c95..c0706c89a 100644 --- a/vol.spec +++ b/vol.spec @@ -46,9 +46,7 @@ a = Analysis(['vol.py'], collect_data_files('volatility.plugins', include_py_files = True), hiddenimports = collect_submodules('volatility.framework.automagic') + \ collect_submodules('volatility.framework.plugins') + \ - collect_submodules('volatility.framework.symbols') + \ - collect_submodules('volatility.plugins') + \ - collect_submodules('volatility.automagic'), + collect_submodules('volatility.framework.symbols'), hookspath = [], runtime_hooks = [], excludes = [], diff --git a/volatility/__init__.py b/volatility/__init__.py index dcadc9950..894508d68 100644 --- a/volatility/__init__.py +++ b/volatility/__init__.py @@ -30,7 +30,11 @@ class WarningFindSpec(abc.MetaPathFinder): def find_spec(fullname: str, path, target = None): """Mock find_spec method that just checks the name, this must go first""" if fullname.startswith("volatility.framework.plugins."): - raise Warning("Please do not use the volatility.framework.plugins namespace, only use volatility.plugins") + warning = "Please do not use the volatility.framework.plugins namespace directly, only use volatility.plugins" + # Pyinstaller uses pkgutil to import, but needs to read the modules to figure out dependencies + # As such, we only print the warning when directly imported rather than being run from a script + if 'pkgutil' not in sys.modules: + raise Warning(warning) warning_find_spec = [WarningFindSpec()] # type: List[abc.MetaPathFinder]