@@ -18,7 +18,31 @@ if [[ "${EUID}" -ne 0 ]]; then
1818fi
1919
2020if ! command -v " ${PYTHON_BIN} " > /dev/null 2>&1 ; then
21- echo " Missing ${PYTHON_BIN} . Install python3 and python3-venv, then run this script again." >&2
21+ echo " Missing ${PYTHON_BIN} . Install Python 3.11+ and the matching venv package, then run this script again." >&2
22+ exit 1
23+ fi
24+
25+ PYTHON_VERSION=" $( " ${PYTHON_BIN} " - << 'PY '
26+ import sys
27+ print(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
28+ PY
29+ ) "
30+
31+ if ! " ${PYTHON_BIN} " - << 'PY '
32+ import sys
33+ raise SystemExit(0 if sys.version_info >= (3, 11) else 1)
34+ PY
35+ then
36+ cat >&2 << EOF
37+ ${PYTHON_BIN} is Python ${PYTHON_VERSION} , but APRS PropView requires Python 3.11 or newer.
38+
39+ Raspberry Pi OS / Debian 11 (bullseye) commonly provides Python 3.9 as
40+ python3. Install a newer Python and rerun this installer with:
41+
42+ sudo PYTHON_BIN=/path/to/python3.11 bash ./scripts/install_linux.sh
43+
44+ Or upgrade to an OS release that provides Python 3.11+.
45+ EOF
2246 exit 1
2347fi
2448
7599
76100chown -R " ${RUN_USER} :${RUN_USER} " " ${INSTALL_DIR} "
77101
102+ if [[ -x " ${INSTALL_DIR} /.venv/bin/python" ]]; then
103+ VENV_VERSION=" $( " ${INSTALL_DIR} /.venv/bin/python" - << 'PY '
104+ import sys
105+ print(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
106+ PY
107+ ) "
108+ if ! " ${INSTALL_DIR} /.venv/bin/python" - << 'PY '
109+ import sys
110+ raise SystemExit(0 if sys.version_info >= (3, 11) else 1)
111+ PY
112+ then
113+ echo " Existing virtualenv uses Python ${VENV_VERSION} ; recreating it with ${PYTHON_BIN} ."
114+ rm -rf " ${INSTALL_DIR} /.venv"
115+ fi
116+ fi
117+
78118sudo -u " ${RUN_USER} " " ${PYTHON_BIN} " -m venv " ${INSTALL_DIR} /.venv"
79119sudo -u " ${RUN_USER} " " ${INSTALL_DIR} /.venv/bin/python" -m pip install --upgrade pip
80120sudo -u " ${RUN_USER} " " ${INSTALL_DIR} /.venv/bin/python" -m pip install -r " ${INSTALL_DIR} /requirements.txt"
0 commit comments