From b1690e9f47d8302d3b938c3d4d3f5d9e6a813a2f Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Tue, 6 Oct 2020 09:35:36 +0100 Subject: [PATCH] Add support for Python 3.9.0 (#1090) https://pythoninsider.blogspot.com/2020/10/python-390-is-now-available-and-you-can.html https://www.python.org/downloads/release/python-390/ https://docs.python.org/release/3.9.0/whatsnew/3.9.html Binaries generated using: ``` make deploy-runtimes RUNTIMES='python-3.9.0' STACKS='heroku-16 heroku-18' ENV_FILE=... ``` Closes @W-7791272@. --- CHANGELOG.md | 1 + README.md | 1 + bin/compile | 1 + bin/default_pythons | 1 + bin/steps/pipenv-python-version | 3 ++ bin/steps/python | 6 ++++ builds/runtimes/python-3.9.0 | 4 +++ test/fixtures/python3_9/requirements.txt | 0 test/fixtures/python3_9/runtime.txt | 1 + test/fixtures/python3_9_warn/requirements.txt | 0 test/fixtures/python3_9_warn/runtime.txt | 1 + test/run-versions | 28 +++++++++++++++++++ 12 files changed, 47 insertions(+) create mode 100755 builds/runtimes/python-3.9.0 create mode 100644 test/fixtures/python3_9/requirements.txt create mode 100644 test/fixtures/python3_9/runtime.txt create mode 100644 test/fixtures/python3_9_warn/requirements.txt create mode 100644 test/fixtures/python3_9_warn/runtime.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 1be561e..5255a6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Python 3.9.0 is now available (CPython) (#1090). - Migrate from the `lang-python` S3 bucket to `heroku-buildpack-python` (#1089). - Remove `vendor/shunit2` (#1086). - Replace `BUILDPACK_VENDOR_URL` and `USE_STAGING_BINARIES` with `BUILDPACK_S3_BASE_URL` (#1085). diff --git a/README.md b/README.md index a2ab6ca..50c8cf7 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Specify a Python Runtime Supported runtime options include: +- `python-3.9.0` - `python-3.8.6` - `python-3.7.9` - `python-3.6.12` diff --git a/bin/compile b/bin/compile index 8c356d7..2054a29 100755 --- a/bin/compile +++ b/bin/compile @@ -57,6 +57,7 @@ export S3_BASE_URL source "$BIN_DIR/default_pythons" # Supported Python Branches +PY39="python-3.9" PY38="python-3.8" PY37="python-3.7" PY36="python-3.6" diff --git a/bin/default_pythons b/bin/default_pythons index b98efb7..ac39cc8 100755 --- a/bin/default_pythons +++ b/bin/default_pythons @@ -6,6 +6,7 @@ # shellcheck disable=2034 DEFAULT_PYTHON_VERSION="python-3.6.12" +LATEST_39="python-3.9.0" LATEST_38="python-3.8.6" LATEST_37="python-3.7.9" LATEST_36="python-3.6.12" diff --git a/bin/steps/pipenv-python-version b/bin/steps/pipenv-python-version index cf92cdf..94da66f 100755 --- a/bin/steps/pipenv-python-version +++ b/bin/steps/pipenv-python-version @@ -30,6 +30,9 @@ if [[ -f $BUILD_DIR/Pipfile ]]; then if [ "$PYTHON" = 3.8 ]; then echo "$LATEST_38" > "$BUILD_DIR/runtime.txt" fi + if [ "$PYTHON" = 3.9 ]; then + echo "$LATEST_39" > "$BUILD_DIR/runtime.txt" + fi fi diff --git a/bin/steps/python b/bin/steps/python index db1d06e..45d34e6 100755 --- a/bin/steps/python +++ b/bin/steps/python @@ -16,6 +16,12 @@ PYTHON_2_EOL_UPDATE="Python 2 has reached it's community EOL. Upgrade your Pytho # check if runtime exists if curl --output /dev/null --silent --head --fail "$VENDORED_PYTHON"; then + if [[ "$PYTHON_VERSION" == $PY39* ]]; then + if [ "$PYTHON_VERSION" != "$LATEST_39" ]; then + puts-warn "$SECURITY_UPDATE" "$LATEST_39" + echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" + fi + fi if [[ "$PYTHON_VERSION" == $PY38* ]]; then # do things to alert the user of security release available if [ "$PYTHON_VERSION" != "$LATEST_38" ]; then diff --git a/builds/runtimes/python-3.9.0 b/builds/runtimes/python-3.9.0 new file mode 100755 index 0000000..ad41723 --- /dev/null +++ b/builds/runtimes/python-3.9.0 @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +# Build Path: /app/.heroku/python/ + +source $(dirname $0)/python3 diff --git a/test/fixtures/python3_9/requirements.txt b/test/fixtures/python3_9/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/python3_9/runtime.txt b/test/fixtures/python3_9/runtime.txt new file mode 100644 index 0000000..f72c511 --- /dev/null +++ b/test/fixtures/python3_9/runtime.txt @@ -0,0 +1 @@ +python-3.9.0 diff --git a/test/fixtures/python3_9_warn/requirements.txt b/test/fixtures/python3_9_warn/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/python3_9_warn/runtime.txt b/test/fixtures/python3_9_warn/runtime.txt new file mode 100644 index 0000000..f72c511 --- /dev/null +++ b/test/fixtures/python3_9_warn/runtime.txt @@ -0,0 +1 @@ +python-3.9.0 diff --git a/test/run-versions b/test/run-versions index a642925..82b2f2b 100755 --- a/test/run-versions +++ b/test/run-versions @@ -140,6 +140,34 @@ testPython3_8_warn() { fi } +testPython3_9() { + # Cedar-14 is EOL, so we're not building new major Python versions for it. + if [[ "${STACK}" = "cedar-14" ]]; then + return + fi + compile "python3_9" + assertNotCaptured "security update" + assertCaptured $LATEST_39 + assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2" + assertCaptured "Installing SQLite3" + assertCapturedSuccess +} + +testPython3_9_warn() { + # Cedar-14 is EOL, so we're not building new major Python versions for it. + if [[ "${STACK}" = "cedar-14" ]]; then + return + fi + # Can't test the version warning until there is at least one old version of Python 3.9. + if [[ "${LATEST_39}" = "python-3.9.0" ]]; then + return + fi + compile "python3_9_warn" + assertCaptured "python-3.9.0" + assertCaptured "security update!" + assertCapturedSuccess +} + testPythonVersionInvalid() { compile "python_version_invalid" assertCaptured "Requested runtime (python-3.8.99) is not available for this stack"