From 0b94911ecda4bcfa3921794a182d587159fbc7a7 Mon Sep 17 00:00:00 2001 From: Graham Herceg Date: Thu, 11 Apr 2024 21:37:39 -0400 Subject: [PATCH 1/2] Remove code for installing Python 3.10 on 18.04 The system version of python was 3.6 on 18.04, and is 3.10 on 22.04. Now that we have fully transitioned to 22.04 (for control machines at least), we can safely remove the code related to installing and setting up 3.10 virtual environments on 18.04. --- control/activate_venv.sh | 17 ------------- control/init.sh | 25 +++---------------- .../1-commcare-cloud/1-installation.rst | 5 +--- quick_monolith_install/cchq-install.sh | 6 ----- 4 files changed, 4 insertions(+), 49 deletions(-) diff --git a/control/activate_venv.sh b/control/activate_venv.sh index 6db19e4a01..01a8f3be41 100644 --- a/control/activate_venv.sh +++ b/control/activate_venv.sh @@ -1,7 +1,6 @@ #! /bin/bash CCHQ_VIRTUALENV=${CCHQ_VIRTUALENV:-cchq} VENV=~/.virtualenvs/$CCHQ_VIRTUALENV -BIONIC_USE_SYSTEM_PYTHON=${BIONIC_USE_SYSTEM_PYTHON:-false} fail_on_error='false' # if true, prints error message and returns exit code 1 while test $# -gt 0; do @@ -16,22 +15,6 @@ while test $# -gt 0; do esac done -if [ "$BIONIC_USE_SYSTEM_PYTHON" == "true" ]; then - echo "The variable BIONIC_USE_SYSTEM_PYTHON is set in your environment." - echo "This variable should only be used temporarily when it is absolutely necessary to use Python 3.6 on 18.04." - echo "Please remove this variable from your environment when you are able to use Python 3.10 again." -fi - -# if on 18.04 with 3.10 installed, use cchq-3.10 unless $BIONIC_USE_SYSTEM_PYTHON is true -if [ "$BIONIC_USE_SYSTEM_PYTHON" == "false" ] && hash python3.10 2>/dev/null && [ $( source /etc/os-release; echo "$VERSION_ID" ) == "18.04" ]; then - # only append 3.10 if it is not already in the name - if [[ "$CCHQ_VIRTUALENV" != *"3.10"* ]]; then - # save for reference by callers - CCHQ_VENV_PATH_OLD="$VENV" - CCHQ_VIRTUALENV=$CCHQ_VIRTUALENV-3.10 - fi - VENV=~/.virtualenvs/$CCHQ_VIRTUALENV -fi # activate virtualenv if it exists, otherwise exit with error if [ -f "$VENV/bin/activate" ]; then diff --git a/control/init.sh b/control/init.sh index 00810f42e6..05afb5fae8 100755 --- a/control/init.sh +++ b/control/init.sh @@ -2,7 +2,6 @@ CCHQ_VIRTUALENV=${CCHQ_VIRTUALENV:-cchq} VENV=~/.virtualenvs/$CCHQ_VIRTUALENV NO_INPUT=0 -BIONIC_USE_SYSTEM_PYTHON=${BIONIC_USE_SYSTEM_PYTHON:-false} if [[ $_ == $0 ]] then @@ -40,32 +39,14 @@ if [ -z ${CI_TEST} ]; then if [ "$VIRTUALENV_NOT_FOUND" == "true" ]; then # check if a virtualenv at $VENV exists yet, and create if not if [[ ! -f $VENV/bin/activate ]]; then - if [[ $BIONIC_USE_SYSTEM_PYTHON == false ]] && hash python3.10 2>/dev/null; then - echo "Creating a python3.10 virtual environment named ${CCHQ_VIRTUALENV}" - if [ -n "$CCHQ_VENV_PATH_OLD" ]; then - echo "Your old virtual environment will remain at ${CCHQ_VENV_PATH_OLD}" - echo "If you wish to delete it, run 'rm -rf ${CCHQ_VENV_PATH_OLD}'" - fi - # use venv because 3.10 setup includes installing python3.10-venv - python3.10 -m venv "$VENV" - else - # use virtualenv because `python3 -m venv` requires python3-venv - python3 -m pip install --user --upgrade virtualenv - python3 -m virtualenv "$VENV" - fi + # use virtualenv because `python3 -m venv` requires python3-venv + python3 -m pip install --user --upgrade virtualenv + python3 -m virtualenv "$VENV" fi source "$VENV/bin/activate" fi fi -# check for unsupported python version after virtual env is activated -python_version=`python --version 2>&1 | awk '{print $2}'` -if [[ $python_version = 3.6* ]]; then - echo "commcare-cloud no longer supports Python 3.6." - echo "To upgrade, follow the instructions in:" - echo " https://commcare-cloud.readthedocs.io/en/latest/installation/2-manual-install.html#upgrade-to-python-3-10" -fi - if [ -d ~/commcarehq-ansible ]; then echo "Moving repo to ~/commcare-cloud" mv ~/commcarehq-ansible ~/commcare-cloud diff --git a/docs/source/reference/1-commcare-cloud/1-installation.rst b/docs/source/reference/1-commcare-cloud/1-installation.rst index 21bca61ef9..117119aa0d 100644 --- a/docs/source/reference/1-commcare-cloud/1-installation.rst +++ b/docs/source/reference/1-commcare-cloud/1-installation.rst @@ -117,10 +117,7 @@ If you get to this point, congratulations! ``commcare-cloud`` is installed. Manual Installation ------------------- -You will need python 3.10 installed to follow these instructions. See -:ref:`installation/2-manual-install:Upgrade to Python 3.10` for instructions on -getting it installed on Ubuntu 22.04. Steps for other operating systems may -differ. +You will need python 3.10 installed to follow these instructions. Setup diff --git a/quick_monolith_install/cchq-install.sh b/quick_monolith_install/cchq-install.sh index 7683556b5e..cbab57e575 100755 --- a/quick_monolith_install/cchq-install.sh +++ b/quick_monolith_install/cchq-install.sh @@ -40,12 +40,6 @@ sudo apt --assume-yes -qq update sudo apt --assume-yes -qq install python3-pip sshpass sudo -H pip3 -q install --upgrade pip sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10 -# install python 3.10 if on ubuntu 18.04 and not installed yet -if ! hash python3.10 2>/dev/null && [[ $( source /etc/os-release; echo $VERSION_ID ) == 18.04 ]]; then - sudo add-apt-repository -y ppa:deadsnakes/ppa - sudo apt update - sudo apt-get --assume-yes -q install python3.10 python3.10-dev python3.10-distutils python3.10-venv libffi-dev -fi printf "\n" printf "#################################################" From 1b38a0420ac11471d318908e3a7bfd1ab157ebd5 Mon Sep 17 00:00:00 2001 From: Graham Herceg Date: Thu, 11 Apr 2024 21:40:09 -0400 Subject: [PATCH 2/2] Update test container to use Ubuntu 22.04 --- tests/cloud/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cloud/Dockerfile b/tests/cloud/Dockerfile index 89dbfbae4b..67f8c4c9c1 100644 --- a/tests/cloud/Dockerfile +++ b/tests/cloud/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:22.04 RUN apt update && \ apt upgrade -y && \ apt install sudo -y && \