]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Simplify bootstrap script
authorZack Cerza <zack@cerza.org>
Thu, 10 Apr 2025 19:22:24 +0000 (13:22 -0600)
committerZack Cerza <zack@cerza.org>
Fri, 7 Nov 2025 20:02:44 +0000 (13:02 -0700)
Much of this is simply removing things we don't have to be doing now that we're
using uv. It also consolidates the different sections for RPM-based distros.

Signed-off-by: Zack Cerza <zack@cerza.org>
bootstrap

index a401d72c65cedbc024b33c2b95e460cf4563aada..cd6638a0a18bf1f846fa54b2990f0bb84433bbe7 100755 (executable)
--- a/bootstrap
+++ b/bootstrap
@@ -1,74 +1,56 @@
 #!/bin/bash
 set -e
 if [ $# -eq 0 ]; then
-  install=false
+    install=false
 else
-  if [ "$1" = "install" ]; then
-      install=true
-  else
-      echo "Invalid command, supported commands are: 'install'"
-      exit 1
-  fi
-fi
-
-if [[ "$PYTHON" =~ "python2" ]]; then
-    echo "python2 is not supported." >&2
-    exit 1
-fi
-
-# Use the newest version we find
-if [ -z "$PYTHON" ]; then
-  for i in 12 11 10; do
-    command -v "python3.$i" > /dev/null && PYTHON="python3.$i" && break
-  done
-fi
-if [ -z "$PYTHON" ]; then
-  # This would be bizarre, but I suppose possible
-  PYTHON=${PYTHON:-"python3"}
+    if [ "$1" = "install" ]; then
+        install=true
+    else
+        echo "Invalid command, supported commands are: 'install'"
+        exit 1
+    fi
 fi
-echo "Using python: $PYTHON"
 
 case "$(uname -s)" in
 Linux)
-    if command -v lsb_release; then
+    if command -v lsb_release > /dev/null; then
         OS=$(lsb_release --id --short)
     else
         . /etc/os-release
         OS=$(echo $NAME | tr -d ' ')
     fi
-    # rpm/dnf is the default, to reduce repetition in the case statement
-    has_pkg="rpm -q --whatprovides"
-    install_pkg="sudo dnf install -y"
     case "$OS" in
     Ubuntu|Debian|LinuxMint)
-        deps=(qemu-utils python3-dev libssl-dev python3-pip python3-wheel python3-venv libev-dev libvirt-dev libffi-dev libyaml-dev build-essential jq curl)
-        has_pkg="dpkg -s"
+        deps=(qemu-utils python3-dev libssl-dev libev-dev libvirt-dev libffi-dev libyaml-dev pipx build-essential jq curl)
+        has_pkg="dpkg -C"
         install_pkg="sudo apt install -y"
         ;;
-    RedHatEnterpriseWorkstation|RedHatEnterpriseServer|RedHatEnterprise|CentOS)
-        deps=(python39-pip python39-devel mariadb-devel libev-devel libvirt-devel libffi-devel)
-        ;;
-    CentOSStream)
-        PYTHON=python3.12
-        deps=($PYTHON-pip $PYTHON-devel)
-        ;;
-    AlmaLinux|RockyLinux)
-        PYTHON=python3.12
-        deps=($PYTHON-pip $PYTHON-devel libev-devel libvirt-devel libffi-devel)
-        ;;
-    Fedora|FedoraLinux)
-        deps=($PYTHON-pip $PYTHON-devel libev-devel libvirt-devel libffi-devel)
+    RedHatEnterpriseWorkstation|RedHatEnterpriseServer|RedHatEnterprise|CentOS|CentOSStream|AlmaLinux|RockyLinux|Fedora|FedoraLinux)
+        # Use the newest version we find
+        if [ -z "$PYTHON" ]; then
+            for i in 13 12 11 10; do
+                command -v "python3.$i" > /dev/null && PYTHON="python3.$i" && break
+            done
+        fi
+        if [ -z "$PYTHON" ]; then
+            # This would be bizarre, but I suppose possible
+            PYTHON=${PYTHON:-"python3"}
+        fi
+        # rpm/dnf is the default, to reduce repetition in the case statement
+        has_pkg="rpm -q --whatprovides"
+        install_pkg="sudo dnf install -y"
+        deps=(libev-devel libffi-devel libvirt-devel $PYTHON-devel pipx)
         ;;
     "openSUSE project"|"SUSE LINUX"|"openSUSE"|"openSUSELeap"|"openSUSETumbleweed")
