#!/bin/sh
# -----------------------------------------------------------------------------------------------------------
# Copyright (c) 2026 Huawei Technologies Co., Ltd.
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
# CANN Open Software License Agreement Version 2.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# -----------------------------------------------------------------------------------------------------------
# Keep this bootstrap on one line so sh can run it from a CRLF checkout.
cr=$(printf '\r'); if grep -q "$cr$" < "$0"; then lf=$(sed -e "s/$cr$//" -e '/# OAT_CRLF_BOOTSTRAP$/d' < "$0") && exec sh -c "$lf" "$0" "$@"; exit 2; fi; # OAT_CRLF_BOOTSTRAP
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) || exit 2
for candidate in python3 python py; do
if command -v "$candidate" >/dev/null 2>&1 &&
"$candidate" -c 'import sys; sys.exit(sys.version_info < (3, 7))' 2>/dev/null; then
exec "$candidate" "$SCRIPT_DIR/oat_check.py" "$@"
fi
done
echo "[OAT] Python 3.7+ is required. Install Python and retry the check." >&2
exit 2