Skip to content

Commit a6452a1

Browse files
authored
Merge pull request #772 from heroku/v-145
V 145
2 parents 402cd82 + 0b554f6 commit a6452a1

30 files changed

+299
-41
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repos:
2+
- repo: git://github.com/detailyang/pre-commit-shell
3+
rev: 1.0.4
4+
hooks:
5+
- id: shell-lint

CHANGELOG.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
# Python Buildpack Changelog
22

3-
# 141 (2018-10-10)
3+
# 145 (2018-11-08)
4+
5+
Python 3.7.1, 3.6.7, 3.5.6 and 3.4.9 now available on all Heroku stacks.
6+
7+
# 144 (2018-10-10)
48

59
Switch to cautious upgrade for Pipenv install to ensure the pinned pip version
610
is used with Pipenv
711

8-
# 140 (2018-10-09)
12+
# 143 (2018-10-09)
913

1014
Add support for detecting SLUGIFY_USES_TEXT_UNIDECODE, which is required to
1115
install Apache Airflow version 1.10 or higher.
1216

13-
# 139 (2018-10-08)
17+
# 142 (2018-10-08)
1418

1519
Improvements to Python install messaging
1620

21+
# 139, 140, 141
22+
23+
No user-facing changes, documenting for version clarity
24+
1725
# 138 (2018-08-01)
1826

1927
Use stack image SQLite3 instead of vendoring

bin/compile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,25 @@ export VENDOR_URL
5252
DEFAULT_PYTHON_VERSION="python-3.6.6"
5353
LATEST_36="python-3.6.6"
5454
LATEST_37="python-3.7.0"
55-
LATEST_2="python-2.7.15"
55+
LATEST_35="python-3.5.6"
56+
LATEST_34="python-3.4.9"
57+
LATEST_27="python-2.7.15"
58+
59+
# Supported Python Branches
60+
PY37="python-3.7"
61+
PY36="python-3.6"
62+
PY35="python-3.5"
63+
PY34="python-3.4"
64+
PY27="python-2.7"
5665

5766
# Which stack is used (for binary downloading), if none is provided (e.g. outside of Heroku)?
5867
DEFAULT_PYTHON_STACK="cedar-14"
5968
# If pip doesn't match this version (the version we install), run the installer.
6069
PIP_UPDATE="9.0.2"
6170

62-
export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE LATEST_2 LATEST_36 LATEST_37
71+
export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE
72+
export LATEST_27 LATEST_36 LATEST_37 LATEST_35 LATEST_34
73+
export PY37 PY36 PY35 PY27 PY34
6374

6475
# Common Problem Warnings:
6576
# This section creates a temporary file in which to stick the output of `pip install`.

bin/steps/python

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,49 @@ PYTHON_VERSION=$(cat runtime.txt)
77
# The location of the pre-compiled python binary.
88
VENDORED_PYTHON="${VENDOR_URL}/runtimes/$PYTHON_VERSION.tar.gz"
99

