Core: Use the location of Utils.py rather than __main__ to determine the AP Folder (#4009)

This commit is contained in:
Katelyn Gigante
2025-05-10 23:20:43 +10:00
committed by GitHub
parent 4e61f1f23c
commit 5f24da7e18

View File

@@ -139,8 +139,11 @@ def local_path(*path: str) -> str:
local_path.cached_path = os.path.dirname(os.path.abspath(sys.argv[0])) local_path.cached_path = os.path.dirname(os.path.abspath(sys.argv[0]))
else: else:
import __main__ 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 # 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__)) local_path.cached_path = os.path.dirname(os.path.abspath(__main__.__file__))
else: else:
# pray # pray