From fb345845fe7102fde325253e8d11d331130b9f48 Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Thu, 16 Apr 2020 23:22:58 +0300 Subject: [PATCH] Added pyinstaller hook for stix2 module --- monkey/monkey_island/monkey_island.spec | 2 +- monkey/monkey_island/pyinstaller_hooks/__init__.py | 0 monkey/monkey_island/pyinstaller_hooks/hook-stix2.py | 7 +++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 monkey/monkey_island/pyinstaller_hooks/__init__.py create mode 100644 monkey/monkey_island/pyinstaller_hooks/hook-stix2.py diff --git a/monkey/monkey_island/monkey_island.spec b/monkey/monkey_island/monkey_island.spec index fd6d0c3e1..f56fc8069 100644 --- a/monkey/monkey_island/monkey_island.spec +++ b/monkey/monkey_island/monkey_island.spec @@ -19,7 +19,7 @@ def main(): a = Analysis(['cc/main.py'], pathex=['..'], hiddenimports=get_hidden_imports(), - hookspath=None, + hookspath=[os.path.join(".", "pyinstaller_hooks")], runtime_hooks=None, binaries=None, datas=added_datas, diff --git a/monkey/monkey_island/pyinstaller_hooks/__init__.py b/monkey/monkey_island/pyinstaller_hooks/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/monkey/monkey_island/pyinstaller_hooks/hook-stix2.py b/monkey/monkey_island/pyinstaller_hooks/hook-stix2.py new file mode 100644 index 000000000..22a9c9774 --- /dev/null +++ b/monkey/monkey_island/pyinstaller_hooks/hook-stix2.py @@ -0,0 +1,7 @@ +# Workaround for packaging Monkey Island using PyInstaller. See https://github.com/oasis-open/cti-python-stix2/issues/218 + +import os +from PyInstaller.utils.hooks import get_module_file_attribute + +stix2_dir = os.path.dirname(get_module_file_attribute('stix2')) +datas = [(stix2_dir, 'stix2')]