-        PYTHON=python3.12
-        deps=(python312-pip python312-devel python312 libev-devel libvirt-devel libffi-devel)
+        deps=(python python-devel libev-devel libffi-devel libvirt-devel python-pipx)
+        has_pkg="rpm --whatprovides"
         install_pkg="sudo zypper install"
         ;;
     esac
     ;;
 
 Darwin)
-    deps="python libvirt libev libffi"
+    deps="python libvirt libev libffi pipx uv"
     has_pkg="brew list"
     install_pkg="brew install"
     ;;
@@ -91,60 +73,19 @@ if [ -n "$missing" ]; then
         echo "$install_pkg $missing"
         exit 1
     fi
-    fi
-
-PYTHON_BIN=$(command -v $PYTHON)
-if [ -z $PYTHON_BIN -o ! -e $PYTHON_BIN -o ! -x $PYTHON_BIN ]; then
-  echo "Cannot find $PYTHON!"
-  exit 1
-fi
-PYTHON_VER_OUT=$($PYTHON_BIN --version)
-
-VENV=${VENV:-"./virtualenv"}
-# If the venv was set to use system site-packages, fix that
-if [ -f "$VENV/pyvenv.cfg" ]; then
-    sed -i'' -e 's/\(include-system-site-packages\s*=\s*\)true/\1false/g' $VENV/pyvenv.cfg
 fi
 
 # Attempt to force a UTF-8 locale without being specific to English
 export LANG=${LANG:-C.UTF-8}
 (echo $LANG | grep -qi utf-8) || export LC_ALL=$LANG.UTF-8
 
-# If the venv but exists but has the wrong python version, recreate it
-if [ -z "$NO_CLOBBER" ] && \
-  [ ! -e "${VENV}/bin/${PYTHON}" ] || \
-  [ "${PYTHON_VER_OUT}" != "$(${VENV}/bin/${PYTHON} --version)" ]; then
-    rm -rf virtualenv
-fi
-
-# if we do not have uv, make venv, then use pip to install it
+[ -z "$NO_CLOBBER" ] && rm -rf virtualenv
 if ! UV=$(command -v uv); then
-    $PYTHON_BIN -m venv $VENV
-    $VENV/bin/python3 -m pip install uv
-    UV=$VENV/bin/uv
-fi
-UV_PROJECT_ENVIRONMENT=$VENV
-if [ ! -e $VENV ]; then
-    uv venv $VENV
+    pipx install uv
 fi
-# Use uv for pip operations
-PIP="${UV} pip"
-
-if [ -f "$VENV/bin/ansible" ]; then
-    uninstall_ansible=$($VENV/bin/python3 -c "import ansible; from packaging.version import parse; print(parse(ansible.__version__) < parse('2.10.0'))")
-    if [ "$uninstall_ansible" = "True" ]; then
-        $PIP uninstall -y ansible
-    fi
-fi
-
-$PIP install -r requirements.txt
-# By default, install teuthology in editable mode
-$PIP install --python $VENV/bin/python ${PIP_INSTALL_FLAGS:---editable '.[test]'}
-
-# Check to make sure requirements are met
-$PIP check
+command -v uv > /dev/null || pipx ensurepath
+PATH=$PATH:$HOME/.local/bin
+uv sync --frozen --all-extras
 
 # Install ansible collections
-$VENV/bin/ansible-galaxy install -r requirements.yml
-
-echo "Bootstrap completed successfully!!!"
+uv run ansible-galaxy install -r requirements.yml