From 5f24da7e181def3ac51930c931bca164dbc1910b Mon Sep 17 00:00:00 2001 From: Katelyn Gigante Date: Sat, 10 May 2025 23:20:43 +1000 Subject: [PATCH] Core: Use the location of Utils.py rather than __main__ to determine the AP Folder (#4009) --- Utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Utils.py b/Utils.py index a3a529d7..f930335b 100644 --- a/Utils.py +++ b/Utils.py @@ -139,8 +139,11 @@ def local_path(*path: str) -> str: local_path.cached_path = os.path.dirname(os.path.abspath(sys.argv[0])) else: import __main__ - if hasattr(__main__, "__file__") and os.path.isfile(__main__.__file__): + if globals().get("__file__") and os.path.isfile(__file__): # we are running in a normal Python environment + local_path.cached_path = os.path.dirname(os.path.abspath(__file__)) + elif hasattr(__main__, "__file__") and os.path.isfile(__main__.__file__): + # we are running in a normal Python environment, but AP was imported weirdly local_path.cached_path = os.path.dirname(os.path.abspath(__main__.__file__)) else: # pray