khh
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled

This commit is contained in:
nose
2025-12-24 02:13:21 -08:00
parent 8bf04c6b71
commit 24dd18de7e
20 changed files with 1792 additions and 636 deletions

View File

@@ -9,6 +9,10 @@ DESKTOP=false
PYTHON_CMD=""
NOINSTALL=false
FORCE=false
QUIET=false
# Playwright options
PLAYWRIGHT_BROWSERS="chromium" # comma-separated (chromium,firefox,webkit) or 'all'
NO_PLAYWRIGHT=false
usage() {
cat <<EOF
@@ -19,6 +23,9 @@ Options:
--python <python> Python executable to use (e.g. python3)
-d, --desktop Create a desktop launcher (~/.local/share/applications and ~/Desktop)
-n, --no-install Skip pip install
--no-playwright Skip installing Playwright browsers (default: install chromium)
--playwright-browsers <list> Comma-separated list of browsers to install (default: chromium)
-q, --quiet Quiet / non-interactive mode; abort on errors instead of prompting
-f, --force Overwrite existing venv without prompting
-h, --help Show this help
EOF
@@ -32,7 +39,10 @@ while [[ $# -gt 0 ]]; do
-d|--desktop) DESKTOP=true; shift;;
-n|--no-install) NOINSTALL=true; shift;;
-f|--force) FORCE=true; shift;;
-q|--quiet) QUIET=true; shift;;
-h|--help) usage; exit 0;;
--no-playwright) NO_PLAYWRIGHT=true; shift;;
--playwright-browsers) PLAYWRIGHT_BROWSERS="$2"; shift 2;;
*) echo "Unknown option: $1"; usage; exit 1;;
esac
done
@@ -51,21 +61,52 @@ fi
echo "Using Python: $PY"
if [[ -d "$VENV_PATH" ]]; then
# Detect whether the existing venv has a working python executable
VENV_PY=""
for cand in "$VENV_PATH/bin/python" "$VENV_PATH/bin/python3" "$VENV_PATH/Scripts/python.exe"; do
if [[ -x "$cand" ]]; then
VENV_PY="$cand"
break
fi
done
if [[ "$FORCE" == "true" ]]; then
echo "Removing existing venv $VENV_PATH"
rm -rf "$VENV_PATH"
else
read -p "$VENV_PATH already exists. Overwrite? [y/N] " REPLY
if [[ "$REPLY" != "y" && "$REPLY" != "Y" ]]; then
echo "Aborted."; exit 0
if [[ -z "$VENV_PY" ]]; then
if [[ "$QUIET" == "true" ]]; then
echo "ERROR: Existing venv appears incomplete or broken (no python executable). Use --force to recreate." >&2
exit 4
fi
read -p "$VENV_PATH exists but appears invalid (no python executable). Overwrite to recreate? (y/N) " REPLY
if [[ "$REPLY" != "y" && "$REPLY" != "Y" ]]; then
echo "Aborted."; exit 4
fi
rm -rf "$VENV_PATH"
else
if [[ "$QUIET" == "true" ]]; then
echo "Using existing venv at $VENV_PATH (quiet mode)"
else
read -p "$VENV_PATH already exists. Overwrite? (y/N) (default: use existing venv) " REPLY
if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then
echo "Removing existing venv $VENV_PATH"
rm -rf "$VENV_PATH"
else
echo "Continuing using existing venv at $VENV_PATH"
fi
fi
fi
rm -rf "$VENV_PATH"
fi
fi
echo "Creating venv at $VENV_PATH"
$PY -m venv "$VENV_PATH"
VENV_PY="$VENV_PATH/bin/python"
if [[ -d "$VENV_PATH" && -n "${VENV_PY:-}" && -x "${VENV_PY:-}" ]]; then
echo "Using existing venv at $VENV_PATH"
else
echo "Creating venv at $VENV_PATH"
$PY -m venv "$VENV_PATH"
VENV_PY="$VENV_PATH/bin/python"
fi
if [[ ! -x "$VENV_PY" ]]; then
echo "ERROR: venv python not found at $VENV_PY" >&2
@@ -98,6 +139,41 @@ if [[ "$NOINSTALL" != "true" ]]; then
echo "Action: Try running: $VENV_PY -m pip install -e . or inspect the venv site-packages to verify the installation." >&2
fi
fi
echo "Verifying environment for known issues (urllib3 compatibility)..."
if ! "$VENV_PY" -c 'from SYS.env_check import check_urllib3_compat; ok,msg = check_urllib3_compat(); print(msg); import sys; sys.exit(0 if ok else 2)'; then
echo "ERROR: Bootstrap detected a potentially broken 'urllib3' installation. See message above." >&2
echo "You can attempt to fix with:" >&2
echo " $VENV_PY -m pip uninstall urllib3-future -y" >&2
echo " $VENV_PY -m pip install --upgrade --force-reinstall urllib3" >&2
echo " $VENV_PY -m pip install niquests -U" >&2
exit 7
fi
# Install Playwright browsers (default: chromium) unless explicitly disabled
if [[ "$NO_PLAYWRIGHT" != "true" && "$NOINSTALL" != "true" ]]; then
echo "Ensuring Playwright browsers are installed (browsers=$PLAYWRIGHT_BROWSERS)..."
# Install package if missing in venv
if ! "$VENV_PY" -c 'import importlib, sys; importlib.import_module("playwright")' >/dev/null 2>&1; then
echo "'playwright' package not found in venv; installing via pip..."
"$VENV_PY" -m pip install playwright
fi
# Compute install behavior: 'all' means install all engines, otherwise split comma list
if [[ "$PLAYWRIGHT_BROWSERS" == "all" ]]; then
echo "Installing all Playwright browsers..."
"$VENV_PY" -m playwright install || echo "Warning: Playwright browser install failed" >&2
else
IFS=',' read -ra PWB <<< "$PLAYWRIGHT_BROWSERS"
for b in "${PWB[@]}"; do
b_trimmed=$(echo "$b" | tr -d '[:space:]')
if [[ -n "$b_trimmed" ]]; then
echo "Installing Playwright browser: $b_trimmed"
"$VENV_PY" -m playwright install "$b_trimmed" || echo "Warning: Playwright install for $b_trimmed failed" >&2
fi
done
fi
fi
else
echo "Skipping install (--no-install)"
fi
@@ -139,7 +215,7 @@ if [[ "$DESKTOP" == "true" ]]; then
Name=Medeia-Macina
Comment=Launch Medeia-Macina
Exec=$EXEC_PATH
Terminal=true
Terminal=false
Type=Application
Categories=Utility;
EOF