10-
if [[ $PYTHON_VERSION =~ ^python-2 ]]; then
11-
if [[ "$PYTHON_VERSION" != "$LATEST_2" ]]; then
12-
puts-warn "The latest version of Python 2 is $LATEST_2 (you are using $PYTHON_VERSION, which is unsupported)."
13-
puts-warn "We recommend upgrading by specifying the latest version ($LATEST_2)."
14-
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
15-
else
16-
echo " Using supported version of Python 2 ($PYTHON_VERSION)"
10+
SECURITY_UPDATE="Python has released a security update! Please consider upgrading to"
11+
12+
# check if runtime exists
13+
if curl --output /dev/null --silent --head --fail "$VENDORED_PYTHON"; then
14+
if [[ "$PYTHON_VERSION" == $PY37* ]]; then
15+
# do things to alert the user of security release available
16+
if [ "$PYTHON_VERSION" != "$LATEST_37" ]; then
17+
puts-warn "$SECURITY_UPDATE" "$LATEST_37"
18+
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
19+
fi
1720
fi
18-
else
19-
if [[ $PYTHON_VERSION =~ ^python-3 ]]; then
20-
if [[ $PYTHON_VERSION =~ ^python-3.7 ]]; then
21-
if [[ "$PYTHON_VERSION" != "$LATEST_37" ]]; then
22-
puts-warn "The latest version of Python 3.7 is $LATEST_37 (you are using $PYTHON_VERSION, which is unsupported)."
23-
puts-warn "We recommend upgrading by specifying the latest version ($LATEST_37)."
21+
if [[ "$PYTHON_VERSION" == $PY36* ]]; then
22+
# security update note
23+
if [ "$PYTHON_VERSION" != "$LATEST_36" ]; then
24+
puts-warn "$SECURITY_UPDATE" "$LATEST_36"
25+
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
26+
fi
27+
fi
28+
if [[ "$PYTHON_VERSION" == $PY35* ]]; then
29+
# security update note
30+
if [ "$PYTHON_VERSION" != "$LATEST_35" ]; then
31+
puts-warn "$SECURITY_UPDATE" "$LATEST_35"
2432
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
25-
else
26-
echo " Using supported version of Python 3.7 ($PYTHON_VERSION)"
27-
fi
28-
else
29-
if [[ $PYTHON_VERSION =~ ^python-3.6 ]]; then
30-
if [[ "$PYTHON_VERSION" != "$LATEST_36" ]]; then
31-
puts-warn "The latest version of Python 3.6 is $LATEST_36 (you are using $PYTHON_VERSION, which is unsupported)."
32-
puts-warn "We recommend upgrading by specifying the latest version ($LATEST_36)."
33-
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
34-
else
35-
echo " Using supported version of Python 3.6 ($PYTHON_VERSION)"
36-
fi
37-
else
38-
puts-warn "Heroku supports runtime versions $LATEST_37, $LATEST_36 and $LATEST_2."
39-
puts-warn "You are using $PYTHON_VERSION, which is unsupported."
40-
puts-warn "We recommend upgrading by specifying the default supported version ($LATEST_36)."
41-
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
42-
fi
4333
fi
4434
fi
35+
if [[ "$PYTHON_VERSION" == $PY34* ]]; then
36+
# security update note
37+
if [ "$PYTHON_VERSION" != "$LATEST_34" ]; then
38+
puts-warn "$SECURITY_UPDATE" "$LATEST_34"
39+
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
40+
fi
41+
fi
42+
if [[ "$PYTHON_VERSION" == $PY27* ]]; then
43+
# security update note
44+
if [ "$PYTHON_VERSION" != "$LATEST_27" ]; then
45+
puts-warn "$SECURITY_UPDATE" "$LATEST_27"
46+
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
47+
fi
48+
fi
49+
else
50+
puts-warn "Requested runtime ($PYTHON_VERSION) is not available for this stack ($STACK)."
51+
puts-warn "Aborting. More info: https://devcenter.heroku.com/articles/python-support"
52+
exit 1
4553
fi
4654

4755
if [[ "$STACK" != "$CACHED_PYTHON_STACK" ]]; then

