Skip to content

Commit

Permalink
Add support for Heroku-20
Browse files Browse the repository at this point in the history
This adds support for generating binaries for the upcoming Heroku-20
stack, and testing them in CI.

The Heroku-20 Dockerfile is based on that for Heroku-18, but with:
* the unused `python-{pip-whl,setuptools,wheel}` dependencies removed
* `python-pip` replaced with `python3-pip` since the former does not
  exist on Ubuntu 20.04.

The switch to Python 3 pip in the builder image only affects bob-builder,
since everything else (such as pip-diff) runs against the Python binaries
downloaded as part of the compile.

bob-builder has been updated to v0.0.18 to pick up the Python 3 fixes in:
heroku-python/bob-builder#48

Before this is merged, the binaries will need to be built/uploaded using
the steps here:
https://github.com/heroku/heroku-buildpack-python/blob/master/builds/README.md

A decision will need to be made about whether to backfill older Python
versions, however for now we should at least provide the latest point
release of each supported Python branch:
https://devguide.python.org/#status-of-python-branches

Which are:
* `3.5.9`
* `3.6.10`
* `3.7.7`
* `3.8.2`

We'll also want to upload at least one version of PyPy, however the
current script is for the out of date `pypy3.6-7.2.0`, so we'll want to
generate newer binaries for all stacks, which is out of scope for now.

Refs W-7485877.
  • Loading branch information
edmorley committed Apr 27, 2020
1 parent c78ffd5 commit b508dac
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ script:
- docker run --rm -e "STACK=heroku-16" travis-build-heroku-16 bash $TESTFOLDER
- docker build --pull --tag travis-build-heroku-18 --file $(pwd)/builds/heroku-18.Dockerfile .
- docker run --rm -e "STACK=heroku-18" travis-build-heroku-18 bash $TESTFOLDER
- docker build --pull --tag travis-build-heroku-20 --file $(pwd)/builds/heroku-20.Dockerfile .
- docker run --rm -e "STACK=heroku-20" travis-build-heroku-20 bash $TESTFOLDER

jobs:
include:
Expand Down
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# These targets are not files
.PHONY: tests

test: test-heroku-18 test-heroku-16 test-cedar-14
test: test-heroku-20 test-heroku-18 test-heroku-16 test-cedar-14

check:
@shellcheck -x bin/compile bin/detect bin/release bin/test-compile bin/utils bin/warnings bin/default_pythons
Expand All @@ -23,6 +23,11 @@ test-heroku-18:
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-18" heroku/heroku:18-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;'
@echo ""

test-heroku-20:
@echo "Running tests in docker (heroku-20)..."
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-20" heroku/heroku:20-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;'
@echo ""

buildenv-heroku-16:
@echo "Creating build environment (heroku-16)..."
@echo
Expand All @@ -49,6 +54,19 @@ buildenv-heroku-18:
@echo
@docker run -it --rm python-buildenv-heroku-18

buildenv-heroku-20:
@echo "Creating build environment (heroku-20)..."
@echo
@docker build --pull -f $(shell pwd)/builds/heroku-20.Dockerfile -t python-buildenv-heroku-20 .
@echo
@echo "Usage..."
@echo
@echo " $$ export AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar # Optional unless deploying"
@echo " $$ bob build runtimes/python-2.7.13"
@echo " $$ bob deploy runtimes/python-2.7.13"
@echo
@docker run -it --rm python-buildenv-heroku-20

tools:
git clone https://github.com/kennethreitz/pip-pop.git
mv pip-pop/bin/* vendor/pip-pop/
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ make test
Or to test in a particular stack:

```
make test-heroku-20
make test-heroku-18
make test-heroku-16
```
Expand Down
2 changes: 2 additions & 0 deletions builds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$ docker build --pull --tag heroku-python-build-cedar-14 --file $(pwd)/builds/cedar-14.Dockerfile .
$ docker build --pull --tag heroku-python-build-heroku-16 --file $(pwd)/builds/heroku-16.Dockerfile .
$ docker build --pull --tag heroku-python-build-heroku-18 --file $(pwd)/builds/heroku-18.Dockerfile .
$ docker build --pull --tag heroku-python-build-heroku-20 --file $(pwd)/builds/heroku-20.Dockerfile .

## Using the Image

Expand All @@ -15,6 +16,7 @@ You can e.g. `bash` into each of the images you built using their tag:
docker run --rm -ti heroku-python-build-cedar-14 bash
docker run --rm -ti heroku-python-build-heroku-16 bash
docker run --rm -ti heroku-python-build-heroku-18 bash
docker run --rm -ti heroku-python-build-heroku-20 bash

You then have a shell where you can run `bob build`, `bob deploy`, and so forth. You can of course also invoke these programs directly with `docker run`:

Expand Down
19 changes: 19 additions & 0 deletions builds/heroku-20.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM heroku/heroku:20-build

WORKDIR /app
ENV WORKSPACE_DIR="/app/builds" \
S3_BUCKET="lang-python" \
S3_PREFIX="heroku-20/" \
DEBIAN_FRONTEND=noninteractive \
STACK="heroku-20"

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
libsqlite3-dev \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt /app/
RUN pip3 install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt

COPY . /app
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
docopt==0.6.2
bob-builder==0.0.17
boto==2.48.0
bob-builder==0.0.18
boto==2.49.0
19 changes: 3 additions & 16 deletions tests.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
#!/usr/bin/env bash

if [[ ! "$STACK" ]]; then
echo '$STACK must be set! (heroku-16 | cedar-14)'
if [[ -z "$STACK" ]]; then
echo '$STACK must be set! (eg: `STACK=heroku-18 ./tests.sh`)'
exit 1
fi

if [[ "$STACK" == "cedar-14" ]]; then
make test-cedar-14
exit $?
fi

if [[ "$STACK" == "heroku-16" ]]; then
make test-heroku-16
exit $?
fi

if [[ "$STACK" == "heroku-18" ]]; then
make test-heroku-18
exit $?
fi
make "test-${STACK}"

0 comments on commit b508dac

Please sign in to comment.