From ae4713efd8370a107f168a1aa1d9544228777495 Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Mon, 22 Oct 2018 14:30:25 -0500 Subject: [PATCH 01/15] add new runtimes and test repos --- builds/runtimes/python-3.5.6 | 29 +++++++++++++++++++ builds/runtimes/python-3.6.7 | 29 +++++++++++++++++++ builds/runtimes/python-3.7.1 | 29 +++++++++++++++++++ .../{python3 => python3_5}/requirements.txt | 0 test/fixtures/python3_5/runtime.txt | 1 + test/fixtures/python3_6/requirements.txt | 1 + test/fixtures/python3_6/runtime.txt | 1 + test/fixtures/python3_7/requirements.txt | 1 + test/fixtures/python3_7/runtime.txt | 1 + 9 files changed, 92 insertions(+) create mode 100755 builds/runtimes/python-3.5.6 create mode 100755 builds/runtimes/python-3.6.7 create mode 100755 builds/runtimes/python-3.7.1 rename test/fixtures/{python3 => python3_5}/requirements.txt (100%) create mode 100644 test/fixtures/python3_5/runtime.txt create mode 100644 test/fixtures/python3_6/requirements.txt create mode 100644 test/fixtures/python3_6/runtime.txt create mode 100644 test/fixtures/python3_7/requirements.txt create mode 100644 test/fixtures/python3_7/runtime.txt diff --git a/builds/runtimes/python-3.5.6 b/builds/runtimes/python-3.5.6 new file mode 100755 index 0000000..0ee79d5 --- /dev/null +++ b/builds/runtimes/python-3.5.6 @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Build Path: /app/.heroku/python/ + +OUT_PREFIX=$1 +BIN_DIR="$(cd "$(dirname "$0")"/../.. || exit; pwd)/bin" +export BIN_DIR + +# shellcheck source=bin/utils +source "$BIN_DIR/steps/sqlite3" + +sqlite3_version +echo "Setting up SQLite3 Headers for $SQLITE3_VERSION" +sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1 + +echo "Building Python…" +SOURCE_TARBALL='https://python.org/ftp/python/3.5.6/Python-3.5.6.tgz' +curl -L $SOURCE_TARBALL | tar xz +mv Python-3.7.0 src +cd src + +./configure --prefix=$OUT_PREFIX --with-ensurepip=no +make +make install + +# Remove unneeded test directories, similar to the official Docker Python images: +# https://github.com/docker-library/python +find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' + + +ln $OUT_PREFIX/bin/python3 $OUT_PREFIX/bin/python diff --git a/builds/runtimes/python-3.6.7 b/builds/runtimes/python-3.6.7 new file mode 100755 index 0000000..9d43de8 --- /dev/null +++ b/builds/runtimes/python-3.6.7 @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Build Path: /app/.heroku/python/ + +OUT_PREFIX=$1 +BIN_DIR="$(cd "$(dirname "$0")"/../.. || exit; pwd)/bin" +export BIN_DIR + +# shellcheck source=bin/utils +source "$BIN_DIR/steps/sqlite3" + +sqlite3_version +echo "Setting up SQLite3 Headers for $SQLITE3_VERSION" +sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1 + +echo "Building Python…" +SOURCE_TARBALL='https://python.org/ftp/python/3.6.7/Python-3.6.7.tgz' +curl -L $SOURCE_TARBALL | tar xz +mv Python-3.7.0 src +cd src + +./configure --prefix=$OUT_PREFIX --with-ensurepip=no +make +make install + +# Remove unneeded test directories, similar to the official Docker Python images: +# https://github.com/docker-library/python +find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' + + +ln $OUT_PREFIX/bin/python3 $OUT_PREFIX/bin/python diff --git a/builds/runtimes/python-3.7.1 b/builds/runtimes/python-3.7.1 new file mode 100755 index 0000000..a4ad45f --- /dev/null +++ b/builds/runtimes/python-3.7.1 @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Build Path: /app/.heroku/python/ + +OUT_PREFIX=$1 +BIN_DIR="$(cd "$(dirname "$0")"/../.. || exit; pwd)/bin" +export BIN_DIR + +# shellcheck source=bin/utils +source "$BIN_DIR/steps/sqlite3" + +sqlite3_version +echo "Setting up SQLite3 Headers for $SQLITE3_VERSION" +sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1 + +echo "Building Python…" +SOURCE_TARBALL='https://python.org/ftp/python/3.7.1/Python-3.7.1.tgz' +curl -L $SOURCE_TARBALL | tar xz +mv Python-3.7.0 src +cd src + +./configure --prefix=$OUT_PREFIX --with-ensurepip=no +make +make install + +# Remove unneeded test directories, similar to the official Docker Python images: +# https://github.com/docker-library/python +find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' + + +ln $OUT_PREFIX/bin/python3 $OUT_PREFIX/bin/python diff --git a/test/fixtures/python3/requirements.txt b/test/fixtures/python3_5/requirements.txt similarity index 100% rename from test/fixtures/python3/requirements.txt rename to test/fixtures/python3_5/requirements.txt diff --git a/test/fixtures/python3_5/runtime.txt b/test/fixtures/python3_5/runtime.txt new file mode 100644 index 0000000..e6391f4 --- /dev/null +++ b/test/fixtures/python3_5/runtime.txt @@ -0,0 +1 @@ +python-3.5.6 diff --git a/test/fixtures/python3_6/requirements.txt b/test/fixtures/python3_6/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/test/fixtures/python3_6/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file diff --git a/test/fixtures/python3_6/runtime.txt b/test/fixtures/python3_6/runtime.txt new file mode 100644 index 0000000..34b35b7 --- /dev/null +++ b/test/fixtures/python3_6/runtime.txt @@ -0,0 +1 @@ +python-3.6.7 diff --git a/test/fixtures/python3_7/requirements.txt b/test/fixtures/python3_7/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/test/fixtures/python3_7/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file diff --git a/test/fixtures/python3_7/runtime.txt b/test/fixtures/python3_7/runtime.txt new file mode 100644 index 0000000..4255f73 --- /dev/null +++ b/test/fixtures/python3_7/runtime.txt @@ -0,0 +1 @@ +python-3.7.1 From 07241cd751c1e3d9858a8fca1c9dcaf1cc766f35 Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Mon, 22 Oct 2018 14:31:48 -0500 Subject: [PATCH 02/15] add tests for new runtimes --- test/run | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/run b/test/run index f636816..c5126da 100755 --- a/test/run +++ b/test/run @@ -93,9 +93,21 @@ testPython2() { assertCapturedSuccess } -testPython3() { - compile "python3" - assertCaptured "python-3.6.6" +testPython3_5() { + compile "python3_5" + assertCaptured "python-3.5.6" + assertCapturedSuccess +} + +testPython3_6() { + compile "python3_6" + assertCaptured "python-3.6.7" + assertCapturedSuccess +} + +testPython3_7() { + compile "python3_7" + assertCaptured "python-3.7.1" assertCapturedSuccess } From 2f430abf075af9aaf9ceaf61b96f9b42597185c1 Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Mon, 22 Oct 2018 14:34:44 -0500 Subject: [PATCH 03/15] adjust sqlcheck --- bin/utils | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/utils b/bin/utils index 2bbf82a..4d1b786 100755 --- a/bin/utils +++ b/bin/utils @@ -89,7 +89,7 @@ python3_check() { # Check if Python version needs to install SQLite3 python_sqlite3_check() { VERSION="$1" - MIN_PYTHON_3="python-3.6.6" + MIN_PYTHON_3="python-3.5.6" MIN_PYTHON_2="python-2.7.15" ( python2_check "$VERSION" && version_gte "$VERSION" "$MIN_PYTHON_2" ) \ From 0a169e76a4ffa97ef51673554beaab3f7d1f00d1 Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Mon, 22 Oct 2018 15:46:10 -0500 Subject: [PATCH 04/15] fix extra slash in python install location --- CHANGELOG.md | 4 ++++ builds/runtimes/python-3.5.6 | 7 +++++-- builds/runtimes/python-3.6.7 | 7 +++++-- builds/runtimes/python-3.7.1 | 7 +++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a5e3a0..b417026 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Python Buildpack Changelog +# 142 (2018-10-22) + +Python 3.7.1, 3.6.7 and 3.5.6 now available on all Heroku stacks. + # 141 (2018-10-10) Switch to cautious upgrade for Pipenv install to ensure the pinned pip version diff --git a/builds/runtimes/python-3.5.6 b/builds/runtimes/python-3.5.6 index 0ee79d5..0d17935 100755 --- a/builds/runtimes/python-3.5.6 +++ b/builds/runtimes/python-3.5.6 @@ -15,7 +15,7 @@ sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1 echo "Building Python…" SOURCE_TARBALL='https://python.org/ftp/python/3.5.6/Python-3.5.6.tgz' curl -L $SOURCE_TARBALL | tar xz -mv Python-3.7.0 src +mv Python-3.5.6 src cd src ./configure --prefix=$OUT_PREFIX --with-ensurepip=no @@ -26,4 +26,7 @@ make install # https://github.com/docker-library/python find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' + -ln $OUT_PREFIX/bin/python3 $OUT_PREFIX/bin/python +# Remove spare / +LOCATION=${OUT_PREFIX%?} + +ln $LOCATION/bin/python3 $LOCATION/bin/python diff --git a/builds/runtimes/python-3.6.7 b/builds/runtimes/python-3.6.7 index 9d43de8..052ee1e 100755 --- a/builds/runtimes/python-3.6.7 +++ b/builds/runtimes/python-3.6.7 @@ -15,7 +15,7 @@ sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1 echo "Building Python…" SOURCE_TARBALL='https://python.org/ftp/python/3.6.7/Python-3.6.7.tgz' curl -L $SOURCE_TARBALL | tar xz -mv Python-3.7.0 src +mv Python-3.6.7 src cd src ./configure --prefix=$OUT_PREFIX --with-ensurepip=no @@ -26,4 +26,7 @@ make install # https://github.com/docker-library/python find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' + -ln $OUT_PREFIX/bin/python3 $OUT_PREFIX/bin/python +# Remove spare / +LOCATION=${OUT_PREFIX%?} + +ln $LOCATION/bin/python3 $LOCATION/bin/python diff --git a/builds/runtimes/python-3.7.1 b/builds/runtimes/python-3.7.1 index a4ad45f..b805139 100755 --- a/builds/runtimes/python-3.7.1 +++ b/builds/runtimes/python-3.7.1 @@ -15,7 +15,7 @@ sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1 echo "Building Python…" SOURCE_TARBALL='https://python.org/ftp/python/3.7.1/Python-3.7.1.tgz' curl -L $SOURCE_TARBALL | tar xz -mv Python-3.7.0 src +mv Python-3.7.1 src cd src ./configure --prefix=$OUT_PREFIX --with-ensurepip=no @@ -26,4 +26,7 @@ make install # https://github.com/docker-library/python find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' + -ln $OUT_PREFIX/bin/python3 $OUT_PREFIX/bin/python +# Remove spare / +LOCATION=${OUT_PREFIX%?} + +ln $LOCATION/bin/python3 $LOCATION/bin/python From 25818765eeef8d36321c3325a34e157800d7c045 Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Thu, 8 Nov 2018 15:54:45 -0600 Subject: [PATCH 05/15] update changelog --- CHANGELOG.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b417026..d6b3209 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,27 @@ # Python Buildpack Changelog -# 142 (2018-10-22) +# 145 (2018-11-08) Python 3.7.1, 3.6.7 and 3.5.6 now available on all Heroku stacks. -# 141 (2018-10-10) +# 144 (2018-10-10) Switch to cautious upgrade for Pipenv install to ensure the pinned pip version is used with Pipenv -# 140 (2018-10-09) +# 143 (2018-10-09) Add support for detecting SLUGIFY_USES_TEXT_UNIDECODE, which is required to install Apache Airflow version 1.10 or higher. -# 139 (2018-10-08) +# 142 (2018-10-08) Improvements to Python install messaging +# 139, 140, 141 + +No user-facing changes, documenting for version clarity + # 138 (2018-08-01) Use stack image SQLite3 instead of vendoring From ef1f7f69246cdc9bf37e575c854c5bf175d45442 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 31 Oct 2018 16:59:04 -0400 Subject: [PATCH 06/15] fix: drop broken version check Due to how the version checks work - via sorting, not actual comparison - this previously resulted in _always_ installing sqlite3, even though it was already bundled for lower versions of python. The second version check also encompasses 3.7.0+, so there is no need to respecify the check. --- bin/utils | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/utils b/bin/utils index 4d1b786..f625645 100755 --- a/bin/utils +++ b/bin/utils @@ -93,6 +93,5 @@ python_sqlite3_check() { MIN_PYTHON_2="python-2.7.15" ( python2_check "$VERSION" && version_gte "$VERSION" "$MIN_PYTHON_2" ) \ - || ( python3_check "$VERSION" && version_gte "$VERSION" "$MIN_PYTHON_3" ) \ - || ( version_gte "$VERSION" "3.7.0" ) + || ( python3_check "$VERSION" && version_gte "$VERSION" "$MIN_PYTHON_3" ) } From f3ef152624d0b811b7fc1254d198c1584334b7ff Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Sun, 11 Nov 2018 15:34:49 -0600 Subject: [PATCH 07/15] update tests to pass, add 3.4 --- bin/compile | 8 +++ bin/steps/python | 68 ++++++++++++---------- builds/runtimes/python-3.4.9 | 32 ++++++++++ test/fixtures/python3_4/requirements.txt | 1 + test/fixtures/python3_4/runtime.txt | 1 + test/fixtures/python3_6/runtime.txt | 2 +- test/fixtures/python3_6_7/requirements.txt | 1 + test/fixtures/python3_6_7/runtime.txt | 1 + test/fixtures/python3_7/runtime.txt | 2 +- test/fixtures/python3_7_1/requirements.txt | 1 + test/fixtures/python3_7_1/runtime.txt | 1 + test/run | 28 ++++++++- 12 files changed, 109 insertions(+), 37 deletions(-) create mode 100755 builds/runtimes/python-3.4.9 create mode 100644 test/fixtures/python3_4/requirements.txt create mode 100644 test/fixtures/python3_4/runtime.txt create mode 100644 test/fixtures/python3_6_7/requirements.txt create mode 100644 test/fixtures/python3_6_7/runtime.txt create mode 100644 test/fixtures/python3_7_1/requirements.txt create mode 100644 test/fixtures/python3_7_1/runtime.txt diff --git a/bin/compile b/bin/compile index d97af68..451a286 100755 --- a/bin/compile +++ b/bin/compile @@ -52,14 +52,22 @@ export VENDOR_URL DEFAULT_PYTHON_VERSION="python-3.6.6" LATEST_36="python-3.6.6" LATEST_37="python-3.7.0" +LATEST_35="python-3.5.6" LATEST_2="python-2.7.15" +# Supported Python Branches +PY37="python-3.7" +PY36="python-3.6" +PY35="python-3.5" +PY27="python-2.7" + # Which stack is used (for binary downloading), if none is provided (e.g. outside of Heroku)? DEFAULT_PYTHON_STACK="cedar-14" # If pip doesn't match this version (the version we install), run the installer. PIP_UPDATE="9.0.2" export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE LATEST_2 LATEST_36 LATEST_37 +export PY37 PY36 PY35 PY27 # Common Problem Warnings: # This section creates a temporary file in which to stick the output of `pip install`. diff --git a/bin/steps/python b/bin/steps/python index ea623b1..d8e2c3a 100755 --- a/bin/steps/python +++ b/bin/steps/python @@ -7,43 +7,47 @@ PYTHON_VERSION=$(cat runtime.txt) # The location of the pre-compiled python binary. VENDORED_PYTHON="${VENDOR_URL}/runtimes/$PYTHON_VERSION.tar.gz" -if [[ $PYTHON_VERSION =~ ^python-2 ]]; then - if [[ "$PYTHON_VERSION" != "$LATEST_2" ]]; then - puts-warn "The latest version of Python 2 is $LATEST_2 (you are using $PYTHON_VERSION, which is unsupported)." - puts-warn "We recommend upgrading by specifying the latest version ($LATEST_2)." - echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" - else - echo " Using supported version of Python 2 ($PYTHON_VERSION)" - fi -else - if [[ $PYTHON_VERSION =~ ^python-3 ]]; then - if [[ $PYTHON_VERSION =~ ^python-3.7 ]]; then - if [[ "$PYTHON_VERSION" != "$LATEST_37" ]]; then - puts-warn "The latest version of Python 3.7 is $LATEST_37 (you are using $PYTHON_VERSION, which is unsupported)." - puts-warn "We recommend upgrading by specifying the latest version ($LATEST_37)." +# "https://lang-python.s3.amazonaws.com/heroku-16/runtimes/python-3.6.6.tar.gz" + +SECURITY_UPDATE="Python has released a security update! Please consider upgrading to " + +# check if runtime exists +if curl --output /dev/null --silent --head --fail $VENDORED_PYTHON; then + if [[ $PYTHON_VERSION == $PY37* ]]; then + # do things to alert the user of security release available + if [ $PYTHON_VERSION != $LATEST_37 ]; then + puts-warn SECURITY_UPDATE $LATEST_37 echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" - else - echo " Using supported version of Python 3.7 ($PYTHON_VERSION)" - fi - else - if [[ $PYTHON_VERSION =~ ^python-3.6 ]]; then - if [[ "$PYTHON_VERSION" != "$LATEST_36" ]]; then - puts-warn "The latest version of Python 3.6 is $LATEST_36 (you are using $PYTHON_VERSION, which is unsupported)." - puts-warn "We recommend upgrading by specifying the latest version ($LATEST_36)." - echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" - else - echo " Using supported version of Python 3.6 ($PYTHON_VERSION)" - fi - else - puts-warn "Heroku supports runtime versions $LATEST_37, $LATEST_36 and $LATEST_2." - puts-warn "You are using $PYTHON_VERSION, which is unsupported." - puts-warn "We recommend upgrading by specifying the default supported version ($LATEST_36)." - echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" - fi fi fi + if [[ $PYTHON_VERSION == $PY36* ]]; then + # security update note + if [ $PYTHON_VERSION != $LATEST_36 ]; then + puts-warn SECURITY_UPDATE $LATEST_36 + echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" + fi + fi + if [[ $PYTHON_VERSION == $PY35* ]]; then + # security update note + if [ $PYTHON_VERSION != $LATEST_35 ]; then + puts-warn SECURITY_UPDATE $LATEST_35 + echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" + fi + fi + if [[ $PYTHON_VERSION == $PY27* ]]; then + # security update note + if [ $PYTHON_VERSION != $LATEST_27 ]; then + puts-warn SECURITY_UPDATE $LATEST_27 + echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" + fi + fi +else + puts-warn "Requested runtime ($PYTHON_VERSION) is not available for this stack ($STACK)." + puts-warn "Aborting. More info: https://devcenter.heroku.com/articles/python-support" + exit 1 fi + if [[ "$STACK" != "$CACHED_PYTHON_STACK" ]]; then puts-step "Stack has changed from $CACHED_PYTHON_STACK to $STACK, clearing cache" rm -fr .heroku/python-stack .heroku/python-version .heroku/python .heroku/vendor .heroku/python .heroku/python-sqlite3-version diff --git a/builds/runtimes/python-3.4.9 b/builds/runtimes/python-3.4.9 new file mode 100755 index 0000000..00cf507 --- /dev/null +++ b/builds/runtimes/python-3.4.9 @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Build Path: /app/.heroku/python/ + +OUT_PREFIX=$1 +BIN_DIR="$(cd "$(dirname "$0")"/../.. || exit; pwd)/bin" +export BIN_DIR + +# shellcheck source=bin/utils +source "$BIN_DIR/steps/sqlite3" + +sqlite3_version +echo "Setting up SQLite3 Headers for $SQLITE3_VERSION" +sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1 + +echo "Building Python…" +SOURCE_TARBALL='https://python.org/ftp/python/3.4.9/Python-3.4.9.tgz' +curl -L $SOURCE_TARBALL | tar xz +mv Python-3.4.9 src +cd src + +./configure --prefix=$OUT_PREFIX --with-ensurepip=no +make +make install + +# Remove unneeded test directories, similar to the official Docker Python images: +# https://github.com/docker-library/python +find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' + + +# Remove spare / +LOCATION=${OUT_PREFIX%?} + +ln $LOCATION/bin/python3 $LOCATION/bin/python diff --git a/test/fixtures/python3_4/requirements.txt b/test/fixtures/python3_4/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/test/fixtures/python3_4/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/test/fixtures/python3_4/runtime.txt b/test/fixtures/python3_4/runtime.txt new file mode 100644 index 0000000..cc8325f --- /dev/null +++ b/test/fixtures/python3_4/runtime.txt @@ -0,0 +1 @@ +python-3.4.9 diff --git a/test/fixtures/python3_6/runtime.txt b/test/fixtures/python3_6/runtime.txt index 34b35b7..1935e97 100644 --- a/test/fixtures/python3_6/runtime.txt +++ b/test/fixtures/python3_6/runtime.txt @@ -1 +1 @@ -python-3.6.7 +python-3.6.6 diff --git a/test/fixtures/python3_6_7/requirements.txt b/test/fixtures/python3_6_7/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/test/fixtures/python3_6_7/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/test/fixtures/python3_6_7/runtime.txt b/test/fixtures/python3_6_7/runtime.txt new file mode 100644 index 0000000..34b35b7 --- /dev/null +++ b/test/fixtures/python3_6_7/runtime.txt @@ -0,0 +1 @@ +python-3.6.7 diff --git a/test/fixtures/python3_7/runtime.txt b/test/fixtures/python3_7/runtime.txt index 4255f73..881a2db 100644 --- a/test/fixtures/python3_7/runtime.txt +++ b/test/fixtures/python3_7/runtime.txt @@ -1 +1 @@ -python-3.7.1 +python-3.7.0 diff --git a/test/fixtures/python3_7_1/requirements.txt b/test/fixtures/python3_7_1/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/test/fixtures/python3_7_1/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/test/fixtures/python3_7_1/runtime.txt b/test/fixtures/python3_7_1/runtime.txt new file mode 100644 index 0000000..4255f73 --- /dev/null +++ b/test/fixtures/python3_7_1/runtime.txt @@ -0,0 +1 @@ +python-3.7.1 diff --git a/test/run b/test/run index c5126da..67d4113 100755 --- a/test/run +++ b/test/run @@ -93,24 +93,46 @@ testPython2() { assertCapturedSuccess } +# This will succeed on Cedar-14 and fail on 16 and 18 +testPython3_4() { + compile "python3_4" + assertCaptured "python-3.4.9" + assertCapturedError +} + +# This will fail testPython3_5() { compile "python3_5" assertCaptured "python-3.5.6" - assertCapturedSuccess + assertCapturedError } testPython3_6() { compile "python3_6" - assertCaptured "python-3.6.7" + assertCaptured "python-3.6.6" assertCapturedSuccess } +# This will fail +testPython3_6_7() { + compile "python3_6_7" + assertCaptured "python-3.6.7" + assertCapturedError +} + testPython3_7() { compile "python3_7" - assertCaptured "python-3.7.1" + assertCaptured "python-3.7.0" assertCapturedSuccess } +# This will fail +testPython3_7_1() { + compile "python3_7_1" + assertCaptured "python-3.7.1" + assertCapturedError +} + testGitEgg() { compile "git-egg" assertCaptured "requests" From c3845fff9afabe3e67fb7dbe9fa9a1e123e2b919 Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Sun, 11 Nov 2018 15:43:21 -0600 Subject: [PATCH 08/15] use text variable as variable in puts-warn --- bin/steps/python | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bin/steps/python b/bin/steps/python index d8e2c3a..cfd267f 100755 --- a/bin/steps/python +++ b/bin/steps/python @@ -7,8 +7,6 @@ PYTHON_VERSION=$(cat runtime.txt) # The location of the pre-compiled python binary. VENDORED_PYTHON="${VENDOR_URL}/runtimes/$PYTHON_VERSION.tar.gz" -# "https://lang-python.s3.amazonaws.com/heroku-16/runtimes/python-3.6.6.tar.gz" - SECURITY_UPDATE="Python has released a security update! Please consider upgrading to " # check if runtime exists @@ -16,28 +14,28 @@ if curl --output /dev/null --silent --head --fail $VENDORED_PYTHON; then if [[ $PYTHON_VERSION == $PY37* ]]; then # do things to alert the user of security release available if [ $PYTHON_VERSION != $LATEST_37 ]; then - puts-warn SECURITY_UPDATE $LATEST_37 + puts-warn $SECURITY_UPDATE $LATEST_37 echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi if [[ $PYTHON_VERSION == $PY36* ]]; then # security update note if [ $PYTHON_VERSION != $LATEST_36 ]; then - puts-warn SECURITY_UPDATE $LATEST_36 + puts-warn $SECURITY_UPDATE $LATEST_36 echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi if [[ $PYTHON_VERSION == $PY35* ]]; then # security update note if [ $PYTHON_VERSION != $LATEST_35 ]; then - puts-warn SECURITY_UPDATE $LATEST_35 + puts-warn $SECURITY_UPDATE $LATEST_35 echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi if [[ $PYTHON_VERSION == $PY27* ]]; then # security update note if [ $PYTHON_VERSION != $LATEST_27 ]; then - puts-warn SECURITY_UPDATE $LATEST_27 + puts-warn $SECURITY_UPDATE $LATEST_27 echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi From 3de5b43447ddef1432f81d61ee309dad27635b7a Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Sun, 11 Nov 2018 16:36:16 -0600 Subject: [PATCH 09/15] add bash pre-commit hook and correct shellcheck warnings --- .pre-commit-config.yaml | 5 +++++ bin/steps/python | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c193863 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: +- repo: git://github.com/detailyang/pre-commit-shell + rev: 1.0.4 + hooks: + - id: shell-lint diff --git a/bin/steps/python b/bin/steps/python index cfd267f..cb69783 100755 --- a/bin/steps/python +++ b/bin/steps/python @@ -10,32 +10,32 @@ VENDORED_PYTHON="${VENDOR_URL}/runtimes/$PYTHON_VERSION.tar.gz" SECURITY_UPDATE="Python has released a security update! Please consider upgrading to " # check if runtime exists -if curl --output /dev/null --silent --head --fail $VENDORED_PYTHON; then - if [[ $PYTHON_VERSION == $PY37* ]]; then +if curl --output /dev/null --silent --head --fail "$VENDORED_PYTHON"; then + if [[ "$PYTHON_VERSION" == $PY37* ]]; then # do things to alert the user of security release available - if [ $PYTHON_VERSION != $LATEST_37 ]; then - puts-warn $SECURITY_UPDATE $LATEST_37 + if [ "$PYTHON_VERSION" != "$LATEST_37" ]; then + puts-warn "$SECURITY_UPDATE" "$LATEST_37" echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi - if [[ $PYTHON_VERSION == $PY36* ]]; then + if [[ "$PYTHON_VERSION" == $PY36* ]]; then # security update note - if [ $PYTHON_VERSION != $LATEST_36 ]; then - puts-warn $SECURITY_UPDATE $LATEST_36 + if [ "$PYTHON_VERSION" != "$LATEST_36" ]; then + puts-warn "$SECURITY_UPDATE" "$LATEST_36" echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi - if [[ $PYTHON_VERSION == $PY35* ]]; then + if [[ "$PYTHON_VERSION" == $PY35* ]]; then # security update note - if [ $PYTHON_VERSION != $LATEST_35 ]; then - puts-warn $SECURITY_UPDATE $LATEST_35 + if [ "$PYTHON_VERSION" != "$LATEST_35" ]; then + puts-warn "$SECURITY_UPDATE" "$LATEST_35" echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi - if [[ $PYTHON_VERSION == $PY27* ]]; then + if [[ "$PYTHON_VERSION" == $PY27* ]]; then # security update note - if [ $PYTHON_VERSION != $LATEST_27 ]; then - puts-warn $SECURITY_UPDATE $LATEST_27 + if [ "$PYTHON_VERSION" != "$LATEST_27" ]; then + puts-warn "$SECURITY_UPDATE" "$LATEST_27" echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi From 4750639a0d796c85320e84616df9fcfc7a140899 Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Sun, 11 Nov 2018 16:38:12 -0600 Subject: [PATCH 10/15] add python 3.4 detection --- bin/compile | 2 ++ bin/steps/python | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/bin/compile b/bin/compile index 451a286..a4fe746 100755 --- a/bin/compile +++ b/bin/compile @@ -53,12 +53,14 @@ DEFAULT_PYTHON_VERSION="python-3.6.6" LATEST_36="python-3.6.6" LATEST_37="python-3.7.0" LATEST_35="python-3.5.6" +LATEST_34="python-3.4.9" LATEST_2="python-2.7.15" # Supported Python Branches PY37="python-3.7" PY36="python-3.6" PY35="python-3.5" +PY35="python-3.4" PY27="python-2.7" # Which stack is used (for binary downloading), if none is provided (e.g. outside of Heroku)? diff --git a/bin/steps/python b/bin/steps/python index cb69783..ac5b057 100755 --- a/bin/steps/python +++ b/bin/steps/python @@ -32,6 +32,13 @@ if curl --output /dev/null --silent --head --fail "$VENDORED_PYTHON"; then echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi + if [[ "$PYTHON_VERSION" == $PY34* ]]; then + # security update note + if [ "$PYTHON_VERSION" != "$LATEST_34" ]; then + puts-warn "$SECURITY_UPDATE" "$LATEST_34" + echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" + fi + fi if [[ "$PYTHON_VERSION" == $PY27* ]]; then # security update note if [ "$PYTHON_VERSION" != "$LATEST_27" ]; then From 0be9d48013a595ea5fea3ae47224e7ccd726c78c Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Sun, 11 Nov 2018 16:51:29 -0600 Subject: [PATCH 11/15] add missing vars for python step --- bin/compile | 7 ++++--- bin/steps/python | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/compile b/bin/compile index a4fe746..246839d 100755 --- a/bin/compile +++ b/bin/compile @@ -60,7 +60,7 @@ LATEST_2="python-2.7.15" PY37="python-3.7" PY36="python-3.6" PY35="python-3.5" -PY35="python-3.4" +PY34="python-3.4" PY27="python-2.7" # Which stack is used (for binary downloading), if none is provided (e.g. outside of Heroku)? @@ -68,8 +68,9 @@ DEFAULT_PYTHON_STACK="cedar-14" # If pip doesn't match this version (the version we install), run the installer. PIP_UPDATE="9.0.2" -export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE LATEST_2 LATEST_36 LATEST_37 -export PY37 PY36 PY35 PY27 +export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE +export LATEST_2 LATEST_36 LATEST_37 LATEST_35 LATEST_34 +export PY37 PY36 PY35 PY27 PY34 # Common Problem Warnings: # This section creates a temporary file in which to stick the output of `pip install`. diff --git a/bin/steps/python b/bin/steps/python index ac5b057..6ca1e85 100755 --- a/bin/steps/python +++ b/bin/steps/python @@ -52,7 +52,6 @@ else exit 1 fi - if [[ "$STACK" != "$CACHED_PYTHON_STACK" ]]; then puts-step "Stack has changed from $CACHED_PYTHON_STACK to $STACK, clearing cache" rm -fr .heroku/python-stack .heroku/python-version .heroku/python .heroku/vendor .heroku/python .heroku/python-sqlite3-version From 9e1df4bbb5cc91de09b6c4ed5b99f4342a249184 Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Sun, 11 Nov 2018 17:24:42 -0600 Subject: [PATCH 12/15] specify python 2.7 --- bin/compile | 4 ++-- bin/steps/python | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/compile b/bin/compile index 246839d..a092a28 100755 --- a/bin/compile +++ b/bin/compile @@ -54,7 +54,7 @@ LATEST_36="python-3.6.6" LATEST_37="python-3.7.0" LATEST_35="python-3.5.6" LATEST_34="python-3.4.9" -LATEST_2="python-2.7.15" +LATEST_27="python-2.7.15" # Supported Python Branches PY37="python-3.7" @@ -69,7 +69,7 @@ DEFAULT_PYTHON_STACK="cedar-14" PIP_UPDATE="9.0.2" export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE -export LATEST_2 LATEST_36 LATEST_37 LATEST_35 LATEST_34 +export LATEST_27 LATEST_36 LATEST_37 LATEST_35 LATEST_34 export PY37 PY36 PY35 PY27 PY34 # Common Problem Warnings: diff --git a/bin/steps/python b/bin/steps/python index 6ca1e85..d10eccf 100755 --- a/bin/steps/python +++ b/bin/steps/python @@ -7,7 +7,7 @@ PYTHON_VERSION=$(cat runtime.txt) # The location of the pre-compiled python binary. VENDORED_PYTHON="${VENDOR_URL}/runtimes/$PYTHON_VERSION.tar.gz" -SECURITY_UPDATE="Python has released a security update! Please consider upgrading to " +SECURITY_UPDATE="Python has released a security update! Please consider upgrading to" # check if runtime exists if curl --output /dev/null --silent --head --fail "$VENDORED_PYTHON"; then From 73d37cbac69eccf77105cbdb080449ad57d52445 Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Sun, 11 Nov 2018 17:52:16 -0600 Subject: [PATCH 13/15] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6b3209..fcfb1c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # 145 (2018-11-08) -Python 3.7.1, 3.6.7 and 3.5.6 now available on all Heroku stacks. +Python 3.7.1, 3.6.7, 3.5.6 and 3.4.9 now available on all Heroku stacks. # 144 (2018-10-10) From 7b9e82175e18ebf160109f7558b8d7ba47146007 Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Mon, 12 Nov 2018 17:10:30 -0600 Subject: [PATCH 14/15] add warning detection and per-stack checks --- test/fixtures/python2_warn/requirements.txt | 1 + test/fixtures/python2_warn/runtime.txt | 1 + test/fixtures/python3_4_warn/requirements.txt | 1 + test/fixtures/python3_4_warn/runtime.txt | 1 + test/fixtures/python3_5_warn/requirements.txt | 1 + test/fixtures/python3_5_warn/runtime.txt | 1 + test/fixtures/python3_6_warn/requirements.txt | 1 + test/fixtures/python3_6_warn/runtime.txt | 1 + test/run | 47 +++++++++++++++++-- 9 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/python2_warn/requirements.txt create mode 100644 test/fixtures/python2_warn/runtime.txt create mode 100644 test/fixtures/python3_4_warn/requirements.txt create mode 100644 test/fixtures/python3_4_warn/runtime.txt create mode 100644 test/fixtures/python3_5_warn/requirements.txt create mode 100644 test/fixtures/python3_5_warn/runtime.txt create mode 100644 test/fixtures/python3_6_warn/requirements.txt create mode 100644 test/fixtures/python3_6_warn/runtime.txt diff --git a/test/fixtures/python2_warn/requirements.txt b/test/fixtures/python2_warn/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/test/fixtures/python2_warn/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file diff --git a/test/fixtures/python2_warn/runtime.txt b/test/fixtures/python2_warn/runtime.txt new file mode 100644 index 0000000..5385682 --- /dev/null +++ b/test/fixtures/python2_warn/runtime.txt @@ -0,0 +1 @@ +python-2.7.14 diff --git a/test/fixtures/python3_4_warn/requirements.txt b/test/fixtures/python3_4_warn/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/test/fixtures/python3_4_warn/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/test/fixtures/python3_4_warn/runtime.txt b/test/fixtures/python3_4_warn/runtime.txt new file mode 100644 index 0000000..fe5dcf7 --- /dev/null +++ b/test/fixtures/python3_4_warn/runtime.txt @@ -0,0 +1 @@ +python-3.4.0 diff --git a/test/fixtures/python3_5_warn/requirements.txt b/test/fixtures/python3_5_warn/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/test/fixtures/python3_5_warn/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/test/fixtures/python3_5_warn/runtime.txt b/test/fixtures/python3_5_warn/runtime.txt new file mode 100644 index 0000000..5486d7a --- /dev/null +++ b/test/fixtures/python3_5_warn/runtime.txt @@ -0,0 +1 @@ +python-3.5.3 diff --git a/test/fixtures/python3_6_warn/requirements.txt b/test/fixtures/python3_6_warn/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/test/fixtures/python3_6_warn/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file diff --git a/test/fixtures/python3_6_warn/runtime.txt b/test/fixtures/python3_6_warn/runtime.txt new file mode 100644 index 0000000..486fcce --- /dev/null +++ b/test/fixtures/python3_6_warn/runtime.txt @@ -0,0 +1 @@ +python-3.6.5 diff --git a/test/run b/test/run index 67d4113..484f241 100755 --- a/test/run +++ b/test/run @@ -87,19 +87,48 @@ testPylibmc() { assertCapturedSuccess } +testPython2_warn() { + compile "python2_warn" + assertCaptured "python-2.7.14" + assertCaptured "security update!" + assertCapturedSuccess +} + testPython2() { compile "python2" assertCaptured "python-2.7.15" assertCapturedSuccess } -# This will succeed on Cedar-14 and fail on 16 and 18 +# This fail +testPython3_4_warn() { + compile "python3_4_warn" + if [[ $STACK = "cedar-14" ]]; then + assertCaptured "python-3.4.0" + assertCapturedSuccess + else + assertCapturedError + fi +} + +# This fail testPython3_4() { compile "python3_4" assertCaptured "python-3.4.9" assertCapturedError } +# This fail +testPython3_5_warn() { + compile "python3_5_warn" + if [[ $STACK = "cedar-14" ]]; then + assertCaptured "python-3.5.3" + assertCapturedSuccess + else + assertCapturedError + fi +} + # This will fail testPython3_5() { compile "python3_5" @@ -107,6 +136,14 @@ testPython3_5() { assertCapturedError } +# This will warn +testPython3_6_warn() { + compile "python3_6_warn" + assertCaptured "python-3.6.5" + assertCaptured "security update!" + assertCapturedSuccess +} + testPython3_6() { compile "python3_6" assertCaptured "python-3.6.6" @@ -122,8 +159,12 @@ testPython3_6_7() { testPython3_7() { compile "python3_7" - assertCaptured "python-3.7.0" - assertCapturedSuccess + if [[ $STACK = "cedar-14" ]]; then + assertCapturedError + else + assertCaptured "python-3.7.0" + assertCapturedSuccess + fi } # This will fail From 0b554f660f249010482d2adfdfb624f53ca61c4f Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Mon, 12 Nov 2018 17:27:07 -0600 Subject: [PATCH 15/15] update tests for missed stack issues --- test/run | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/run b/test/run index 484f241..67d97c8 100755 --- a/test/run +++ b/test/run @@ -89,9 +89,13 @@ testPylibmc() { testPython2_warn() { compile "python2_warn" - assertCaptured "python-2.7.14" - assertCaptured "security update!" - assertCapturedSuccess + if [[ $STACK = "heroku-18" ]]; then + assertCapturedError + else + assertCaptured "python-2.7.14" + assertCaptured "security update!" + assertCapturedSuccess + fi } testPython2() { @@ -123,7 +127,8 @@ testPython3_5_warn() { compile "python3_5_warn" if [[ $STACK = "cedar-14" ]]; then assertCaptured "python-3.5.3" - assertCapturedSuccess + assertCaptured "security update!" + assertCapturedError else assertCapturedError fi