install.sh: skip pip when requests is already system-wide

PEP 668 Debian 13 systems error out on 'pip install --user'. Runtime
only needs requests; pytest+requests-mock are test-only. Detect the
runtime dep first and fall back to pip only when missing.
This commit is contained in:
Cobra
2026-06-11 09:37:02 -04:00
parent 45a8d6163e
commit 745844f721
Regular → Executable
+12 -7
View File
@@ -19,15 +19,20 @@ if mountpoint -q "$HOME/pCloudDrive" 2>/dev/null; then
mkdir -p "$PCLOUD_TARGET"
fi
# Install dependencies
echo "Installing dependencies..."
if ! pip install --user requests requests-mock pytest 2>&1 | tail -5; then
# Install runtime dependency (requests) if missing. Dev deps (pytest, requests-mock)
# are only needed by the test suite — install them separately in a venv if you plan to test.
if python3 -c "import requests" 2>/dev/null; then
echo "Runtime dep 'requests' already importable system-wide; skipping pip install."
else
echo "Installing runtime dependency: requests"
if ! pip install --user requests 2>&1 | tail -5; then
echo "ERROR: pip install --user failed (PEP 668 externally-managed environment?)."
echo "To install in a virtualenv instead, run:"
echo " python3 -m venv ~/tools/coe-mirror/.venv"
echo " source ~/tools/coe-mirror/.venv/bin/activate"
echo " pip install requests requests-mock pytest"
echo "To install in a virtualenv instead:"
echo " python3 -m venv $TOOL_DIR/.venv"
echo " $TOOL_DIR/.venv/bin/pip install requests"
echo " # then edit systemd/coe-mirror.service ExecStart to point at the venv python"
exit 1
fi
fi
# Copy unit files