installer: embed repo path in global 'mm' launcher and fall back to locating repo from CWD; prefer venv's python3
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled

This commit is contained in:
nose
2025-12-24 03:09:59 -08:00
parent 2208fdad96
commit 26e0d749d7
2 changed files with 32 additions and 17 deletions

View File

@@ -363,14 +363,20 @@ python $cli @args
sh_text = (
"#!/usr/bin/env bash\n"
"set -e\n"
"SCRIPT=\"$0\"\n"
"if command -v readlink >/dev/null 2>&1; then\n"
" if readlink -f \"$SCRIPT\" >/dev/null 2>&1; then\n"
" SCRIPT=\"$(readlink -f \"$SCRIPT\")\"\n"
" fi\n"
f"REPO=\"{repo}\"\n"
"# If the packaged REPO does not look valid at runtime, try to locate the repo by walking\n"
"# up from the current working directory so the launcher works when executed inside the\n"
"# project tree or when the global bin is symlinked into the repo.\n"
"if [ ! -f \"$REPO/CLI.py\" ] && [ ! -f \"$REPO/pyproject.toml\" ] && [ ! -f \"$REPO/setup.py\" ]; then\n"
" CUR=\"$(pwd -P)\"\n"
" while [ \"$CUR\" != \"/\" ] && [ \"$CUR\" != \"\" ]; do\n"
" if [ -f \"$CUR/CLI.py\" ] || [ -f \"$CUR/pyproject.toml\" ] || [ -f \"$CUR/setup.py\" ]; then\n"
" REPO=\"$CUR\"\n"
" break\n"
" fi\n"
" CUR=\"$(dirname \"$CUR\")\"\n"
" done\n"
"fi\n"
"SCRIPT_DIR=\"$(cd \"$(dirname \"$SCRIPT\")\" && pwd -P)\"\n"
"REPO=\"$(cd \"$SCRIPT_DIR/..\" && pwd -P)\"\n"
"VENV=\"$REPO/.venv\"\n"
"if [ -x \"$VENV/bin/mm\" ]; then\n"
" exec \"$VENV/bin/mm\" \"$@\"\n"