Add helper function to identify when app running as pyinstaller app

Useful for when want the app to behave differently in pyinstaller app
scenario with frozen python. And in development scenarios
This commit is contained in:
Debanjum Singh Solanky
2022-08-18 23:17:21 +03:00
parent 6c5c1c33c1
commit ffbf15eff8
2 changed files with 8 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ import argparse
import pathlib import pathlib
# Internal Packages # Internal Packages
from src.utils.helpers import get_absolute_path, resolve_absolute_path from src.utils.helpers import resolve_absolute_path
from src.utils.yaml import parse_config_from_file from src.utils.yaml import parse_config_from_file

View File

@@ -1,5 +1,6 @@
# Standard Packages # Standard Packages
import pathlib import pathlib
import sys
from os.path import join from os.path import join
@@ -55,3 +56,8 @@ def load_model(model_name, model_dir, model_type):
model.save(model_path) model.save(model_path)
return model return model
def is_pyinstaller_app():
"Returns true if the app is running from Native GUI created by PyInstaller"
return getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS')