From ffbf15eff868bf3f08ed6e8d9ad251255175c1f2 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 18 Aug 2022 23:17:21 +0300 Subject: [PATCH] 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 --- src/utils/cli.py | 2 +- src/utils/helpers.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils/cli.py b/src/utils/cli.py index e855f706..a140bb46 100644 --- a/src/utils/cli.py +++ b/src/utils/cli.py @@ -3,7 +3,7 @@ import argparse import pathlib # 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 diff --git a/src/utils/helpers.py b/src/utils/helpers.py index 78c2f176..e77e656d 100644 --- a/src/utils/helpers.py +++ b/src/utils/helpers.py @@ -1,5 +1,6 @@ # Standard Packages import pathlib +import sys from os.path import join @@ -54,4 +55,9 @@ def load_model(model_name, model_dir, model_type): if model_path is not None: model.save(model_path) - return model \ No newline at end of file + 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') \ No newline at end of file