Skip to content

Commit f3ef152

Browse files
committed
update tests to pass, add 3.4
1 parent ef1f7f6 commit f3ef152

File tree

12 files changed

+108
-36
lines changed

12 files changed

+108
-36
lines changed

bin/compile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,22 @@ 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_35="python-3.5.6"
5556
LATEST_2="python-2.7.15"
5657

58+
# Supported Python Branches
59+
PY37="python-3.7"
60+
PY36="python-3.6"
61+
PY35="python-3.5"
62+
PY27="python-2.7"
63+
5764
# Which stack is used (for binary downloading), if none is provided (e.g. outside of Heroku)?
5865
DEFAULT_PYTHON_STACK="cedar-14"
5966
# If pip doesn't match this version (the version we install), run the installer.
6067
PIP_UPDATE="9.0.2"
6168

6269
export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE LATEST_2 LATEST_36 LATEST_37
70+
export PY37 PY36 PY35 PY27
6371

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

bin/steps/python

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,47 @@ 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+
# "https://lang-python.s3.amazonaws.com/heroku-16/runtimes/python-3.6.6.tar.gz"
11+
12+
SECURITY_UPDATE="Python has released a security update! Please consider upgrading to "
13+
14+
# check if runtime exists
15+
if curl --output /dev/null --silent --head --fail $VENDORED_PYTHON; then
16+
if [[ $PYTHON_VERSION == $PY37* ]]; then
17+
# do things to alert the user of security release available
18+
if [ $PYTHON_VERSION != $LATEST_37 ]; then
19+
puts-warn SECURITY_UPDATE $LATEST_37
20+
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
21+
fi
1722
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)."
23+
if [[ $PYTHON_VERSION == $PY36* ]]; then
24+
# security update note
25+
if [ $PYTHON_VERSION != $LATEST_36 ]; then
26+
puts-warn SECURITY_UPDATE $LATEST_36
27+
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
28+
fi
29+
fi
30+
if [[ $PYTHON_VERSION == $PY35* ]]; then
31+
# security update note
32+
if [ $PYTHON_VERSION != $LATEST_35 ]; then
33+
puts-warn SECURITY_UPDATE $LATEST_35
2434
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
4335
fi
4436
fi
37+
if [[ $PYTHON_VERSION == $PY27* ]]; then
38+
# security update note
39+
if [ $PYTHON_VERSION != $LATEST_27 ]; then
40+
puts-warn SECURITY_UPDATE $LATEST_27
41+
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
42+
fi
43+
fi
44+
else
45+
puts-warn "Requested runtime ($PYTHON_VERSION) is not available for this stack ($STACK)."
46+
puts-warn "Aborting. More info: https://devcenter.heroku.com/articles/python-support"
47+
exit 1
4548
fi
4649

50+
4751
if [[ "$STACK" != "$CACHED_PYTHON_STACK" ]]; then
4852
puts-step "Stack has changed from $CACHED_PYTHON_STACK to $STACK, clearing cache"
4953
rm -fr .heroku/python-stack .heroku/python-version .heroku/python .heroku/vendor .heroku/python .heroku/python-sqlite3-version

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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flask

test/fixtures/python3_4/runtime.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.4.9

test/fixtures/python3_6/runtime.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-3.6.7
1+
python-3.6.6
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flask

test/fixtures/python3_6_7/runtime.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.6.7

test/fixtures/python3_7/runtime.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-3.7.1
1+
python-3.7.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flask

0 commit comments

Comments
 (0)