mirror of
https://github.com/kennethreitz/heroku-buildpack-python.git
synced 2026-06-05 23:10:16 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c9504ffd2e | |||
| 96822983ed | |||
| f9d5c0010d | |||
| 9b1a69a1b3 | |||
| 58dd638fb6 | |||
| ead59ac7ff | |||
| ac8fd555b8 | |||
| f825896c4e | |||
| fcf696b835 | |||
| a98ef91566 |
@@ -34,6 +34,10 @@ env:
|
||||
- STACK=heroku-18 TEST_CMD=test/run-deps
|
||||
- STACK=heroku-18 TEST_CMD=test/run-versions
|
||||
- STACK=heroku-18 TEST_CMD=test/run-features
|
||||
|
||||
- STACK=heroku-20 TEST_CMD=test/run-deps
|
||||
- STACK=heroku-20 TEST_CMD=test/run-versions
|
||||
- STACK=heroku-20 TEST_CMD=test/run-features
|
||||
global:
|
||||
- HATCHET_RETRIES=3
|
||||
- IS_RUNNING_ON_CI=true
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
## Unreleased
|
||||
|
||||
|
||||
## v184 (2020-10-21)
|
||||
|
||||
- Vendor buildpack-stdlib instead of fetching from S3 (#1100).
|
||||
- Fix metric names for metrics emitted within `sub_env` (#1099).
|
||||
|
||||
## v183 (2020-10-12)
|
||||
|
||||
- Add support for Heroku-20 (#968).
|
||||
|
||||
## v182 (2020-10-06)
|
||||
|
||||
- Python 3.9.0 is now available (CPython) (#1090).
|
||||
|
||||
+4
-4
@@ -3,17 +3,17 @@ GEM
|
||||
specs:
|
||||
diff-lcs (1.4.4)
|
||||
erubis (2.7.0)
|
||||
excon (0.76.0)
|
||||
excon (0.78.0)
|
||||
heroics (0.1.1)
|
||||
erubis (~> 2.0)
|
||||
excon
|
||||
moneta
|
||||
multi_json (>= 1.9.2)
|
||||
heroku_hatchet (7.3.0)
|
||||
heroku_hatchet (7.3.3)
|
||||
excon (~> 0)
|
||||
platform-api (~> 3)
|
||||
rrrretry (~> 1)
|
||||
thor (~> 0)
|
||||
thor (~> 1)
|
||||
threaded (~> 0)
|
||||
moneta (1.0.0)
|
||||
multi_json (1.15.0)
|
||||
@@ -43,7 +43,7 @@ GEM
|
||||
rspec-retry (0.6.2)
|
||||
rspec-core (> 3.3)
|
||||
rspec-support (3.9.3)
|
||||
thor (0.20.3)
|
||||
thor (1.0.1)
|
||||
threaded (0.0.4)
|
||||
|
||||
PLATFORMS
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
.PHONY: check test builder-image buildenv deploy-runtimes tools
|
||||
|
||||
STACK ?= heroku-18
|
||||
STACKS ?= cedar-14 heroku-16 heroku-18
|
||||
STACKS ?= cedar-14 heroku-16 heroku-18 heroku-20
|
||||
TEST_CMD ?= test/run-versions && test/run-features && test/run-deps
|
||||
ENV_FILE ?= builds/dockerenv.default
|
||||
BUILDER_IMAGE_PREFIX := heroku-python-build
|
||||
|
||||
+2
-4
@@ -15,10 +15,8 @@
|
||||
# Fail fast and fail hard.
|
||||
set -eo pipefail
|
||||
|
||||
# Boostrap the Buildpack Standard Library.
|
||||
# Disable unused env var warning since shellcheck doesn't know about the stdlib.
|
||||
# shellcheck disable=2034
|
||||
BPLOG_PREFIX="buildpack.python"
|
||||
# Used by buildpack-stdlib's metrics features.
|
||||
export BPLOG_PREFIX="buildpack.python"
|
||||
export BUILDPACK_LOG_FILE=${BUILDPACK_LOG_FILE:-/dev/null}
|
||||
|
||||
[ "$BUILDPACK_XTRACE" ] && set -o xtrace
|
||||
|
||||
+4
-1
@@ -21,8 +21,11 @@ source "$BIN_DIR/utils"
|
||||
# If GDAL exists within requirements, use vendored gdal.
|
||||
if (pip-grep -s requirements.txt GDAL gdal pygdal &> /dev/null) then
|
||||
|
||||
if [ ! -f ".heroku/vendor/bin/gdalserver" ]; then
|
||||
if [[ ! -f ".heroku/vendor/bin/gdalserver" && "${STACK}" == 'heroku-20' ]]; then
|
||||
puts-warn "The buildpack's built-in GDAL functonality is not supported on Heroku-20."
|
||||
puts-warn "Please use this buildpack instead: https://github.com/heroku/heroku-geo-buildpack"
|
||||
|
||||
elif [[ ! -f ".heroku/vendor/bin/gdalserver" ]]; then
|
||||
puts-warn "The vendored GDAL package in the Heroku Python Buildpack now deprecated."
|
||||
puts-warn "To enable GDAL use an alternative buildpack is available here - https://github.com/heroku/heroku-geo-buildpack"
|
||||
|
||||
|
||||
+5
-2
@@ -20,8 +20,11 @@ PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
# shellcheck source=bin/utils
|
||||
source "$BIN_DIR/utils"
|
||||
|
||||
# If GDAL exists within requirements, use vendored gdal.
|
||||
if [[ "$BUILD_WITH_GEO_LIBRARIES" ]]; then
|
||||
if [[ "$BUILD_WITH_GEO_LIBRARIES" && "${STACK}" == 'heroku-20' ]]; then
|
||||
puts-warn "The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality is not supported on Heroku-20."
|
||||
puts-warn "Please use this buildpack for GDAL, GEOS and PROJ: https://github.com/heroku/heroku-geo-buildpack"
|
||||
puts-warn "To hide this message, unset the BUILD_WITH_GEO_LIBRARIES variable using: heroku config:unset BUILD_WITH_GEO_LIBRARIES"
|
||||
elif [[ "$BUILD_WITH_GEO_LIBRARIES" ]]; then
|
||||
mcount "buildvar.BUILD_WITH_GEO_LIBRARIES"
|
||||
|
||||
puts-warn "The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality are now deprecated."
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
shopt -s extglob
|
||||
shopt -s nullglob
|
||||
|
||||
# The standard library.
|
||||
if [[ ! -f /tmp/stdlib.sh ]]; then
|
||||
curl --retry 3 -s https://lang-common.s3.amazonaws.com/buildpack-stdlib/v8/stdlib.sh > /tmp/stdlib.sh
|
||||
fi
|
||||
# shellcheck source=/dev/null
|
||||
source /tmp/stdlib.sh
|
||||
# This is necessary since this script is sometimes sourced from
|
||||
# subshells that don't have the variables from bin/compile.
|
||||
# Remove this once we no longer wrap all the things in `sub_env`.
|
||||
BIN_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
ROOT_DIR=$(dirname "${BIN_DIR}")
|
||||
# shellcheck source=vendor/buildpack-stdlib_v8.sh
|
||||
source "${ROOT_DIR}/vendor/buildpack-stdlib_v8.sh"
|
||||
|
||||
if [ "$(uname)" == Darwin ]; then
|
||||
sed() { command sed -l "$@"; }
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
FROM heroku/heroku:20-build
|
||||
|
||||
ENV WORKSPACE_DIR="/app/builds" \
|
||||
S3_BUCKET="heroku-buildpack-python" \
|
||||
S3_PREFIX="heroku-20/" \
|
||||
STACK="heroku-20"
|
||||
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
||||
libsqlite3-dev \
|
||||
python3-pip \
|
||||
python3-setuptools \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt /app/
|
||||
RUN pip3 install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt
|
||||
|
||||
COPY . /app
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
python-3.6.6
|
||||
+1
-1
@@ -6,4 +6,4 @@ verify_ssl = true
|
||||
requests = "*"
|
||||
|
||||
[requires]
|
||||
python_full_version = "3.6.3"
|
||||
python_full_version = "3.7.8"
|
||||
|
||||
+2
-15
@@ -1,24 +1,11 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "22a052f4d1cfe6518b2f236fe45c3208c587a9ab1323bdd390632e27278b541e"
|
||||
},
|
||||
"host-environment-markers": {
|
||||
"implementation_name": "cpython",
|
||||
"implementation_version": "3.6.3",
|
||||
"os_name": "posix",
|
||||
"platform_machine": "x86_64",
|
||||
"platform_python_implementation": "CPython",
|
||||
"platform_release": "16.7.0",
|
||||
"platform_system": "Darwin",
|
||||
"platform_version": "Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64",
|
||||
"python_full_version": "3.6.3",
|
||||
"python_version": "3.6",
|
||||
"sys_platform": "darwin"
|
||||
"sha256": "8a36860f0f9cb55716222098062cea5c5e0f8127cafb9d0c694de327bac9fbc0"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_full_version": "3.6.3"
|
||||
"python_full_version": "3.7.8"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
pypy2.7-7.2.0
|
||||
pypy2.7-7.3.1
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
pypy3.6-7.2.0
|
||||
pypy3.6-7.3.1
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
requests
|
||||
@@ -1 +0,0 @@
|
||||
flask
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
flask
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
python-3.6.8
|
||||
python-3.6.12
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
requests
|
||||
+1
-1
@@ -1 +1 @@
|
||||
python-3.6.7
|
||||
python-3.6.11
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
python-3.7.2
|
||||
python-3.7.9
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
requests
|
||||
+1
-1
@@ -1 +1 @@
|
||||
python-3.7.1
|
||||
python-3.7.8
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
python-3.8.2
|
||||
python-3.8.6
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
requests
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
python-3.8.0
|
||||
python-3.8.5
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
flask
|
||||
+12
-16
@@ -21,16 +21,13 @@ testGEOS() {
|
||||
local env_dir="$(mktmpdir)"
|
||||
echo '1' > "${env_dir}/BUILD_WITH_GEO_LIBRARIES"
|
||||
compile 'geos' '' "${env_dir}"
|
||||
assertCaptured "geos"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testGEOSDeprecation() {
|
||||
local env_dir="$(mktmpdir)"
|
||||
echo '1' > "${env_dir}/BUILD_WITH_GEO_LIBRARIES"
|
||||
compile 'geos' '' "${env_dir}"
|
||||
assertCaptured " ! The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality are now deprecated.
|
||||
! An alternative buildpack to enable GDAL, GEOS and PROJ use is available here - https://github.com/heroku/heroku-geo-buildpack"
|
||||
if [[ $STACK == "heroku-20" ]]; then
|
||||
assertCaptured " ! The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality is not supported on Heroku-20."
|
||||
else
|
||||
assertCaptured " ! The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality are now deprecated."
|
||||
fi
|
||||
# This should assertCapturedError on Heroku-20, but the test doesn't actually
|
||||
# install anything that uses GEOS so succeeds (see W-8145375)
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
@@ -55,17 +52,16 @@ testPsycopg2() {
|
||||
}
|
||||
|
||||
testPysqlite() {
|
||||
# pysqlite does not support Python 3 (since the sqlite3 stdlib can be used there),
|
||||
# so we have to test with Python 2, which we've not made available for Heroku-20.
|
||||
if [[ $STACK == "heroku-20" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "pysqlite"
|
||||
assertCaptured "pysqlite"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testSqliteInstall() {
|
||||
compile "pythonDefault"
|
||||
assertNotCaptured "Sqlite3 failed to install."
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testCffi() {
|
||||
compile "cffi"
|
||||
assertCaptured "cffi"
|
||||
|
||||
+16
-6
@@ -59,24 +59,33 @@ testPipenvLock() {
|
||||
assertCapturedSuccessWithStdErr
|
||||
}
|
||||
|
||||
testPipenvVersion() {
|
||||
testPipenvPythonVersion3_6() {
|
||||
compile "pipenv-version"
|
||||
assertCaptured $DEFAULT_PYTHON_VERSION
|
||||
assertCaptured "Installing ${LATEST_36}"
|
||||
# Can't use `assertCapturedSuccess` since stderr contains:
|
||||
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
|
||||
assertCapturedSuccessWithStdErr
|
||||
}
|
||||
|
||||
testPipenvVersion2() {
|
||||
testPipenvPythonVersion2_7() {
|
||||
# Python 2.7 is EOL, so it has not been built for Heroku-20.
|
||||
if [[ $STACK == "heroku-20" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "pipenv-version2"
|
||||
assertCaptured $LATEST_27
|
||||
assertCaptured "Installing ${LATEST_27}"
|
||||
# Can't use `assertCapturedSuccess` since stderr contains:
|
||||
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
|
||||
assertCapturedSuccessWithStdErr
|
||||
}
|
||||
testPipenvFullVersion() {
|
||||
|
||||
testPipenvPythonFullVersion() {
|
||||
# Python 3.7+ requires newer libssl than is present on Cedar-14.
|
||||
if [[ "${STACK}" = "cedar-14" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "pipenv-full-version"
|
||||
assertCaptured "3.6.3"
|
||||
assertCaptured "3.7.8"
|
||||
# Can't use `assertCapturedSuccess` since stderr contains:
|
||||
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
|
||||
assertCapturedSuccessWithStdErr
|
||||
@@ -107,6 +116,7 @@ testHooks() {
|
||||
local expected_env_vars=(
|
||||
_
|
||||
BIN_DIR
|
||||
BPLOG_PREFIX
|
||||
BUILD_DIR
|
||||
BUILDPACK_LOG_FILE
|
||||
CACHE_DIR
|
||||
|
||||
+106
-93
@@ -4,59 +4,78 @@
|
||||
# shellcheck source=bin/default_pythons
|
||||
source "bin/default_pythons"
|
||||
|
||||
testPythonDefault() {
|
||||
updateVersion "pythonDefault" $DEFAULT_PYTHON_VERSION
|
||||
compile "pythonDefault"
|
||||
assertCaptured $DEFAULT_PYTHON_VERSION
|
||||
testPythonVersionUnspecified() {
|
||||
compile "python_version_unspecified"
|
||||
assertCaptured "Installing ${DEFAULT_PYTHON_VERSION}"
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPython2() {
|
||||
updateVersion "python2" $LATEST_27
|
||||
echo $LATEST_27 > "runtime.txt"
|
||||
compile "python2"
|
||||
assertCaptured $LATEST_27
|
||||
assertCaptured "python-2-7-eol-faq";
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 44.1.1 and wheel 0.34.2"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCapturedSuccess
|
||||
testPython2_7() {
|
||||
# Python 2.7 is EOL, so it has not been built for Heroku-20.
|
||||
if [[ $STACK == "heroku-20" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "python2"
|
||||
assertCaptured "Installing ${LATEST_27}"
|
||||
assertCaptured "python-2-7-eol-faq";
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 44.1.1 and wheel 0.34.2"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPython2_warn() {
|
||||
compile "python2_warn"
|
||||
assertCaptured "python-2.7.15"
|
||||
assertCaptured "python-2-7-eol-faq";
|
||||
assertCaptured "Only the latest version"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCapturedSuccess
|
||||
testPython2_7_warn() {
|
||||
# Python 2.7 is EOL, so it has not been built for Heroku-20.
|
||||
if [[ $STACK == "heroku-20" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "python2_warn"
|
||||
assertCaptured "Installing python-2.7.15"
|
||||
assertCaptured "python-2-7-eol-faq";
|
||||
assertCaptured "Only the latest version"
|
||||
assertCaptured "${LATEST_27}"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPython3_4() {
|
||||
# Python 3.4 is EOL, so it has not been built for Heroku-20.
|
||||
if [[ $STACK == "heroku-20" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "python3_4"
|
||||
assertCaptured $LATEST_34
|
||||
assertCaptured "Installing ${LATEST_34}"
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured "Installing pip 19.1.1, setuptools 43.0.0 and wheel 0.33.6"
|
||||
assertCaptured "Installing SQLite3"
|
||||
# Can't use `assertCapturedSuccess` since Pip outputs a Python 3.4 EOL warning to stderr,
|
||||
# and the newest Pip that works on Python 3.4 doesn't support `PIP_NO_PYTHON_VERSION_WARNING`.
|
||||
assertCapturedSuccessWithStdErr
|
||||
}
|
||||
|
||||
testPython3_4_warn() {
|
||||
# Python 3.4 is EOL, so it has not been built for Heroku-20.
|
||||
if [[ $STACK == "heroku-20" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "python3_4_warn"
|
||||
assertCaptured "python-3.4.9"
|
||||
assertCaptured "Installing python-3.4.9"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "${LATEST_34}"
|
||||
# Can't use `assertCapturedSuccess` since Pip outputs a Python 3.4 EOL warning to stderr,
|
||||
# and the newest Pip that works on Python 3.4 doesn't support `PIP_NO_PYTHON_VERSION_WARNING`.
|
||||
assertCapturedSuccessWithStdErr
|
||||
}
|
||||
|
||||
testPython3_5() {
|
||||
# Python 3.5 is EOL, so it has not been built for Heroku-20.
|
||||
if [[ $STACK == "heroku-20" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "python3_5"
|
||||
assertCaptured $LATEST_35
|
||||
assertCaptured "Installing ${LATEST_35}"
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2"
|
||||
assertCaptured "Installing SQLite3"
|
||||
@@ -64,16 +83,20 @@ testPython3_5() {
|
||||
}
|
||||
|
||||
testPython3_5_warn() {
|
||||
# Python 3.5 is EOL, so it has not been built for Heroku-20.
|
||||
if [[ $STACK == "heroku-20" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "python3_5_warn"
|
||||
assertCaptured "python-3.5.6"
|
||||
assertCaptured "Installing python-3.5.6"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "${LATEST_35}"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPython3_6() {
|
||||
updateVersion "python3_6" $LATEST_36
|
||||
compile "python3_6"
|
||||
assertCaptured $LATEST_36
|
||||
assertCaptured "Installing ${LATEST_36}"
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2"
|
||||
assertCaptured "Installing SQLite3"
|
||||
@@ -82,62 +105,60 @@ testPython3_6() {
|
||||
|
||||
testPython3_6_warn() {
|
||||
compile "python3_6_warn"
|
||||
assertCaptured "python-3.6.7"
|
||||
assertCaptured "Installing python-3.6.11"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCaptured "${LATEST_36}"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPython3_7() {
|
||||
updateVersion "python3_7" $LATEST_37
|
||||
compile "python3_7"
|
||||
if [[ $STACK = "cedar-14" ]]; then
|
||||
assertCapturedError
|
||||
else
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured $LATEST_37
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCapturedSuccess
|
||||
# Python 3.7+ requires newer libssl than is present on Cedar-14.
|
||||
if [[ "${STACK}" = "cedar-14" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "python3_7"
|
||||
assertCaptured "Installing ${LATEST_37}"
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPython3_7_warn() {
|
||||
compile "python3_7_warn"
|
||||
if [[ $STACK = "cedar-14" ]]; then
|
||||
assertCapturedError
|
||||
else
|
||||
assertCaptured "python-3.7.1"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCapturedSuccess
|
||||
# Python 3.7+ requires newer libssl than is present on Cedar-14.
|
||||
if [[ "${STACK}" = "cedar-14" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "python3_7_warn"
|
||||
assertCaptured "Installing python-3.7.8"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "${LATEST_37}"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPython3_8() {
|
||||
updateVersion "python3_8" $LATEST_38
|
||||
compile "python3_8"
|
||||
if [[ $STACK = "cedar-14" ]]; then
|
||||
assertCapturedError
|
||||
else
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured $LATEST_38
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCapturedSuccess
|
||||
# Python 3.7+ requires newer libssl than is present on Cedar-14.
|
||||
if [[ "${STACK}" = "cedar-14" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "python3_8"
|
||||
assertCaptured "Installing ${LATEST_38}"
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPython3_8_warn() {
|
||||
compile "python3_8_warn"
|
||||
if [[ $STACK = "cedar-14" ]]; then
|
||||
assertCapturedError
|
||||
else
|
||||
assertCaptured "python-3.8.0"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "Installing SQLite3"
|
||||
assertCapturedSuccess
|
||||
# Python 3.7+ requires newer libssl than is present on Cedar-14.
|
||||
if [[ "${STACK}" = "cedar-14" ]]; then
|
||||
return
|
||||
fi
|
||||
compile "python3_8_warn"
|
||||
assertCaptured "Installing python-3.8.5"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "${LATEST_38}"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPython3_9() {
|
||||
@@ -146,8 +167,8 @@ testPython3_9() {
|
||||
return
|
||||
fi
|
||||
compile "python3_9"
|
||||
assertCaptured "Installing ${LATEST_39}"
|
||||
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
|
||||
@@ -163,8 +184,9 @@ testPython3_9_warn() {
|
||||
return
|
||||
fi
|
||||
compile "python3_9_warn"
|
||||
assertCaptured "python-3.9.0"
|
||||
assertCaptured "Installing python-3.9.0"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "${LATEST_39}"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
@@ -177,67 +199,58 @@ testPythonVersionInvalid() {
|
||||
|
||||
testPypy3_6() {
|
||||
compile "pypy3_6"
|
||||
assertCaptured "Installing pypy"
|
||||
assertCaptured "Installing ${LATEST_PYPY_36}"
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured "$LATEST_PYPY_36"
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPypy3_6_warn() {
|
||||
compile "pypy3_6_warn"
|
||||
if [[ $STACK = "cedar-14" ]]; then
|
||||
assertCapturedError
|
||||
else
|
||||
assertCaptured "Installing pypy"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "$LATEST_PYPY_36"
|
||||
assertCapturedSuccess
|
||||
fi
|
||||
assertCaptured "Installing pypy3.6-7.3.1"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "${LATEST_PYPY_36}"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPypy2_7() {
|
||||
compile "pypy2_7"
|
||||
assertCaptured "Installing pypy"
|
||||
assertCaptured "Installing ${LATEST_PYPY_27}"
|
||||
assertNotCaptured "security update"
|
||||
assertCaptured "$LATEST_PYPY_27"
|
||||
assertCaptured "Installing pip 20.1.1, setuptools 44.1.1 and wheel 0.34.2"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testPypy2_7_warn() {
|
||||
compile "pypy2_7_warn"
|
||||
if [[ $STACK = "cedar-14" ]]; then
|
||||
assertCapturedError
|
||||
else
|
||||
assertCaptured "Installing pypy"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "$LATEST_PYPY_27"
|
||||
assertCapturedSuccess
|
||||
fi
|
||||
assertCaptured "Installing pypy2.7-7.3.1"
|
||||
assertCaptured "security update!"
|
||||
assertCaptured "${LATEST_PYPY_27}"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
testStickyPythonVersion() {
|
||||
local cache_dir="$(mktmpdir)"
|
||||
compile "python3_6_warn" "$cache_dir"
|
||||
assertCaptured "Installing python-3.6.7"
|
||||
assertCaptured "Installing python-3.6.11"
|
||||
assertCapturedSuccess
|
||||
compile "no-runtime-txt" "$cache_dir"
|
||||
assertCaptured "Installing python-3.6.7"
|
||||
compile "python_version_unspecified" "$cache_dir"
|
||||
assertNotCaptured "Installing python"
|
||||
assertCaptured "security update!"
|
||||
assertCapturedSuccess
|
||||
# Whilst this file seems like an implementation detail (so something that should
|
||||
# not be tested), we must guarantee the filename remains consistent for backwards
|
||||
# compatibility across buildpack versions for already-built apps.
|
||||
assertFile "python-3.6.7" ".heroku/python-version"
|
||||
assertFile "python-3.6.11" ".heroku/python-version"
|
||||
}
|
||||
|
||||
testPythonVersionChange() {
|
||||
local cache_dir="$(mktmpdir)"
|
||||
compile "python3_6_warn" "$cache_dir"
|
||||
assertCaptured "Installing python-3.6.7"
|
||||
assertCaptured "Installing python-3.6.11"
|
||||
assertCapturedSuccess
|
||||
compile "python3_6" "$cache_dir"
|
||||
assertCaptured "Found python-3.6.7, removing"
|
||||
assertCaptured "Found python-3.6.11, removing"
|
||||
assertCapturedSuccess
|
||||
}
|
||||
|
||||
|
||||
@@ -56,11 +56,6 @@ resetCapture()
|
||||
unset rtrn # deprecated
|
||||
}
|
||||
|
||||
updateVersion()
|
||||
{
|
||||
echo "$2" > "test/fixtures/${1}/runtime.txt"
|
||||
}
|
||||
|
||||
assertCapturedEquals()
|
||||
{
|
||||
assertEquals "$@" "$(cat ${STD_OUT})"
|
||||
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# From:
|
||||
# https://raw.githubusercontent.com/heroku/buildpack-stdlib/v8/stdlib.sh
|
||||
|
||||
# Buildpack defaults
|
||||
# ---------------
|
||||
|
||||
export BUILDPACK_LOG_FILE="${BUILDPACK_LOG_FILE:-/dev/null}"
|
||||
|
||||
# Standard Output
|
||||
# ---------------
|
||||
|
||||
# Buildpack Steps.
|
||||
puts_step() {
|
||||
if [[ "$*" == "-" ]]; then
|
||||
read -r output
|
||||
else
|
||||
output=$*
|
||||
fi
|
||||
echo -e "\\e[1m\\e[36m=== $output\\e[0m"
|
||||
unset output
|
||||
}
|
||||
|
||||
# Buildpack Error.
|
||||
puts_error() {
|
||||
if [[ "$*" == "-" ]]; then
|
||||
read -r output
|
||||
else
|
||||
output=$*
|
||||
fi
|
||||
echo -e "\\e[1m\\e[31m=!= $output\\e[0m"
|
||||
}
|
||||
|
||||
# Buildpack Warning.
|
||||
puts_warn() {
|
||||
if [[ "$*" == "-" ]]; then
|
||||
read -r output
|
||||
else
|
||||
output=$*
|
||||
fi
|
||||
echo -e "\\e[1m\\e[33m=!= $output\\e[0m"
|
||||
}
|
||||
|
||||
# Is verbose set?
|
||||
is_verbose() {
|
||||
if [[ -n $BUILDPACK_VERBOSE ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Buildpack Verbose.
|
||||
puts_verbose() {
|
||||
if is_verbose; then
|
||||
if [[ "$*" == "-" ]]; then
|
||||
read -r output
|
||||
else
|
||||
output=$*
|
||||
fi
|
||||
echo "$output"
|
||||
unset output
|
||||
fi
|
||||
}
|
||||
|
||||
# Buildpack Utilities
|
||||
# -------------------
|
||||
|
||||
# Usage: $ set-env key value
|
||||
# NOTICE: Expects PROFILE_PATH & EXPORT_PATH to be set!
|
||||
set_env() {
|
||||
# TODO: automatically create profile path directory if it doesn't exist.
|
||||
echo "export $1=$2" >> "$PROFILE_PATH"
|
||||
echo "export $1=$2" >> "$EXPORT_PATH"
|
||||
}
|
||||
|
||||
# Usage: $ set-default-env key value
|
||||
# NOTICE: Expects PROFILE_PATH & EXPORT_PATH to be set!
|
||||
set_default_env() {
|
||||
echo "export $1=\${$1:-$2}" >> "$PROFILE_PATH"
|
||||
echo "export $1=\${$1:-$2}" >> "$EXPORT_PATH"
|
||||
}
|
||||
|
||||
# Usage: $ un-set-env key
|
||||
# NOTICE: Expects PROFILE_PATH to be set!
|
||||
un_set_env() {
|
||||
echo "unset $1" >> "$PROFILE_PATH"
|
||||
}
|
||||
|
||||
# Usage: $ _env-blacklist pattern
|
||||
# Outputs a regex of default blacklist env vars.
|
||||
_env_blacklist() {
|
||||
local regex=${1:-''}
|
||||
if [ -n "$regex" ]; then
|
||||
regex="|$regex"
|
||||
fi
|
||||
echo "^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH$regex)$"
|
||||
}
|
||||
|
||||
# Usage: $ export-env ENV_DIR WHITELIST BLACKLIST
|
||||
# Exports the environment variables defined in the given directory.
|
||||
export_env() {
|
||||
local env_dir=${1:-$ENV_DIR}
|
||||
local whitelist=${2:-''}
|
||||
local blacklist
|
||||
blacklist="$(_env_blacklist "$3")"
|
||||
if [ -d "$env_dir" ]; then
|
||||
# Environment variable names won't contain characters affected by:
|
||||
# shellcheck disable=SC2045
|
||||
for e in $(ls "$env_dir"); do
|
||||
echo "$e" | grep -E "$whitelist" | grep -qvE "$blacklist" &&
|
||||
export "$e=$(cat "$env_dir/$e")"
|
||||
:
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Usage: $ sub-env command
|
||||
# Runs a subshell of specified command with user-provided config.
|
||||
# NOTICE: Expects ENV_DIR to be set. WHITELIST & BLACKLIST are optional.
|
||||
# Examples:
|
||||
# WHITELIST=${2:-''}
|
||||
# BLACKLIST=${3:-'^(GIT_DIR|PYTHONHOME|LD_LIBRARY_PATH|LIBRARY_PATH|PATH)$'}
|
||||
sub_env() {
|
||||
(
|
||||
# TODO: Fix https://github.com/heroku/buildpack-stdlib/issues/37
|
||||
# shellcheck disable=SC2153
|
||||
export_env "$ENV_DIR" "$WHITELIST" "$BLACKLIST"
|
||||
|
||||
"$@"
|
||||
)
|
||||
}
|
||||
|
||||
# Logging
|
||||
# -------
|
||||
|
||||
# Notice: These functions expect BPLOG_PREFIX and BUILDPACK_LOG_FILE to be defined (BUILDPACK_LOG_FILE can point to /dev/null if not provided by the buildpack).
|
||||
# Example: BUILDPACK_LOG_FILE=${BUILDPACK_LOG_FILE:-/dev/null}; BPLOG_PREFIX="buildpack.go"
|
||||
|
||||
# Returns now, in milleseconds. Useful for logging.
|
||||
# Example: $ let start=$(nowms); sleep 30; mtime "glide.install.time" "${start}"
|
||||
nowms() {
|
||||
date +%s%3N
|
||||
}
|
||||
|
||||
# Log arbitrary data to the logfile (e.g. a packaging file).
|
||||
# Usage: $ bplog "$(<${vendorJSON})
|
||||
bplog() {
|
||||
echo -n "${@}" | awk 'BEGIN {printf "msg=\""; f="%s"} {gsub(/"/, "\\\"", $0); printf f, $0} {if (NR == 1) f="\\n%s" } END { print "\"" }' >> "${BUILDPACK_LOG_FILE}"
|
||||
}
|
||||
|
||||
# Measures time elapsed for a specific build step.
|
||||
# Usage: $ let start=$(nowms); mtime "glide.install.time" "${start}"
|
||||
# https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#distributions-measure
|
||||
mtime() {
|
||||
local key="${BPLOG_PREFIX}.${1}"
|
||||
local start="${2}"
|
||||
local end="${3:-$(nowms)}"
|
||||
echo "${key} ${start} ${end}" | awk '{ printf "measure#%s=%.3f\n", $1, ($3 - $2)/1000 }' >> "${BUILDPACK_LOG_FILE}"
|
||||
}
|
||||
|
||||
# Logs a count for a specific built step.
|
||||
# Usage: $ mcount "tool.govendor"
|
||||
# https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#counting-count
|
||||
mcount() {
|
||||
local k="${BPLOG_PREFIX}.${1}"
|
||||
local v="${2:-1}"
|
||||
echo "count#${k}=${v}" >> "${BUILDPACK_LOG_FILE}"
|
||||
}
|
||||
|
||||
# Logs a measure for a specific build step.
|
||||
# Usage: $ mmeasure "tool.installed_dependencies" 42
|
||||
# https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#distributions-measure
|
||||
mmeasure() {
|
||||
local k="${BPLOG_PREFIX}.${1}"
|
||||
local v="${2}"
|
||||
echo "measure#${k}=${v}" >> "${BUILDPACK_LOG_FILE}"
|
||||
}
|
||||
|
||||
# Logs a unuique measurement build step.
|
||||
# Usage: $ munique "versions.count" 2.7.13
|
||||
# https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#uniques-unique
|
||||
munique() {
|
||||
local k="${BPLOG_PREFIX}.${1}"
|
||||
local v="${2}"
|
||||
echo "unique#${k}=${v}" >> "${BUILDPACK_LOG_FILE}"
|
||||
}
|
||||
|
||||
# Measures when an exit path to the buildpack is reached, given a name, then exits 1.
|
||||
# Usage: $ mcount-exi "binExists"
|
||||
mcount_exit() {
|
||||
mcount "error.${1}"
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user