-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·58 lines (48 loc) · 2.61 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·58 lines (48 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────────────
# PDF Text Extractor — launcher script
# Installs dependencies (once) then launches the app.
#
# Usage:
# chmod +x run.sh (first time only)
# ./run.sh
#
# To open specific PDFs immediately:
# ./run.sh ~/Documents/report.pdf invoice.pdf
# ─────────────────────────────────────────────────────────────────────────────
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
APP="$SCRIPT_DIR/pdf_text_extractor.py"
REQS="$SCRIPT_DIR/requirements.txt"
# ── Locate python3 ───────────────────────────────────────────────────────────
if command -v python3 &>/dev/null; then
PYTHON=python3
else
echo "❌ python3 not found."
echo " Please install Python 3.10+ from https://www.python.org/downloads/"
exit 1
fi
PY_VER=$("$PYTHON" -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
PY_MAJOR=$("$PYTHON" -c "import sys; print(sys.version_info.major)")
PY_MINOR=$("$PYTHON" -c "import sys; print(sys.version_info.minor)")
if [[ "$PY_MAJOR" -lt 3 ]] || [[ "$PY_MAJOR" -eq 3 && "$PY_MINOR" -lt 9 ]]; then
echo "❌ Python $PY_VER found, but 3.9+ is required."
exit 1
fi
echo "✓ Python $PY_VER"
# ── Install / upgrade dependencies ────────────────────────────────────────────
echo "📦 Checking dependencies…"
INSTALL_FLAGS="--quiet --upgrade"
# On macOS system Python or Homebrew, --break-system-packages may be needed
"$PYTHON" -m pip install $INSTALL_FLAGS -r "$REQS" 2>/dev/null || \
"$PYTHON" -m pip install $INSTALL_FLAGS --break-system-packages -r "$REQS" || {
echo ""
echo "⚠️ pip install failed. Trying with --user flag…"
"$PYTHON" -m pip install $INSTALL_FLAGS --user -r "$REQS"
}
echo "✅ Dependencies ready"
echo ""
echo "🚀 Launching PDF Text Extractor…"
echo ""
# ── Launch ────────────────────────────────────────────────────────────────────
exec "$PYTHON" "$APP" "$@"