55 lines
1.9 KiB
Bash
Executable File
55 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Install Marker (marker-pdf) into a dedicated Python venv at ~/.local/marker-venv.
|
|
# Marker is a PDF→markdown converter (surya-ocr-based, very high quality output).
|
|
# Used to convert chamber-library PDFs into mineable markdown for ARC.
|
|
#
|
|
# Run once on a fresh machine after dotfiles + Brewfile bootstrap.
|
|
# Idempotent: skips if already installed; safe to re-run.
|
|
#
|
|
# First-run model download is large (~1+ GB safetensors) and can take 30-60 min
|
|
# on a residential connection. Models cache to ~/.cache/datalab/models/ for
|
|
# subsequent runs.
|
|
|
|
set -euo pipefail
|
|
|
|
VENV="${HOME}/.local/marker-venv"
|
|
PYTHON_BIN="$(command -v python3 2>/dev/null || true)"
|
|
|
|
echo "Installing Marker into ${VENV}..."
|
|
echo ""
|
|
|
|
# Sanity check
|
|
if [ -z "${PYTHON_BIN}" ]; then
|
|
echo "Error: python3 not found on PATH. Install python@3.13 via Brewfile first."
|
|
exit 1
|
|
fi
|
|
|
|
# 1. Create venv if missing
|
|
if [ -d "${VENV}" ] && [ -x "${VENV}/bin/python" ]; then
|
|
echo " skip: venv already exists at ${VENV}"
|
|
else
|
|
mkdir -p "$(dirname "${VENV}")"
|
|
"${PYTHON_BIN}" -m venv "${VENV}"
|
|
echo " created: ${VENV}"
|
|
fi
|
|
|
|
# 2. Upgrade pip inside venv
|
|
"${VENV}/bin/pip" install --quiet --upgrade pip
|
|
|
|
# 3. Install marker-pdf if missing
|
|
if "${VENV}/bin/marker_single" --help >/dev/null 2>&1; then
|
|
echo " skip: marker already installed"
|
|
"${VENV}/bin/pip" show marker-pdf 2>/dev/null | grep -E "^(Name|Version):" | sed 's/^/ /'
|
|
else
|
|
echo " installing marker-pdf (pulls surya-ocr, torch, transformers — ~2-5 min)..."
|
|
"${VENV}/bin/pip" install --quiet marker-pdf
|
|
echo " installed."
|
|
"${VENV}/bin/pip" show marker-pdf 2>/dev/null | grep -E "^(Name|Version):" | sed 's/^/ /'
|
|
fi
|
|
|
|
echo ""
|
|
echo "Done."
|
|
echo ""
|
|
echo "First run will download models (~1+ GB) to ~/.cache/datalab/models/"
|
|
echo "Test with: ${VENV}/bin/marker_single <path-to-test.pdf> --output_dir /tmp/marker-test"
|