Skip to content

Commit

Permalink
feat(devenv): Leniant Python version check
Browse files Browse the repository at this point in the history
In #28213 we removed the leniant Python version check and it hit few engineers.
This adds it back and better wording for Python 3.8 version check.
  • Loading branch information
armenzg committed Sep 2, 2021
1 parent 5f91cfc commit a082d17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 4 additions & 3 deletions scripts/ensure-venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ EOF

if ! query-valid-python-version; then
cat <<EOF
${yellow}${bold}
${red}${bold}
WARNING! You are running a virtualenv with a Python version ($(which python))
different than 3.6.13 or 3.8.11. We recommend you start with a fresh virtualenv OR"
use SENTRY_PYTHON_VERSION to by-pass this check.
different than 3.6 (or at least 3.8.10 on M1 Macs). Either run "rm -rf ${venv_name} && direnv allow"
OR use SENTRY_PYTHON_VERSION to by-pass this check."
${reset}
EOF
exit 1
fi
else
if [[ ! -f "${venv_name}/bin/activate" ]]; then
Expand Down
15 changes: 12 additions & 3 deletions scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Module containing code shared across various shell scripts
# Execute functions from this module via the script do.sh
# shellcheck disable=SC2034 # Unused variables
# shellcheck disable=SC2001 # https://github.com/koalaman/shellcheck/wiki/SC2001

# This block is a safe-guard since in CI calling tput will fail and abort scripts
if [ -z "${CI+x}" ]; then
Expand Down Expand Up @@ -55,11 +56,19 @@ get-pyenv-version() {

query-valid-python-version() {
python_version=$(python3 -V 2>&1 | awk '{print $2}')
if [ "${python_version}" == 3.6.13 ] || [ "${python_version}" == 3.8.11 ]; then
return 0
else
minor=$(echo "${python_version}" | sed 's/[0-9]*\.\([0-9]*\)\.\([0-9]*\)/\1/')
patch=$(echo "${python_version}" | sed 's/[0-9]*\.\([0-9]*\)\.\([0-9]*\)/\2/')

# For Apple M1, we only allow 3.8 and at least patch version 10
if query-apple-m1; then
if [ "$minor" -ne 8 ] || [ "$patch" -lt 10 ]; then
return 1
fi
# For everything else, we only allow 3.6
elif [ "$minor" -ne 8 ]; then
return 1
fi
return 0
}

sudo-askpass() {
Expand Down

0 comments on commit a082d17

Please sign in to comment.