Skip to content

Commit fcf696b

Browse files
authored
Add support for Heroku-20 (heroku#968)
This adds support for the upcoming Heroku-20 stack. The Heroku-20 Dockerfile is identical to that for Heroku-18, other than the base image, and stack-related env var changes. The initial Python versions made available will be those in: https://devcenter.heroku.com/articles/python-support#supported-runtimes https://devcenter.heroku.com/articles/python-support#supported-pypy-runtimes ...minus CPython 2.7, since it's EOL. Which are: * `python-3.6.12` * `python-3.7.9` * `python-3.8.6` * `python-3.9.0` * `pypy2.7-7.3.2` * `pypy3.6-7.3.2` Note: Unlike CPython 2.7, the PyPy 2.7 branch is still supported: https://doc.pypy.org/en/latest/faq.html#how-long-will-pypy-support-python2 In addition, I've generated binaries for each patch release immediately prior to the latest versions (with the exception of 3.9.0, since there isn't one), otherwise it's not possible to run the "out of date Python" warning tests. The binaries were generated using the process here: https://github.com/heroku/heroku-buildpack-python/blob/main/builds/README.md Specifically: ``` make deploy-runtimes STACKS='heroku-20' \ RUNTIMES='python-3.6.11 python-3.6.12 python-3.7.8 python-3.7.9 python-3.8.5 python-3.8.6 python-3.9.0 pypy2.7-7.3.1 pypy2.7-7.3.2 pypy3.6-7.3.1 pypy3.6-7.3.2' \ ENV_FILE=... ``` Binaries for the GDAL/GEOS/PROJ feature have not been generated, since it's deprecated and due for removal shortly: https://help.heroku.com/D5INLB1A/python-s-build_with_geo_libraries-legacy-feature-is-now-deprecated Note: Like the Python 3.9.0 release, this uses the new S3 bucket, so apps will need to be using a recent version of the buildpack in order to build on Heroku-20: https://devcenter.heroku.com/articles/python-support#checking-the-python-buildpack-version Closes @W-7485877@.
1 parent a98ef91 commit fcf696b

File tree

13 files changed

+92
-40
lines changed

13 files changed

+92
-40
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ env:
3434
- STACK=heroku-18 TEST_CMD=test/run-deps
3535
- STACK=heroku-18 TEST_CMD=test/run-versions
3636
- STACK=heroku-18 TEST_CMD=test/run-features
37+
38+
- STACK=heroku-20 TEST_CMD=test/run-deps
39+
- STACK=heroku-20 TEST_CMD=test/run-versions
40+
- STACK=heroku-20 TEST_CMD=test/run-features
3741
global:
3842
- HATCHET_RETRIES=3
3943
- IS_RUNNING_ON_CI=true

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Add support for Heroku-20 (#968).
56

67
## v182 (2020-10-06)
78

bin/steps/gdal

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ source "$BIN_DIR/utils"
2121
# If GDAL exists within requirements, use vendored gdal.
2222
if (pip-grep -s requirements.txt GDAL gdal pygdal &> /dev/null) then
2323

24-
if [ ! -f ".heroku/vendor/bin/gdalserver" ]; then
24+
if [[ ! -f ".heroku/vendor/bin/gdalserver" && "${STACK}" == 'heroku-20' ]]; then
25+
puts-warn "The buildpack's built-in GDAL functonality is not supported on Heroku-20."
26+
puts-warn "Please use this buildpack instead: https://github.com/heroku/heroku-geo-buildpack"
2527

28+
elif [[ ! -f ".heroku/vendor/bin/gdalserver" ]]; then
2629
puts-warn "The vendored GDAL package in the Heroku Python Buildpack now deprecated."
2730
puts-warn "To enable GDAL use an alternative buildpack is available here - https://github.com/heroku/heroku-geo-buildpack"
2831

bin/steps/geo-libs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
2020
# shellcheck source=bin/utils
2121
source "$BIN_DIR/utils"
2222

23-
# If GDAL exists within requirements, use vendored gdal.
24-
if [[ "$BUILD_WITH_GEO_LIBRARIES" ]]; then
23+
if [[ "$BUILD_WITH_GEO_LIBRARIES" && "${STACK}" == 'heroku-20' ]]; then
24+
puts-warn "The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality is not supported on Heroku-20."
25+
puts-warn "Please use this buildpack for GDAL, GEOS and PROJ: https://github.com/heroku/heroku-geo-buildpack"
26+
puts-warn "To hide this message, unset the BUILD_WITH_GEO_LIBRARIES variable using: heroku config:unset BUILD_WITH_GEO_LIBRARIES"
27+
elif [[ "$BUILD_WITH_GEO_LIBRARIES" ]]; then
2528
mcount "buildvar.BUILD_WITH_GEO_LIBRARIES"
2629

2730
puts-warn "The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality are now deprecated."

builds/heroku-20.Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM heroku/heroku:20-build
2+
3+
ENV WORKSPACE_DIR="/app/builds" \
4+
S3_BUCKET="heroku-buildpack-python" \
5+
S3_PREFIX="heroku-20/" \
6+
STACK="heroku-20"
7+
8+
RUN apt-get update \
9+
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
10+
libsqlite3-dev \
11+
python3-pip \
12+
python3-setuptools \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
WORKDIR /app
16+
17+
COPY requirements.txt /app/
18+
RUN pip3 install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt
19+
20+
COPY . /app

test/fixtures/pipenv-full-version/Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ verify_ssl = true
66
requests = "*"
77

88
[requires]
9-
python_full_version = "3.6.3"
9+
python_full_version = "3.7.8"

test/fixtures/pipenv-full-version/Pipfile.lock

Lines changed: 2 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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.11
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.8
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-3.8.0
1+
python-3.8.5

test/run-deps

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ testGEOS() {
2121
local env_dir="$(mktmpdir)"
2222
echo '1' > "${env_dir}/BUILD_WITH_GEO_LIBRARIES"
2323
compile 'geos' '' "${env_dir}"
24-
assertCaptured "geos"
25-
assertCapturedSuccess
26-
}
27-
28-
testGEOSDeprecation() {
29-
local env_dir="$(mktmpdir)"
30-
echo '1' > "${env_dir}/BUILD_WITH_GEO_LIBRARIES"
31-
compile 'geos' '' "${env_dir}"
32-
assertCaptured " ! The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality are now deprecated.
33-
! An alternative buildpack to enable GDAL, GEOS and PROJ use is available here - https://github.com/heroku/heroku-geo-buildpack"
24+
if [[ $STACK == "heroku-20" ]]; then
25+
assertCaptured " ! The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality is not supported on Heroku-20."
26+
else
27+
assertCaptured " ! The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality are now deprecated."
28+
fi
29+
# This should assertCapturedError on Heroku-20, but the test doesn't actually
30+
# install anything that uses GEOS so succeeds (see W-8145375)
3431
assertCapturedSuccess
3532
}
3633

@@ -55,6 +52,11 @@ testPsycopg2() {
5552
}
5653

5754
testPysqlite() {
55+
# pysqlite does not support Python 3 (since the sqlite3 stdlib can be used there),
56+
# so we have to test with Python 2, which we've not made available for Heroku-20.
57+
if [[ $STACK == "heroku-20" ]]; then
58+
return
59+
fi
5860
compile "pysqlite"
5961
assertCaptured "pysqlite"
6062
assertCapturedSuccess

test/run-features

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ testPipenvPythonVersion3_6() {
6868
}
6969

7070
testPipenvPythonVersion2_7() {
71+
# Python 2.7 is EOL, so it has not been built for Heroku-20.
72+
if [[ $STACK == "heroku-20" ]]; then
73+
return
74+
fi
7175
compile "pipenv-version2"
7276
assertCaptured "Installing ${LATEST_27}"
7377
# Can't use `assertCapturedSuccess` since stderr contains:
@@ -76,8 +80,12 @@ testPipenvPythonVersion2_7() {
7680
}
7781

7882
testPipenvPythonFullVersion() {
83+
# Python 3.7+ requires newer libssl than is present on Cedar-14.
84+
if [[ "${STACK}" = "cedar-14" ]]; then
85+
return
86+
fi
7987
compile "pipenv-full-version"
80-
assertCaptured "3.6.3"
88+
assertCaptured "3.7.8"
8189
# Can't use `assertCapturedSuccess` since stderr contains:
8290
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
8391
assertCapturedSuccessWithStdErr

test/run-versions

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ testPythonVersionUnspecified() {
1414
}
1515

1616
testPython2_7() {
17+
# Python 2.7 is EOL, so it has not been built for Heroku-20.
18+
if [[ $STACK == "heroku-20" ]]; then
19+
return
20+
fi
1721
compile "python2"
1822
assertCaptured "Installing ${LATEST_27}"
1923
assertCaptured "python-2-7-eol-faq";
@@ -24,6 +28,10 @@ testPython2_7() {
2428
}
2529

2630
testPython2_7_warn() {
31+
# Python 2.7 is EOL, so it has not been built for Heroku-20.
32+
if [[ $STACK == "heroku-20" ]]; then
33+
return
34+
fi
2735
compile "python2_warn"
2836
assertCaptured "Installing python-2.7.15"
2937
assertCaptured "python-2-7-eol-faq";
@@ -33,6 +41,10 @@ testPython2_7_warn() {
3341
}
3442

3543
testPython3_4() {
44+
# Python 3.4 is EOL, so it has not been built for Heroku-20.
45+
if [[ $STACK == "heroku-20" ]]; then
46+
return
47+
fi
3648
compile "python3_4"
3749
assertCaptured "Installing ${LATEST_34}"
3850
assertNotCaptured "security update"
@@ -44,6 +56,10 @@ testPython3_4() {
4456
}
4557

4658
testPython3_4_warn() {
59+
# Python 3.4 is EOL, so it has not been built for Heroku-20.
60+
if [[ $STACK == "heroku-20" ]]; then
61+
return
62+
fi
4763
compile "python3_4_warn"
4864
assertCaptured "Installing python-3.4.9"
4965
assertCaptured "security update!"
@@ -54,6 +70,10 @@ testPython3_4_warn() {
5470
}
5571

5672
testPython3_5() {
73+
# Python 3.5 is EOL, so it has not been built for Heroku-20.
74+
if [[ $STACK == "heroku-20" ]]; then
75+
return
76+
fi
5777
compile "python3_5"
5878
assertCaptured "Installing ${LATEST_35}"
5979
assertNotCaptured "security update"
@@ -63,6 +83,10 @@ testPython3_5() {
6383
}
6484

6585
testPython3_5_warn() {
86+
# Python 3.5 is EOL, so it has not been built for Heroku-20.
87+
if [[ $STACK == "heroku-20" ]]; then
88+
return
89+
fi
6690
compile "python3_5_warn"
6791
assertCaptured "Installing python-3.5.6"
6892
assertCaptured "security update!"
@@ -81,7 +105,7 @@ testPython3_6() {
81105

82106
testPython3_6_warn() {
83107
compile "python3_6_warn"
84-
assertCaptured "Installing python-3.6.7"
108+
assertCaptured "Installing python-3.6.11"
85109
assertCaptured "security update!"
86110
assertCaptured "${LATEST_36}"
87111
assertCapturedSuccess
@@ -106,7 +130,7 @@ testPython3_7_warn() {
106130
return
107131
fi
108132
compile "python3_7_warn"
109-
assertCaptured "Installing python-3.7.1"
133+
assertCaptured "Installing python-3.7.8"
110134
assertCaptured "security update!"
111135
assertCaptured "${LATEST_37}"
112136
assertCapturedSuccess
@@ -131,7 +155,7 @@ testPython3_8_warn() {
131155
return
132156
fi
133157
compile "python3_8_warn"
134-
assertCaptured "Installing python-3.8.0"
158+
assertCaptured "Installing python-3.8.5"
135159
assertCaptured "security update!"
136160
assertCaptured "${LATEST_38}"
137161
assertCapturedSuccess
@@ -208,7 +232,7 @@ testPypy2_7_warn() {
208232
testStickyPythonVersion() {
209233
local cache_dir="$(mktmpdir)"
210234
compile "python3_6_warn" "$cache_dir"
211-
assertCaptured "Installing python-3.6.7"
235+
assertCaptured "Installing python-3.6.11"
212236
assertCapturedSuccess
213237
compile "python_version_unspecified" "$cache_dir"
214238
assertNotCaptured "Installing python"
@@ -217,16 +241,16 @@ testStickyPythonVersion() {
217241
# Whilst this file seems like an implementation detail (so something that should
218242
# not be tested), we must guarantee the filename remains consistent for backwards
219243
# compatibility across buildpack versions for already-built apps.
220-
assertFile "python-3.6.7" ".heroku/python-version"
244+
assertFile "python-3.6.11" ".heroku/python-version"
221245
}
222246

223247
testPythonVersionChange() {
224248
local cache_dir="$(mktmpdir)"
225249
compile "python3_6_warn" "$cache_dir"
226-
assertCaptured "Installing python-3.6.7"
250+
assertCaptured "Installing python-3.6.11"
227251
assertCapturedSuccess
228252
compile "python3_6" "$cache_dir"
229-
assertCaptured "Found python-3.6.7, removing"
253+
assertCaptured "Found python-3.6.11, removing"
230254
assertCapturedSuccess
231255
}
232256

0 commit comments

Comments
 (0)