Skip to content

Commit

Permalink
Merge pull request #101 from OpenVoiceOS/fix/python_version
Browse files Browse the repository at this point in the history
Support all Python versions
  • Loading branch information
goldyfruit authored Jun 26, 2024
2 parents 18e50ac + 8b69ef2 commit 83511e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
32 changes: 8 additions & 24 deletions utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ function get_os_information() {
# the installer will exit with a message.
function required_packages() {
echo -ne "➤ Validating installer package requirements... "
PYTHON_VERSION="$MAX_PYTHON_VERSION"

# Add extra packages if a Raspberry Pi board is detected
declare extra_packages
if [ "$RASPBERRYPI_MODEL" != "N/A" ]; then
Expand All @@ -209,34 +207,19 @@ function required_packages() {

case "$DISTRO_NAME" in
debian | ubuntu | raspbian | linuxmint | zorin)
[ "$DISTRO_VERSION_ID" == "11" ] && export PYTHON_VERSION="3"
# This is a temporary fix until OVOS is confirmed to work with
# Python 3.12. Requirements are PocketSphinx, tflite-runtime and
# onnxruntime Python packages.
if [ "$(ver "$DISTRO_VERSION_ID")" -ge "$(ver 24.04)" ]; then
{
apt-get update
apt-get install --no-install-recommends -y software-properties-common
add-apt-repository ppa:deadsnakes/ppa -y
} &>>"$LOG_FILE"
fi
apt-get update &>>"$LOG_FILE"
apt-get install --no-install-recommends -y "python${PYTHON_VERSION}" "python${PYTHON_VERSION}-dev" python3-pip "python${PYTHON_VERSION}-venv" whiptail expect jq "${extra_packages[@]}" &>>"$LOG_FILE"
apt-get install --no-install-recommends -y python3 python3-dev python3-pip python3-venv whiptail expect jq "${extra_packages[@]}" &>>"$LOG_FILE"
;;
fedora)
export PYTHON_VERSION
dnf install -y python3.11 python3.11-devel python3-pip python3-virtualenv newt expect jq "${extra_packages[@]}" &>>"$LOG_FILE"
dnf install -y python3 python3-devel python3-pip python3-virtualenv newt expect jq "${extra_packages[@]}" &>>"$LOG_FILE"
;;
rocky | centos)
export PYTHON_VERSION
dnf install -y python3.11 python3.11-devel python3-pip newt expect jq "${extra_packages[@]}" &>>"$LOG_FILE"
dnf install -y python3 python3-devel python3-pip newt expect jq "${extra_packages[@]}" &>>"$LOG_FILE"
;;
opensuse-tumbleweed | opensuse-leap)
export PYTHON_VERSION
zypper install -y python311 python311-devel python3-pip python3-rpm newt expect jq "${extra_packages[@]}" &>>"$LOG_FILE"
zypper install --no-recommends -y python3 python3-devel python3-pip python3-rpm newt expect jq "${extra_packages[@]}" &>>"$LOG_FILE"
;;
arch | manjaro | endeavouros)
export PYTHON_VERSION
pacman -Sy --noconfirm python python-pip python-virtualenv libnewt expect jq "${extra_packages[@]}" &>>"$LOG_FILE"
;;
*)
Expand All @@ -261,15 +244,16 @@ function create_python_venv() {
fi
fi

if [ ! -d "$VENV_PATH" ]; then
"python${PYTHON_VERSION}" -m venv "$VENV_PATH" &>>"$LOG_FILE"
if [ -d "$VENV_PATH" ]; then
rm -rf "$VENV_PATH" &>>"$LOG_FILE"
fi
python3 -m venv "$VENV_PATH" &>>"$LOG_FILE"

# shellcheck source=/dev/null
source "$VENV_PATH/bin/activate"

pip3 install --upgrade pip setuptools &>>"$LOG_FILE"
chown "$RUN_AS":"$(id -ng "$RUN_AS")" "$VENV_PATH"
chown "$RUN_AS":"$(id -ng "$RUN_AS")" "$VENV_PATH" &>>"$LOG_FILE"
echo -e "[$done_format]"
}

Expand Down
1 change: 0 additions & 1 deletion utils/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export DT_FILE=/sys/firmware/devicetree/base/model
export I2C_BUS="1"
export INSTALLER_VENV_NAME="ovos-installer"
export LOG_FILE=/var/log/ovos-installer.log
export MAX_PYTHON_VERSION="3.11"
export NEWT_COLORS="
root=white,black
border=black,lightgray
Expand Down

0 comments on commit 83511e5

Please sign in to comment.