Skip to content

Commit 2a11bd7

Browse files
committed
always force a reinstall as pyenv versions are getting removed everytime
1 parent c8fa487 commit 2a11bd7

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

scripts/dev/recreate_python_venv.sh

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ set -Eeou pipefail
77
source scripts/dev/set_env_context.sh
88

99
install_pyenv() {
10+
# Install python3-venv package for Debian/Ubuntu systems if needed
11+
if command -v apt-get &> /dev/null; then
12+
echo "Installing python3-venv package for venv support..." >&2
13+
sudo apt-get update -qq || true
14+
sudo apt-get install -y python3-venv || true
15+
fi
16+
1017
# Check if pyenv directory exists first
1118
if [[ -d "${HOME}/.pyenv" ]]; then
1219
echo "pyenv directory already exists, setting up environment..." >&2
@@ -54,38 +61,22 @@ install_pyenv() {
5461
}
5562

5663
ensure_required_python() {
57-
local required_version="${PYTHON_VERSION:-3.13}"
58-
local major_minor
59-
major_minor=$(echo "${required_version}" | grep -oE '^[0-9]+\.[0-9]+')
64+
local required_version="${PYTHON_VERSION:-3.13.7}"
6065

61-
echo "Setting up Python ${required_version} (${major_minor}.x)..." >&2
66+
echo "Setting up Python ${required_version}..." >&2
6267

63-
# Always install pyenv first
6468
if ! install_pyenv; then
6569
echo "Error: Failed to install pyenv" >&2
6670
return 1
6771
fi
6872

69-
# Install latest version in the required series
70-
local latest_version
71-
latest_version=$(pyenv install --list | grep -E "^[[:space:]]*${major_minor}\.[0-9]+$" | tail -1 | xargs)
72-
if [[ -n "${latest_version}" ]]; then
73-
echo "Installing Python ${latest_version} via pyenv..." >&2
74-
# Use --skip-existing to avoid errors if version already exists
75-
if pyenv install --skip-existing "${latest_version}"; then
76-
pyenv global "${latest_version}"
77-
# Install python3-venv package for Debian/Ubuntu systems if needed
78-
if command -v apt-get &> /dev/null; then
79-
echo "Installing python3-venv package for venv support..." >&2
80-
sudo apt-get update -qq || true
81-
sudo apt-get install -y python3-venv || true
82-
fi
83-
return 0
84-
fi
73+
# Install specific pinned version for consistency across runs
74+
echo "Installing Python ${required_version} via pyenv..." >&2
75+
# Use --skip-existing to avoid errors if version already exists
76+
if pyenv install --skip-existing "${required_version}"; then
77+
pyenv global "${required_version}"
78+
return 0
8579
fi
86-
87-
echo "Error: Unable to install Python ${major_minor} via pyenv" >&2
88-
return 1
8980
}
9081

9182
if [[ -d "${PROJECT_DIR}"/venv ]]; then

scripts/evergreen/setup_aws.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,19 @@ install_aws_cli_pip() {
4848
return 1
4949
fi
5050

51+
# Check if AWS CLI exists and works before installing
52+
if command -v aws &> /dev/null; then
53+
if aws --version > /dev/null 2>&1; then
54+
echo "AWS CLI is already installed and working"
55+
return 0
56+
else
57+
echo "AWS CLI exists but not functional (likely bad Python shebang), reinstalling..."
58+
pip3 uninstall -y awscli || true
59+
fi
60+
fi
61+
5162
echo "Installing AWS CLI using pip3..."
52-
pip3 install --user --force-reinstall awscli
63+
pip3 install --user awscli
5364

5465
# Add ~/.local/bin to PATH if not already there (where pip --user installs)
5566
if [[ ":${PATH}:" != *":${HOME}/.local/bin:"* ]]; then

0 commit comments

Comments
 (0)