bin/utils

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ python3_check() {
8989
# Check if Python version needs to install SQLite3
9090
python_sqlite3_check() {
9191
VERSION="$1"
92-
MIN_PYTHON_3="python-3.6.6"
92+
MIN_PYTHON_3="python-3.5.6"
9393
MIN_PYTHON_2="python-2.7.15"
9494

9595
( python2_check "$VERSION" && version_gte "$VERSION" "$MIN_PYTHON_2" ) \
96-
|| ( python3_check "$VERSION" && version_gte "$VERSION" "$MIN_PYTHON_3" ) \
97-
|| ( version_gte "$VERSION" "3.7.0" )
96+
|| ( python3_check "$VERSION" && version_gte "$VERSION" "$MIN_PYTHON_3" )
9897
}

builds/runtimes/python-3.4.9

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
# Build Path: /app/.heroku/python/
3+
4+
OUT_PREFIX=$1
5+
BIN_DIR="$(cd "$(dirname "$0")"/../.. || exit; pwd)/bin"
6+
export BIN_DIR
7+
8+
# shellcheck source=bin/utils
9+
source "$BIN_DIR/steps/sqlite3"
10+
11+
sqlite3_version
12+
echo "Setting up SQLite3 Headers for $SQLITE3_VERSION"
13+
sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1
14+
15+
echo "Building Python…"
16+
SOURCE_TARBALL='https://python.org/ftp/python/3.4.9/Python-3.4.9.tgz'
17+
curl -L $SOURCE_TARBALL | tar xz
18+
mv Python-3.4.9 src
19+
cd src
20+
21+
./configure --prefix=$OUT_PREFIX --with-ensurepip=no
22+
make
23+
make install
24+
25+
# Remove unneeded test directories, similar to the official Docker Python images:
26+
# https://github.com/docker-library/python
27+
find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' +
28+
29+
# Remove spare /
30+
LOCATION=${OUT_PREFIX%?}
31+
32+
ln $LOCATION/bin/python3 $LOCATION/bin/python

builds/runtimes/python-3.5.6

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
# Build Path: /app/.heroku/python/
3+
4+
OUT_PREFIX=$1
5+
BIN_DIR="$(cd "$(dirname "$0")"/../.. || exit; pwd)/bin"
6+
export BIN_DIR
7+
8+
# shellcheck source=bin/utils
9+
source "$BIN_DIR/steps/sqlite3"
10+
11+
sqlite3_version
12+
echo "Setting up SQLite3 Headers for $SQLITE3_VERSION"
13+
sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1
14+
15+
echo "Building Python…"
16+
SOURCE_TARBALL='https://python.org/ftp/python/3.5.6/Python-3.5.6.tgz'
17+
curl -L $SOURCE_TARBALL | tar xz
18+
mv Python-3.5.6 src
19+
cd src
20+
21+
./configure --prefix=$OUT_PREFIX --with-ensurepip=no
22+
make
23+
make install
24+
25+
# Remove unneeded test directories, similar to the official Docker Python images:
26+
# https://github.com/docker-library/python
27+
find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' +
28+
29+
# Remove spare /
30+
LOCATION=${OUT_PREFIX%?}
31+
32+
ln $LOCATION/bin/python3 $LOCATION/bin/python

builds/runtimes/python-3.6.7

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
# Build Path: /app/.heroku/python/
3+
4+
OUT_PREFIX=$1
5+
BIN_DIR="$(cd "$(dirname "$0")"/../.. || exit; pwd)/bin"
6+
export BIN_DIR
7+
8+
# shellcheck source=bin/utils
9+
source "$BIN_DIR/steps/sqlite3"
10+
11+
sqlite3_version
12+
echo "Setting up SQLite3 Headers for $SQLITE3_VERSION"
13+
sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1
14+
15+
echo "Building Python…"
16+
SOURCE_TARBALL='https://python.org/ftp/python/3.6.7/Python-3.6.7.tgz'
17+
curl -L $SOURCE_TARBALL | tar xz
18+
mv Python-3.6.7 src
19+
cd src
20+
21+
./configure --prefix=$OUT_PREFIX --with-ensurepip=no
22+
make
23+
make install
24+
25+
# Remove unneeded test directories, similar to the official Docker Python images:
26+
# https://github.com/docker-library/python
27+
find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' +
28+
29+
# Remove spare /
30+
LOCATION=${OUT_PREFIX%?}
31+
32+
ln $LOCATION/bin/python3 $LOCATION/bin/python

builds/runtimes/python-3.7.1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
# Build Path: /app/.heroku/python/
3+
4+
OUT_PREFIX=$1
5+
BIN_DIR="$(cd "$(dirname "$0")"/../.. || exit; pwd)/bin"
6+
export BIN_DIR
7+
8+
# shellcheck source=bin/utils
9+
source "$BIN_DIR/steps/sqlite3"
10+
11+
sqlite3_version
12+
echo "Setting up SQLite3 Headers for $SQLITE3_VERSION"
13+
sqlite3_install "$OUT_PREFIX" "$SQLITE3_VERSION" 1
14+
15+
echo "Building Python…"
16+
SOURCE_TARBALL='https://python.org/ftp/python/3.7.1/Python-3.7.1.tgz'
17+
curl -L $SOURCE_TARBALL | tar xz
18+
mv Python-3.7.1 src
19+
cd src
20+
21+
./configure --prefix=$OUT_PREFIX --with-ensurepip=no
22+
make
23+
make install
24+
25+
# Remove unneeded test directories, similar to the official Docker Python images:
26+
# https://github.com/docker-library/python
27+
find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' +
28+
29+
# Remove spare /
30+
LOCATION=${OUT_PREFIX%?}
31+
32+
ln $LOCATION/bin/python3 $LOCATION/bin/python

0 commit comments

Comments
 (0)