Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions scripts/dev/configure_container_auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
39 changes: 15 additions & 24 deletions scripts/dev/recreate_python_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
33 changes: 17 additions & 16 deletions scripts/evergreen/setup_aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +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
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
# Activate the venv
source "${PROJECT_DIR}/venv/bin/activate"

# 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"
# 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 in venv"
return 0
else
echo "AWS CLI exists but not functional, reinstalling in venv..."
pip uninstall -y awscli || true
fi
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
Expand Down
Loading