From c8fa487f9fde1548d82322f0f209d7eaded2a6db Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Mon, 1 Sep 2025 13:02:30 +0200 Subject: [PATCH 1/4] always force a reinstall as pyenv versions are getting removed everytime --- scripts/evergreen/setup_aws.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/evergreen/setup_aws.sh b/scripts/evergreen/setup_aws.sh index 52c611d39..5ab1feea8 100755 --- a/scripts/evergreen/setup_aws.sh +++ b/scripts/evergreen/setup_aws.sh @@ -48,14 +48,8 @@ install_aws_cli_pip() { return 1 fi - # Check if AWS CLI exists and works before installing - if command -v aws &> /dev/null && aws --version &> /dev/null 2>&1; then - echo "AWS CLI is already installed and working" - return 0 - fi - echo "Installing AWS CLI using pip3..." - pip3 install --user awscli + pip3 install --user --force-reinstall awscli # Add ~/.local/bin to PATH if not already there (where pip --user installs) if [[ ":${PATH}:" != *":${HOME}/.local/bin:"* ]]; then From 2a11bd708d7966a278324290e2318ace86102396 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Mon, 1 Sep 2025 13:08:16 +0200 Subject: [PATCH 2/4] always force a reinstall as pyenv versions are getting removed everytime --- scripts/dev/recreate_python_venv.sh | 39 +++++++++++------------------ scripts/evergreen/setup_aws.sh | 13 +++++++++- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/scripts/dev/recreate_python_venv.sh b/scripts/dev/recreate_python_venv.sh index c2b94a8d9..3069f14c8 100755 --- a/scripts/dev/recreate_python_venv.sh +++ b/scripts/dev/recreate_python_venv.sh @@ -7,6 +7,13 @@ set -Eeou pipefail source scripts/dev/set_env_context.sh install_pyenv() { + # Install python3-venv package for Debian/Ubuntu systems if needed + if command -v apt-get &> /dev/null; then + echo "Installing python3-venv package for venv support..." >&2 + sudo apt-get update -qq || true + sudo apt-get install -y python3-venv || true + fi + # Check if pyenv directory exists first if [[ -d "${HOME}/.pyenv" ]]; then echo "pyenv directory already exists, setting up environment..." >&2 @@ -54,38 +61,22 @@ install_pyenv() { } ensure_required_python() { - local required_version="${PYTHON_VERSION:-3.13}" - local major_minor - major_minor=$(echo "${required_version}" | grep -oE '^[0-9]+\.[0-9]+') + local required_version="${PYTHON_VERSION:-3.13.7}" - echo "Setting up Python ${required_version} (${major_minor}.x)..." >&2 + echo "Setting up Python ${required_version}..." >&2 - # Always install pyenv first if ! install_pyenv; then echo "Error: Failed to install pyenv" >&2 return 1 fi - # Install latest version in the required series - local latest_version - latest_version=$(pyenv install --list | grep -E "^[[:space:]]*${major_minor}\.[0-9]+$" | tail -1 | xargs) - if [[ -n "${latest_version}" ]]; then - echo "Installing Python ${latest_version} via pyenv..." >&2 - # Use --skip-existing to avoid errors if version already exists - if pyenv install --skip-existing "${latest_version}"; then - pyenv global "${latest_version}" - # Install python3-venv package for Debian/Ubuntu systems if needed - if command -v apt-get &> /dev/null; then - echo "Installing python3-venv package for venv support..." >&2 - sudo apt-get update -qq || true - sudo apt-get install -y python3-venv || true - fi - return 0 - fi + # Install specific pinned version for consistency across runs + echo "Installing Python ${required_version} via pyenv..." >&2 + # Use --skip-existing to avoid errors if version already exists + if pyenv install --skip-existing "${required_version}"; then + pyenv global "${required_version}" + return 0 fi - - echo "Error: Unable to install Python ${major_minor} via pyenv" >&2 - return 1 } if [[ -d "${PROJECT_DIR}"/venv ]]; then diff --git a/scripts/evergreen/setup_aws.sh b/scripts/evergreen/setup_aws.sh index 5ab1feea8..95b824d0b 100755 --- a/scripts/evergreen/setup_aws.sh +++ b/scripts/evergreen/setup_aws.sh @@ -48,8 +48,19 @@ install_aws_cli_pip() { return 1 fi + # Check if AWS CLI exists and works before installing + if command -v aws &> /dev/null; then + if aws --version > /dev/null 2>&1; then + echo "AWS CLI is already installed and working" + return 0 + else + echo "AWS CLI exists but not functional (likely bad Python shebang), reinstalling..." + pip3 uninstall -y awscli || true + fi + fi + echo "Installing AWS CLI using pip3..." - pip3 install --user --force-reinstall awscli + pip3 install --user awscli # Add ~/.local/bin to PATH if not already there (where pip --user installs) if [[ ":${PATH}:" != *":${HOME}/.local/bin:"* ]]; then From 4c3c21e84bd04ee4e915a2e10a34e833e8cde0cd Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Mon, 1 Sep 2025 13:10:41 +0200 Subject: [PATCH 3/4] always force a reinstall as pyenv versions are getting removed everytime --- scripts/evergreen/setup_aws.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/scripts/evergreen/setup_aws.sh b/scripts/evergreen/setup_aws.sh index 95b824d0b..5f947fcb5 100755 --- a/scripts/evergreen/setup_aws.sh +++ b/scripts/evergreen/setup_aws.sh @@ -42,35 +42,31 @@ install_aws_cli_binary() { install_aws_cli_pip() { echo "Installing AWS CLI v1 via pip (for IBM architectures)..." - # Ensure pip is available - if ! command -v pip3 &> /dev/null && ! command -v pip &> /dev/null; then - echo "Error: pip is not available. Please install Python and pip first." >&2 + if [[ ! -d "${PROJECT_DIR}/venv" ]]; then + echo "Error: Python venv not found at ${PROJECT_DIR}/venv. Please run recreate_python_venv.sh first." >&2 return 1 fi - # Check if AWS CLI exists and works before installing + # Activate the venv + source "${PROJECT_DIR}/venv/bin/activate" + + # Check if AWS CLI exists and works in the venv if command -v aws &> /dev/null; then if aws --version > /dev/null 2>&1; then - echo "AWS CLI is already installed and working" + echo "AWS CLI is already installed and working in venv" return 0 else - echo "AWS CLI exists but not functional (likely bad Python shebang), reinstalling..." - pip3 uninstall -y awscli || true + echo "AWS CLI exists but not functional, reinstalling in venv..." + pip uninstall -y awscli || true fi fi - echo "Installing AWS CLI using pip3..." - pip3 install --user awscli - - # Add ~/.local/bin to PATH if not already there (where pip --user installs) - if [[ ":${PATH}:" != *":${HOME}/.local/bin:"* ]]; then - export PATH="${HOME}/.local/bin:${PATH}" - echo "Added ~/.local/bin to PATH" - fi + echo "Installing AWS CLI into venv using pip..." + pip install awscli # Verify installation if command -v aws &> /dev/null; then - echo "AWS CLI v1 installed successfully" + echo "AWS CLI v1 installed successfully in venv" else echo "Error: AWS CLI v1 installation failed" >&2 return 1 From 4ab39cef61f137294e7e49266dad7612421197f9 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Mon, 1 Sep 2025 13:11:50 +0200 Subject: [PATCH 4/4] always force a reinstall as pyenv versions are getting removed everytime --- scripts/dev/configure_container_auth.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/dev/configure_container_auth.sh b/scripts/dev/configure_container_auth.sh index fa20539b0..1afd8429d 100755 --- a/scripts/dev/configure_container_auth.sh +++ b/scripts/dev/configure_container_auth.sh @@ -8,6 +8,11 @@ source scripts/funcs/checks source scripts/funcs/printing source scripts/funcs/kubernetes +# Activate venv if it exists (needed for AWS CLI on IBM architectures) +if [[ -f "${PROJECT_DIR}/venv/bin/activate" ]]; then + source "${PROJECT_DIR}/venv/bin/activate" +fi + CONTAINER_RUNTIME="${CONTAINER_RUNTIME-"docker"}" setup_validate_container_runtime() {