hjhj
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:
@@ -459,26 +459,71 @@ cat > "$USER_BIN/mm" <<'MM'
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# REPO is injected at install time; if it doesn't look like a project, try to
|
||||
# find the repo by walking up from the current working directory.
|
||||
# REPO is injected at install time; try to resolve canonical project root using
|
||||
# git when available to avoid mistakenly selecting parent directories.
|
||||
REPO="__REPO__"
|
||||
# If the embedded REPO does not contain a canonical project marker, search
|
||||
# upward from the current working directory for a project root. Use only
|
||||
# explicit project markers (CLI.py or pyproject.toml) to avoid false positives
|
||||
# from subdirectories like 'scripts' which may contain their own setup.py.
|
||||
if [ ! -f "$REPO/CLI.py" ] && [ ! -f "$REPO/pyproject.toml" ]; then
|
||||
CUR="$(pwd -P)"
|
||||
while [ "$CUR" != "/" ] && [ "$CUR" != "" ]; do
|
||||
if [ -f "$CUR/CLI.py" ] || [ -f "$CUR/pyproject.toml" ]; then
|
||||
REPO="$CUR"
|
||||
break
|
||||
if command -v git >/dev/null 2>&1; then
|
||||
gitroot=$(git -C "$REPO" rev-parse --show-toplevel 2>/dev/null || true)
|
||||
if [ -n "$gitroot" ]; then
|
||||
REPO="$gitroot"
|
||||
else
|
||||
# Try resolving from the current working directory
|
||||
gitroot=$(git -C "$(pwd -P)" rev-parse --show-toplevel 2>/dev/null || true)
|
||||
if [ -n "$gitroot" ]; then
|
||||
REPO="$gitroot"
|
||||
fi
|
||||
CUR="$(dirname "$CUR")"
|
||||
done
|
||||
fi
|
||||
else
|
||||
# Fallback: walk up from CWD to find CLI.py or pyproject.toml
|
||||
if [ ! -f "$REPO/CLI.py" ] && [ ! -f "$REPO/pyproject.toml" ]; then
|
||||
CUR="$(pwd -P)"
|
||||
while [ "$CUR" != "/" ] && [ "$CUR" != "" ]; do
|
||||
if [ -f "$CUR/CLI.py" ] || [ -f "$CUR/pyproject.toml" ]; then
|
||||
REPO="$CUR"
|
||||
break
|
||||
fi
|
||||
CUR="$(dirname "$CUR")"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
VENV="$REPO/.venv"
|
||||
|
||||
# Debug mode: set MM_DEBUG=1 to print repository, venv, and import diagnostics
|
||||
if [ -n "${MM_DEBUG:-}" ]; then
|
||||
echo "MM_DEBUG: diagnostics" >&2
|
||||
echo "Resolved REPO: $REPO" >&2
|
||||
echo "Resolved VENV: $VENV" >&2
|
||||
echo "VENV exists: $( [ -d "$VENV" ] && echo yes || echo no )" >&2
|
||||
echo "Candidates:" >&2
|
||||
echo " VENV/bin/mm: $( [ -x "$VENV/bin/mm" ] && echo yes || echo no )" >&2
|
||||
echo " VENV/bin/python3: $( [ -x "$VENV/bin/python3" ] && echo yes || echo no )" >&2
|
||||
echo " VENV/bin/python: $( [ -x "$VENV/bin/python" ] && echo yes || echo no )" >&2
|
||||
echo " system python3: $(command -v python3 || echo none)" >&2
|
||||
echo " system python: $(command -v python || echo none)" >&2
|
||||
for pycmd in "$VENV/bin/python3" "$VENV/bin/python" "$(command -v python3 2>/dev/null)" "$(command -v python 2>/dev/null)"; do
|
||||
if [ -n "$pycmd" ] && [ -x "$pycmd" ]; then
|
||||
echo "---- Testing with: $pycmd ----" >&2
|
||||
"$pycmd" - <<'PY'
|
||||
import sys, importlib, traceback, importlib.util
|
||||
print('sys.executable:', sys.executable)
|
||||
print('sys.path (first 8):', sys.path[:8])
|
||||
for mod in ('CLI','medeia_macina','medeia_macina.cli_entry'):
|
||||
try:
|
||||
spec = importlib.util.find_spec(mod)
|
||||
print(mod, 'spec:', spec)
|
||||
if spec:
|
||||
m = importlib.import_module(mod)
|
||||
print(mod, 'loaded at', getattr(m, '__file__', None))
|
||||
except Exception:
|
||||
print(mod, 'import failed')
|
||||
traceback.print_exc()
|
||||
PY
|
||||
fi
|
||||
done
|
||||
echo "MM_DEBUG: end diagnostics" >&2
|
||||
fi
|
||||
|
||||
# Packaged console script in the venv if available
|
||||
if [ -x "$VENV/bin/mm" ]; then
|
||||
exec "$VENV/bin/mm" "$@"
|
||||
@@ -574,4 +619,7 @@ To run the app:
|
||||
$VENV_PY -m medeia_macina.cli_entry # alternative
|
||||
|
||||
Global launcher installed: $USER_BIN/mm
|
||||
|
||||
If the global 'mm' launcher fails to run, collect diagnostics with MM_DEBUG=1:
|
||||
MM_DEBUG=1 mm
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user