# INSTALL -- gradio on offline RHEL 9.6

Quick path. Details in `README.md`, host requirements in
`docs/PREREQUISITES.md`, failure modes in `docs/TROUBLESHOOTING.md`.

## 1. Move the bundle to the offline host

    # on the connected side
    tar czf gradio-template.tar.gz gradio-template/
    sha256sum gradio-template.tar.gz > gradio-template.tar.gz.sha256

    # on the offline host
    sha256sum -c gradio-template.tar.gz.sha256
    tar xzf gradio-template.tar.gz -C /opt
    /opt/gradio-template/scripts/check-bundle.sh

## 2. Make sure the interpreter is present

Install it from your own RHEL repositories -- this bundle ships no RPMs
(`docs/PREREQUISITES.md` explains why):

    python3 -V                                   # 3.9, present by default
    dnf install python3.12 python3.12-pip        # only if you want 3.12

## 3. Install

    cd /opt/gradio-template

    ./scripts/install-gradio.sh 3.12             # gradio 6.28.0
    ./scripts/install-gradio.sh 3.9              # gradio 4.44.1

Each creates `venv-py312` / `venv-py39` inside the bundle. Pass a path as the
second argument to put it elsewhere:

    ./scripts/install-gradio.sh 3.12 /opt/myapp/venv

No network is used: `pip` runs with `--no-index` against `wheels/`.

## 4. Run something

    source venv-py312/bin/activate
    source gradio-offline.env        # do not skip this -- see below
    python templates/01_hello_interface.py

Then open <http://127.0.0.1:7860>.

`gradio-offline.env` matters more than it looks. Without it, gradio's analytics
call and huggingface_hub's metadata lookups have no route out and do not fail
fast, so every launch stalls for the TCP timeout.

## 5. Confirm the whole bundle works

    ./scripts/verify-offline.sh

18 checks: an offline install, 7 template launches, and a `gradio_client` round
trip, for each interpreter. As root each step runs inside `unshare -n`, so a
stray network dependency fails rather than passing unnoticed.

## Which version do I get

| Interpreter | gradio | Why |
|---|---|---|
| Python 3.9 | 4.44.1 | Last release supporting 3.9; gradio 5.0 raised the floor to 3.10 |
| Python 3.12 | 6.28.0 | Current release |

Use 3.12 for new work. The 3.9 set exists for hosts that cannot add an
interpreter; it carries two required pins (`huggingface-hub<1.0`,
`pydantic<2.11`) documented in `requirements/constraints-py39.txt`.

## Deploying as a service

`deploy/gradio-app.service.example` is a systemd unit with the offline
environment, a `nologin` service account, SELinux-friendly scratch paths and
basic hardening.
