From bb8d5d0d6585ed8058b214003b87743ae992c98d Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Wed, 29 Apr 2015 00:27:42 +0300 Subject: [PATCH] Change the way we detect pyfa path This ensures that it works even with frozen executable --- config.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index ca6cadff1..5e9ab637e 100644 --- a/config.py +++ b/config.py @@ -29,6 +29,13 @@ staticPath = None saveDB = None gameDB = None + +def get_main_dir(): + if hasattr(sys, "frozen"): + # print 'Running from path', os.path.dirname(sys.executable) + return unicode(os.path.dirname(os.path.realpath(os.path.abspath(sys.executable))), sys.getfilesystemencoding()) + return unicode(os.path.dirname(os.path.realpath(os.path.abspath(sys.modules['__main__'].__file__))), sys.getfilesystemencoding()) + def defPaths(): global pyfaPath global savePath @@ -40,8 +47,7 @@ def defPaths(): # Python 2.X uses ANSI by default, so we need to convert the character encoding pyfaPath = getattr(configforced, "pyfaPath", pyfaPath) if pyfaPath is None: - pyfaPath = unicode(os.path.dirname(os.path.realpath(os.path.abspath( - sys.modules['__main__'].__file__))), sys.getfilesystemencoding()) + pyfaPath = get_main_dir() # Where we store the saved fits etc, default is the current users home directory if saveInRoot is True: