From e4fd07185eea13ed1bece3edebaa6d092fb91c8d Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 23 Mar 2020 07:45:40 +0100 Subject: [PATCH] refine local path mechanics --- Utils.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Utils.py b/Utils.py index bee31d13..f1fe61bd 100644 --- a/Utils.py +++ b/Utils.py @@ -49,14 +49,17 @@ def local_path(path): if local_path.cached_path: return os.path.join(local_path.cached_path, path) - elif is_bundled() and hasattr(sys, "_MEIPASS"): - # we are running in a PyInstaller bundle - local_path.cached_path = sys._MEIPASS # pylint: disable=protected-access,no-member - + elif is_bundled(): + if hasattr(sys, "_MEIPASS"): + # we are running in a PyInstaller bundle + local_path.cached_path = sys._MEIPASS # pylint: disable=protected-access,no-member + else: + # cx_Freeze + local_path.cached_path = os.path.dirname(os.path.abspath(sys.argv[0])) else: # we are running in a normal Python environment - # or cx_Freeze - local_path.cached_path = os.path.dirname(os.path.abspath(sys.argv[0])) + import __main__ + local_path.cached_path = os.path.dirname(os.path.abspath(__main__.__file__)) return os.path.join(local_path.cached_path, path)