#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2026 Grace Contributors
#
# Installed as /usr/bin/grace-b2u by the grace-b2u .deb package.
# Invokes `python3 -m grace` against the Python source tree that
# lives under /opt/grace-b2u/ and forwards every argument. The
# package and binary are named grace-b2u to avoid colliding with
# the unrelated Debian/Ubuntu "grace" package (xmgrace).

set -euo pipefail

GRACE_B2U_PREFIX="${GRACE_B2U_PREFIX:-/opt/grace-b2u}"

if [[ ! -d "${GRACE_B2U_PREFIX}/src/grace" ]]; then
    echo "grace-b2u: installation not found at ${GRACE_B2U_PREFIX}" >&2
    echo "           Reinstall the 'grace-b2u' package or set GRACE_B2U_PREFIX." >&2
    exit 64
fi

export PYTHONPATH="${GRACE_B2U_PREFIX}/src${PYTHONPATH:+:${PYTHONPATH}}"
exec python3 -m grace "$@"
