mirror of
https://github.com/SuperClaude-Org/SuperClaude_Framework.git
synced 2025-12-29 16:16:08 +00:00
import path workaround in __main__.py (#272)
* Refactor setup directory import logic for compatibility with Windows and Python 3.10 * fixed cannot import 'setup.utils.ui'
This commit is contained in:
@@ -18,17 +18,13 @@ 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 (with deprecation-safe logic)
|
# This needed a modification for windows and python 3.10 - JPShag
|
||||||
|
# Resolved ImportError: cannot import 'setup.utils.ui' because the sibling 'setup' directory was not on sys.path.
|
||||||
try:
|
# Find the setup directory relative to this file
|
||||||
# Python 3.9+ preferred modern way
|
setup_dir = Path(__file__).parent.parent / "setup"
|
||||||
from importlib.resources import files, as_file
|
if not setup_dir.exists():
|
||||||
with as_file(files("setup")) as resource:
|
# Try alternative location if running from installed package
|
||||||
setup_dir = str(resource)
|
setup_dir = Path(__file__).parent / "setup"
|
||||||
except (ImportError, ModuleNotFoundError, AttributeError):
|
|
||||||
# Fallback for Python < 3.9
|
|
||||||
from pkg_resources import resource_filename
|
|
||||||
setup_dir = resource_filename('setup', '')
|
|
||||||
|
|
||||||
# Add to sys.path
|
# Add to sys.path
|
||||||
sys.path.insert(0, str(setup_dir))
|
sys.path.insert(0, str(setup_dir))
|
||||||
@@ -59,6 +55,9 @@ except ImportError:
|
|||||||
INFO = 20
|
INFO = 20
|
||||||
DEBUG = 10
|
DEBUG = 10
|
||||||
|
|
||||||
|
# Default install directory fallback
|
||||||
|
DEFAULT_INSTALL_DIR = Path.home() / ".claude"
|
||||||
|
|
||||||
|
|
||||||
def create_global_parser() -> argparse.ArgumentParser:
|
def create_global_parser() -> argparse.ArgumentParser:
|
||||||
"""Create shared parser for global flags used by all commands"""
|
"""Create shared parser for global flags used by all commands"""
|
||||||
|
|||||||
Reference in New Issue
Block a user