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

This commit is contained in:
nose
2025-12-24 02:42:13 -08:00
parent 032cf9f191
commit 32494a97ac
2 changed files with 201 additions and 8 deletions

View File

@@ -28,6 +28,7 @@ FIX_URLLIB3=false
# Playwright options
PLAYWRIGHT_BROWSERS="chromium" # comma-separated (chromium,firefox,webkit) or 'all'
NO_PLAYWRIGHT=false
REMOVE_PTH=false
attempt_fix_urllib3() {
local venv_py="$1"
@@ -53,6 +54,87 @@ attempt_fix_urllib3() {
fi
echo "ERROR: urllib3 fix attempt incomplete (import check failed)" >&2
# Detect potential interfering .pth files in site-packages
echo "Searching for interfering .pth files in the venv site-packages..." >&2
local site_pkgs
site_pkgs=$("$venv_py" - <<'PY'
import json, site, sysconfig
paths = []
try:
paths.extend(site.getsitepackages())
except Exception:
pass
try:
p = sysconfig.get_paths().get('purelib')
if p:
paths.append(p)
except Exception:
pass
seen = []
out = []
for s in paths:
if s and s not in seen:
seen.append(s)
out.append(s)
print("\n".join(out))
PY
)
local pths=()
if [[ -n "$site_pkgs" ]]; then
while IFS= read -r sp; do
if [[ -d "$sp" ]]; then
while IFS= read -r f; do
if [[ -n "$f" ]]; then
if grep -qi 'urllib3_future' "$f" >/dev/null 2>&1 || grep -qi 'urllib3-future' "$f" >/dev/null 2>&1; then
pths+=("$f")
fi
fi
done < <(find "$sp" -maxdepth 1 -type f -name '*.pth' -print 2>/dev/null)
fi
done <<< "$site_pkgs"
fi
if [[ ${#pths[@]} -eq 0 ]]; then
echo "No obvious interfering .pth files found in site-packages. Manual inspection recommended." >&2
return 3
fi
echo "Found the following potentially interfering .pth files:" >&2
for p in "${pths[@]}"; do echo " - $p" >&2; done
if [[ "$REMOVE_PTH" == "true" ]]; then
echo "Removing .pth files as requested..." >&2
for p in "${pths[@]}"; do rm -f "$p"; done
else
if [[ "$QUIET" == "true" ]]; then
echo "Detected interfering .pth files but cannot prompt in quiet mode. Re-run with --remove-pth to remove them automatically." >&2
return 3
fi
read -p "Remove these files now? (y/N) " resp
if [[ "$resp" != "y" && "$resp" != "Y" ]]; then
echo "User declined to remove .pth files. Aborting." >&2
return 3
fi
for p in "${pths[@]}"; do rm -f "$p"; done
fi
# Re-run reinstall & verify
echo "Reinstalling urllib3 after .pth removal..." >&2
set +e
"$venv_py" -m pip install --upgrade --force-reinstall urllib3
local pip_ret2=$?
set -e
if [[ $pip_ret2 -ne 0 ]]; then
echo "ERROR: pip reinstall failed after .pth removal (exit $pip_ret2)" >&2
return 2
fi
if "$venv_py" -c 'from SYS.env_check import check_urllib3_compat; ok,msg = check_urllib3_compat(); import sys; sys.exit(0 if ok else 2)'; then
echo "Success: urllib3 issues resolved after .pth removal" >&2
return 0
fi
echo "ERROR: urllib3 still not importable after .pth removal" >&2
return 3
}
@@ -69,6 +151,7 @@ Options:
--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, --fix-urllib3 Attempt to automatically fix known urllib3 issues in the venv if detected
-R, --remove-pth When fixing urllib3, automatically remove interfering .pth files (like urllib3_future.pth)
-f, --force Overwrite existing venv without prompting
-h, --help Show this help
EOF
@@ -83,6 +166,7 @@ while [[ $# -gt 0 ]]; do
-n|--no-install) NOINSTALL=true; shift;;
-f|--force) FORCE=true; shift;;
-F|--fix-urllib3) FIX_URLLIB3=true; shift;;
-R|--remove-pth) REMOVE_PTH=true; shift;;
-q|--quiet) QUIET=true; shift;;
-h|--help) usage; exit 0;;
--no-playwright) NO_PLAYWRIGHT=true; shift;;