From bdd908298571c6e315447cccfca91c269c3c2ba4 Mon Sep 17 00:00:00 2001 From: Marcelo Jorge Vieira Date: Wed, 24 Apr 2024 12:04:06 -0300 Subject: [PATCH] Added python 3.12 support (#125) Co-authored-by: Paulo Sousa --- python/deploy | 5 +++-- tests/python/tests.bats | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/python/deploy b/python/deploy index ac1169b..61fb6f3 100755 --- a/python/deploy +++ b/python/deploy @@ -12,6 +12,7 @@ PYTHON_REPO=${PYTHON_REPO:-https://heroku-buildpack-python.s3.amazonaws.com/hero GET_PIP_URL=${GET_PIP_URL:-https://bootstrap.pypa.io/get-pip.py} GET_PIP_VERSION_URL=${GET_PIP_VERSION_URL:-https://bootstrap.pypa.io/pip/@VERSION@/get-pip.py} +LATEST_312="3.12.0" LATEST_311="3.11.3" LATEST_310="3.10.11" LATEST_39="3.9.16" @@ -21,8 +22,8 @@ LATEST_36="3.6.15" LATEST_35="3.5.10" PYPY_36="pypy3.6-7.3.2" PYPY_27="pypy2.7-7.3.2" -LATEST_PYTHON_VERSIONS=(${LATEST_311} ${LATEST_310} ${LATEST_39} ${LATEST_38} ${LATEST_37} ${LATEST_36} ${LATEST_35} ${PYPY_36} ${PYPY_27}) -PYTHON_VERSION_DEFAULT="${PYTHON_VERSION_DEFAULT:-${LATEST_311}}" +LATEST_PYTHON_VERSIONS=(${LATEST_312} ${LATEST_311} ${LATEST_310} ${LATEST_39} ${LATEST_38} ${LATEST_37} ${LATEST_36} ${LATEST_35} ${PYPY_36} ${PYPY_27}) +PYTHON_VERSION_DEFAULT="${PYTHON_VERSION_DEFAULT:-${LATEST_312}}" VERSION_ORIGIN="default" PYTHON_BASE_DIR="/home/application/python" INSTALLED_PYTHON_FILE="${PYTHON_BASE_DIR}/.installed-version" diff --git a/tests/python/tests.bats b/tests/python/tests.bats index deca615..be1e5cc 100644 --- a/tests/python/tests.bats +++ b/tests/python/tests.bats @@ -15,7 +15,21 @@ setup() { load 'bats-support-master/load' load 'bats-assert-master/load' +@test "use python version 3.12.0 as default" { + run /var/lib/tsuru/deploy + [[ "$output" == *"Using python version: 3.12.0"* ]] + assert_success + + run python --version + assert_success + [[ "$output" == *"3.12.0"* ]] + + run pip freeze + assert_success +} + @test "use python version 3.11 as default" { + export PYTHON_VERSION_DEFAULT=3.11.3 run /var/lib/tsuru/deploy [[ "$output" == *"Using python version: 3.11.3"* ]] assert_success @@ -87,6 +101,7 @@ load 'bats-assert-master/load' } @test "use python version 3.11 as default with invalid .python-version" { + export PYTHON_VERSION=3.11.3 echo "xyz" > ${CURRENT_DIR}/.python-version run /var/lib/tsuru/deploy assert_success @@ -164,6 +179,8 @@ EOF } @test "install from Pipfile.lock with custom pipenv" { + export PYTHON_REPO=${PYTHON_REPO:-https://heroku-buildpack-python.s3.amazonaws.com/heroku-18/runtimes} + export PYTHON_VERSION=2.7.18 export PYTHON_PIPENV_VERSION=2021.5.29 cp Pipfile Pipfile.lock ${CURRENT_DIR}/ @@ -180,6 +197,7 @@ EOF } @test "change python version" { + export PYTHON_VERSION=3.11.3 run /var/lib/tsuru/deploy assert_success run python --version @@ -273,6 +291,7 @@ EOF assert_success [[ "$output" == *"Using python version: 3.11.3 (PYTHON_VERSION environment variable (closest))"* ]] + export PYTHON_VERSION=3.11.3 run python --version assert_success