2023-01-16 14:52:22 +08:00
#!/bin/bash
2023-01-02 01:54:45 +08:00
2022-12-11 13:37:08 +08:00
# make sure we are not already in a venv
# (don't need to check status)
deactivate >/dev/null 2>& 1
2023-02-04 10:42:00 +08:00
scriptdir = $( dirname " $0 " )
cd $scriptdir
2022-12-11 13:37:08 +08:00
2023-02-04 10:42:00 +08:00
function version { echo " $@ " | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }' ; }
MINIMUM_PYTHON_VERSION = 3.9.0
2023-07-25 05:21:56 +08:00
MAXIMUM_PYTHON_VERSION = 3.11.100
2023-02-04 10:42:00 +08:00
PYTHON = ""
2023-07-25 05:21:56 +08:00
for candidate in python3.11 python3.10 python3.9 python3 python ; do
2023-02-04 10:42:00 +08:00
if ppath = ` which $candidate ` ; then
python_version = $( $ppath -V | awk '{ print $2 }' )
if [ $( version $python_version ) -ge $( version " $MINIMUM_PYTHON_VERSION " ) ] ; then
2023-07-25 05:21:56 +08:00
if [ $( version $python_version ) -le $( version " $MAXIMUM_PYTHON_VERSION " ) ] ; then
2023-02-17 01:52:07 +08:00
PYTHON = $ppath
break
fi
2023-02-04 10:42:00 +08:00
fi
fi
done
if [ -z " $PYTHON " ] ; then
echo "A suitable Python interpreter could not be found"
2023-06-16 21:18:23 +08:00
echo " Please install Python $MINIMUM_PYTHON_VERSION or higher (maximum $MAXIMUM_PYTHON_VERSION ) before running this script. See instructions at $INSTRUCTIONS for help. "
2023-06-09 04:37:10 +08:00
echo "For the best user experience we suggest enlarging or maximizing this window now."
2023-02-04 10:42:00 +08:00
read -p "Press any key to exit"
exit -1
fi
2023-02-08 05:35:22 +08:00
exec $PYTHON ./lib/main.py ${ @ }
2023-02-22 09:03:08 +08:00
read -p "Press any key to exit"