diff --git a/oletools/msodde.py b/oletools/msodde.py index a09f7ab..34a26db 100644 --- a/oletools/msodde.py +++ b/oletools/msodde.py @@ -57,6 +57,18 @@ import csv import olefile +# IMPORTANT: it should be possible to run oletools directly as scripts +# in any directory without installing them with pip or setup.py. +# In that case, relative imports are NOT usable. +# And to enable Python 2+3 compatibility, we need to use absolute imports, +# so we add the oletools parent folder to sys.path (absolute+normalized path): +_thismodule_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__))) +# print('_thismodule_dir = %r' % _thismodule_dir) +_parent_dir = os.path.normpath(os.path.join(_thismodule_dir, '..')) +# print('_parent_dir = %r' % _thirdparty_dir) +if _parent_dir not in sys.path: + sys.path.insert(0, _parent_dir) + from oletools import ooxml from oletools import xls_parser from oletools import rtfobj