#!/usr/bin/env bash # onw-Image setup (Ubuntu): system packages for the window (WebKit; asks for sudo once), the Python environment (.venv), # the model (~10 GB from Hugging Face), the application list entry; then starts onw-Image. set -e cd "$(dirname "$0")" export PYTHONUTF8=1 if ! python3 -c "import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)" 2>/dev/null; then echo "Python 3.10 or newer is needed (Ubuntu 22.04 and later ship it): sudo apt install python3" exit 1 fi if [ ! -e /dev/accel/accel0 ]; then echo "[setup] note: no NPU device (/dev/accel/accel0). Install the Intel NPU driver (linux-npu-driver 1.38 or newer):" echo " https://github.com/intel/linux-npu-driver/releases" fi need="" webkit=gir1.2-webkit2-4.1 apt-cache show $webkit >/dev/null 2>&1 || webkit=gir1.2-webkit2-4.0 for p in python3-venv python3-gi $webkit; do dpkg -s "$p" >/dev/null 2>&1 || need="$need $p" done if [ -n "$need" ]; then # wl-clipboard / xclip: "copy image" in the window (optional - the window falls back to the web clipboard) for p in wl-clipboard xclip; do dpkg -s "$p" >/dev/null 2>&1 || need="$need $p"; done echo "[setup] installing system packages:$need" sudo apt-get install -y $need fi install_deps() { .venv/bin/python -m pip install --disable-pip-version-check -r requirements.txt \ --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release } if [ ! -f .venv/bin/python ]; then echo "[setup] creating Python environment in .venv ..." python3 -m venv --system-site-packages .venv # GObject / WebKit bindings come from apt (python3-gi) fi if ! cmp -s requirements.txt .venv/requirements.done 2>/dev/null; then if ! install_deps; then echo "[setup] installation failed; rebuilding the Python environment once ..." rm -rf .venv python3 -m venv --system-site-packages .venv install_deps || exit 1 fi cp requirements.txt .venv/requirements.done fi echo "[setup] model ..." .venv/bin/python -m onw_image.fetch_model mkdir -p ~/.local/share/applications cat > ~/.local/share/applications/onw-image.desktop </dev/null 2>&1 &