| import functools |
| import logging |
| import os |
|
|
| logger = logging.getLogger(__name__) |
|
|
| _DEFAULT_DEPLOY_ENV = "local-git" |
| _ENV_FILENAME = ".comfy_environment" |
|
|
| |
| |
| |
| |
| |
| _COMFY_INSTALL_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) |
|
|
|
|
| @functools.cache |
| def get_deploy_environment() -> str: |
| env_file = os.path.join(_COMFY_INSTALL_DIR, _ENV_FILENAME) |
| try: |
| with open(env_file, encoding="utf-8") as f: |
| |
| |
| first_line = f.readline(128).strip() |
| value = "".join(c for c in first_line if 32 <= ord(c) < 127) |
| if value: |
| return value |
| except FileNotFoundError: |
| pass |
| except Exception as e: |
| logger.error("Failed to read %s: %s", env_file, e) |
|
|
| return _DEFAULT_DEPLOY_ENV |
|
|