@@ -7,6 +7,13 @@ set -Eeou pipefail
7
7
source scripts/dev/set_env_context.sh
8
8
9
9
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
+
10
17
# Check if pyenv directory exists first
11
18
if [[ -d " ${HOME} /.pyenv" ]]; then
12
19
echo " pyenv directory already exists, setting up environment..." >&2
@@ -54,38 +61,22 @@ install_pyenv() {
54
61
}
55
62
56
63
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} "
60
65
61
- echo " Setting up Python ${required_version} ( ${major_minor} .x) ..." >&2
66
+ echo " Setting up Python ${required_version} ..." >&2
62
67
63
- # Always install pyenv first
64
68
if ! install_pyenv; then
65
69
echo " Error: Failed to install pyenv" >&2
66
70
return 1
67
71
fi
68
72
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
85
79
fi
86
-
87
- echo " Error: Unable to install Python ${major_minor} via pyenv" >&2
88
- return 1
89
80
}
90
81
91
82
if [[ -d " ${PROJECT_DIR} " /venv ]]; then
0 commit comments