Update __main__.py

Signed-off-by: Mithun Gowda B <mithungowda.b7411@gmail.com>
This commit is contained in:
Mithun Gowda B 2025-07-16 11:31:05 +05:30 committed by GitHub
parent 1af243bffa
commit 67585af9a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,11 +18,23 @@ import difflib
from pathlib import Path from pathlib import Path
from typing import Dict, Callable from typing import Dict, Callable
# Add the 'setup' directory to the Python import path # Add the 'setup' directory to the Python import path (with deprecation-safe logic)
import sys
try:
# Python 3.9+ preferred modern way
from importlib.resources import files, as_file
with as_file(files("setup")) as resource:
setup_dir = str(resource)
except (ImportError, ModuleNotFoundError, AttributeError):
# Fallback for Python < 3.9
from pkg_resources import resource_filename from pkg_resources import resource_filename
setup_dir = resource_filename('setup', '') setup_dir = resource_filename('setup', '')
# Add to sys.path
sys.path.insert(0, str(setup_dir)) sys.path.insert(0, str(setup_dir))
# Try to import utilities from the setup package # Try to import utilities from the setup package
try: try:
from setup.utils.ui import ( from setup.utils.ui import (