fix: move dep checks into scripts/check_deps.sh for robustness

Replaces fragile one-liner Makefile chain with a proper shell script.
Tries: sudo -n apt → python3 -m pip --user → get-pip.py bootstrap.
Prints a clear manual-install message if all automated paths fail.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 09:23:01 -04:00
parent b2f12824ac
commit 368457ecce
2 changed files with 49 additions and 13 deletions
+1 -13
View File
@@ -39,19 +39,7 @@ help:
# Setup commands
check-deps:
@echo "Checking system dependencies..."
@which python3 >/dev/null 2>&1 || \
{ echo "Installing python3..." && sudo -n apt-get install -y python3 2>/dev/null || \
{ echo "ERROR: python3 not found. Run: sudo apt-get install -y python3" ; exit 1 ; } ; }
@python3 -c "import cryptography" 2>/dev/null || { \
echo "Installing python3-cryptography..." ; \
sudo -n apt-get install -y python3-cryptography 2>/dev/null || \
python3 -m pip install --user cryptography 2>/dev/null || \
{ python3 -m ensurepip --upgrade 2>/dev/null && python3 -m pip install --user cryptography 2>/dev/null ; } || \
{ echo "ERROR: Cannot install python3-cryptography. Run: sudo apt-get install python3-cryptography" ; exit 1 ; } ; }
@python3 -c "import cryptography" >/dev/null 2>&1 || \
{ echo "ERROR: python3-cryptography still not found. Run: sudo apt-get install python3-cryptography" ; exit 1 ; }
@echo "Dependencies OK."
@sh scripts/check_deps.sh
setup: check-deps
@echo "Setting up Personal Internet Cell..."
+48
View File
@@ -0,0 +1,48 @@
#!/bin/sh
# Install Python dependencies needed by setup_cell.py
set -e
echo "Checking system dependencies..."
# Ensure python3 is available
if ! command -v python3 >/dev/null 2>&1; then
echo "Installing python3..."
sudo apt-get install -y python3 || { echo "ERROR: python3 not found and could not install it."; exit 1; }
fi
# Check if cryptography is already importable
if python3 -c "import cryptography" 2>/dev/null; then
echo "Dependencies OK."
exit 0
fi
echo "Installing python3-cryptography..."
# 1. Try apt (works if sudo is passwordless or interactive TTY is available)
if sudo -n apt-get install -y python3-cryptography 2>/dev/null; then
echo "Dependencies OK."
exit 0
fi
# 2. Try pip (module form, covers both pip3 and python3 -m pip)
if python3 -m pip install --user cryptography 2>/dev/null; then
echo "Dependencies OK."
exit 0
fi
# 3. Bootstrap pip via get-pip.py, then install
if command -v curl >/dev/null 2>&1; then
curl -sSL https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py 2>/dev/null \
&& python3 /tmp/get-pip.py --user -q 2>/dev/null \
&& python3 -m pip install --user cryptography 2>/dev/null \
&& { echo "Dependencies OK."; exit 0; }
fi
# 4. No automated path worked — ask the user to install manually
echo ""
echo "ERROR: Could not install python3-cryptography automatically."
echo "Please run the following command and then retry:"
echo ""
echo " sudo apt-get install -y python3-cryptography"
echo ""
exit 1