#!/bin/sh
# Prefer an installed Python with safe tar extraction support.
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
for candidate in python3 python3.14 python3.13 python3.12 /opt/homebrew/bin/python3 /usr/local/bin/python3; do
    if command -v "$candidate" >/dev/null 2>&1 &&
        "$candidate" -c 'import sys; sys.exit(sys.version_info < (3, 12))' 2>/dev/null; then
        exec "$candidate" "$script_dir/../.github/ci/layerfs.py" "$@"
    fi
done
printf '%s\n' 'LayerFS requires Python 3.12 or newer on PATH (Homebrew Python is also supported).' >&2
exit 1
