Skip to content

Commit

Permalink
Fixed pyinstaller errors
Browse files Browse the repository at this point in the history
  • Loading branch information
drHyperion451 committed Nov 1, 2023
1 parent bd8a276 commit a31bc27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@
home = Path.home()
JSON_FILEPATH = 'src/ml_info.json'
SETTINGS_PATH = 'config.ini'
if getattr(sys, 'frozen', True):
JSON_FILEPATH = Path(sys._MEIPASS) / "src" / "ml_info.json"
SETTINGS_PATH = f"{Path(sys._MEIPASS).parent}/config.ini"
maps = MapsJson(JSON_FILEPATH)
try:
"""
This is needed if you want to freeze the script. If not, it won't load
correctly.
"""
JSON_FILEPATH = f"{sys._MEIPASS}/src/ml_info.json"
JSON_FILEPATH = Path(sys._MEIPASS) / "src" / "ml_info.json"
SETTINGS_PATH = f"{Path(sys._MEIPASS).parent}/config.ini"
except (NameError, AttributeError) as error:
print(f"{error}. Expected to be running as script, not frozen.")




def SETTINGS_CREATE(settings_path):
config = ConfigParser()
config.read(settings_path)
Expand Down
3 changes: 2 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def action_request_settings(self) -> None:
sys.stdout.write("\x1b]2;%s\x07" % 'MLauncher')

# CWD to executable
if getattr(sys, 'frozen', False):
if getattr(sys, 'frozen', True):
print(sys.frozen)
os.chdir(os.path.dirname(sys.executable))


Expand Down

0 comments on commit a31bc27

Please sign in to comment.