khh
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
This commit is contained in:
@@ -140,7 +140,9 @@ def _import_medeia_entry_module():
|
||||
return importlib.import_module("medeia_entry")
|
||||
|
||||
raise ImportError(
|
||||
"Could not import 'medeia_entry'. Ensure the project was installed properly or run from the repo root."
|
||||
"Could not import 'medeia_entry'. This often means the package is not installed into the active virtualenv or is an outdated install.\n"
|
||||
"Remedy: activate your venv and run: pip install -e . (or re-run the bootstrap script).\n"
|
||||
"If problems persist, recreate the venv and reinstall the project."
|
||||
)
|
||||
|
||||
|
||||
@@ -152,10 +154,26 @@ def _run_cli(clean_args: List[str]) -> int:
|
||||
pass
|
||||
|
||||
mod = _import_medeia_entry_module()
|
||||
try:
|
||||
|
||||
# Backwards compatibility: the imported module may not expose `MedeiaCLI` as
|
||||
# an attribute (for example, the installed `medeia_entry` delegates to the
|
||||
# packaged entrypoint instead of importing the top-level `CLI` module at
|
||||
# import-time). Try a few strategies to obtain or invoke the CLI:
|
||||
MedeiaCLI = None
|
||||
if hasattr(mod, "MedeiaCLI"):
|
||||
MedeiaCLI = getattr(mod, "MedeiaCLI")
|
||||
except AttributeError:
|
||||
raise ImportError("Imported module 'medeia_entry' does not define 'MedeiaCLI'")
|
||||
else:
|
||||
# Try importing the top-level `CLI` module directly (editable/repo mode)
|
||||
try:
|
||||
from CLI import MedeiaCLI as _M # type: ignore
|
||||
|
||||
MedeiaCLI = _M
|
||||
except Exception:
|
||||
raise ImportError(
|
||||
"Imported module 'medeia_entry' does not define 'MedeiaCLI' and direct import of top-level 'CLI' failed.\n"
|
||||
"Remedy: activate your venv and run: pip install -e . (or re-run the bootstrap script).\n"
|
||||
"If problems persist, recreate the venv and reinstall the project."
|
||||
)
|
||||
|
||||
try:
|
||||
app = MedeiaCLI()
|
||||
@@ -209,6 +227,22 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
print(f"Error parsing mode flags: {exc}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
# Early environment sanity check to detect urllib3/urllib3-future conflicts.
|
||||
# When a broken urllib3 is detected we print an actionable message and
|
||||
# exit early to avoid confusing import-time errors later during startup.
|
||||
try:
|
||||
from SYS.env_check import ensure_urllib3_ok
|
||||
try:
|
||||
ensure_urllib3_ok(exit_on_error=True)
|
||||
except SystemExit as exc:
|
||||
# Bubble out the exit code as the CLI return value for clearer
|
||||
# behavior in shell sessions and scripts.
|
||||
return int(getattr(exc, "code", 2) or 2)
|
||||
except Exception:
|
||||
# If the sanity check itself cannot be imported or run, don't block
|
||||
# startup; we'll continue and let normal import errors surface.
|
||||
pass
|
||||
|
||||
# If GUI requested, delegate directly (GUI may decide to honor any args itself)
|
||||
if mode == "gui":
|
||||
return _run_gui(clean_args)
|
||||
|
||||
Reference in New Issue
Block a user