Skip to content

Commit

Permalink
Make determine_python() pin to 3.9 (#19116)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjyw authored May 23, 2023
1 parent a84f53b commit 2307d75
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions build-support/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,17 @@ function determine_python() {
which "${PY}" && return 0
fi

local candidate_versions
if is_macos_arm; then
candidate_versions=('3.9')
else
candidate_versions=('3.7' '3.8' '3.9')
version='3.9'
interpreter_path="$(command -v "python${version}")"
if [[ -z "${interpreter_path}" ]]; then
echo "pants: Failed to find a Python ${version} interpreter" && return 1
fi

for version in "${candidate_versions[@]}"; do
local interpreter_path
interpreter_path="$(command -v "python${version}")"
if [[ -z "${interpreter_path}" ]]; then
continue
fi
# Check if the Python version is installed via Pyenv but not activated.
if [[ "$("${interpreter_path}" --version 2>&1 > /dev/null)" == "pyenv: python${version}"* ]]; then
continue
fi
echo "${interpreter_path}" && return 0
done
echo "pants: failed to find suitable Python interpreter, looking for: ${candidate_versions[*]}" >&2
return 1
# Check if the Python version is installed via Pyenv but not activated.
if [[ "$("${interpreter_path}" --version 2>&1 > /dev/null)" == "pyenv: python${version}"* ]]; then
echo "pants: The Python ${version} interpreter at ${interpreter_path} is an inactive pyenv interpreter" && return 1
fi
echo "${interpreter_path}"
return 0
}

function is_macos_arm() {
Expand Down

0 comments on commit 2307d75

Please sign in to comment.