| 1 | #!/usr/bin/env bash |
| 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | set -e |
| 4 | PYTHONPATH="$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")" |
| 5 | export PYTHONPATH |
| 6 | command="$(basename "${BASH_SOURCE[0]//-/.}")" |
| 7 | |
| 8 | if [ -z "$MKOSI_INTERPRETER" ]; then |
| 9 | # Note the check seems to be inverted here because the if branch is |
| 10 | # executed when the exit status is 0 which is equal to False in Python. |
| 11 | if python3 -c "import sys; sys.exit(sys.version_info < (3, 9))"; then |
| 12 | MKOSI_INTERPRETER=python3 |
| 13 | elif command -v python3.9 >/dev/null; then |
| 14 | MKOSI_INTERPRETER=python3.9 |
| 15 | else |
| 16 | echo "mkosi needs python 3.9 or newer (found $(python3 --version))" |
| 17 | exit 1 |
| 18 | fi |
| 19 | fi |
| 20 | |
| 21 | exec "$MKOSI_INTERPRETER" -B -m "$command" "$@" |