Skip to content

Commit dfb8185

Browse files
authored
Merge branch 'master' into patch-1
2 parents 3880b1a + 149c046 commit dfb8185

36 files changed

+644
-22838
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ repos/*
77

88
#Venv
99
buildpack/*
10+
11+
builds/dockerenv.staging*
12+
builds/dockerenv.production

.pre-commit-config.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
repos:
2-
- repo: git://github.com/detailyang/pre-commit-shell
3-
rev: 1.0.4
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
44
hooks:
5-
- id: shell-lint
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace

.travis.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
11
language: ruby
22
dist: trusty
33
sudo: required
4+
45
rvm:
56
- 2.4.4
67
before_script:
78
- gem install bundler -v 1.16.2
89
- bundle exec hatchet ci:setup
10+
11+
script:
12+
- docker build --pull --tag travis-build-cedar-14 --file $(pwd)/builds/cedar-14.Dockerfile .
13+
- docker run --rm -e "STACK=cedar-14" travis-build-cedar-14 bash $TESTFOLDER
14+
- docker build --pull --tag travis-build-heroku-16 --file $(pwd)/builds/heroku-16.Dockerfile .
15+
- docker run --rm -e "STACK=heroku-16" travis-build-heroku-16 bash $TESTFOLDER
16+
- docker build --pull --tag travis-build-heroku-18 --file $(pwd)/builds/heroku-18.Dockerfile .
17+
- docker run --rm -e "STACK=heroku-18" travis-build-heroku-18 bash $TESTFOLDER
18+
919
jobs:
1020
include:
1121
- stage: Bash linting (shellcheck)
1222
sudo: false
1323
script: make check
14-
- stage: Stack Unit Tests
15-
services: docker
16-
env: STACK=heroku-18
17-
script: "./tests.sh"
18-
- stage: Stack Unit Tests
19-
services: docker
20-
env: STACK=heroku-16
21-
script: "./tests.sh"
22-
- stage: Stack Unit Tests
23-
services: docker
24-
env: STACK=cedar-14
25-
script: "./tests.sh"
2624
- stage: Hatchet Integration
25+
if: branch = master
26+
name: Run Hatchet
2727
script: "bundle exec rspec"
2828
env:
29+
matrix:
30+
- TESTFOLDER=test/run-deps
31+
- TESTFOLDER=test/run-versions
32+
- TESTFOLDER=test/run-features
2933
global:
30-
- HATCHET_RETRIES=3
31-
- IS_RUNNING_ON_CI=true
32-
- HATCHET_APP_LIMIT=5
33-
- HATCHET_DEPLOY_STRATEGY=git
34-
- secure: yjtlPE5FbVxTKnjUy/tZUBgSEf4qADD3QOxtgziuid73S0U/1IEXlMGFULsQzIjtlHKmHeywZqpVVEpthIH4RuT7uoX1Pb7SSM/g0T8fT3VoEFbFK1uYl0oZQbUS4Klxv9tPiumj8if3m6ULEGIz1X0wZcMOC0tMLwVCnwmap0E=
35-
- secure: ZeFTHWwnpIKE9nAqs88ocmiQh7bKce84lilGm5J23nf3N6V4wNyLwqlkvsM008WGBCaOg9AUx7ZunasT0ANsR5gLP3eV2UUg7ILdRgV2Gy13eNRFheC4PHdN92RqQ3aKoqlIv2K999xlhVjod0NzhkQQXB6PddfQINbuU7ks6As=
34+
- HATCHET_RETRIES=3
35+
- IS_RUNNING_ON_CI=true
36+
- HATCHET_APP_LIMIT=5
37+
- HATCHET_DEPLOY_STRATEGY=git
38+
- secure: yjtlPE5FbVxTKnjUy/tZUBgSEf4qADD3QOxtgziuid73S0U/1IEXlMGFULsQzIjtlHKmHeywZqpVVEpthIH4RuT7uoX1Pb7SSM/g0T8fT3VoEFbFK1uYl0oZQbUS4Klxv9tPiumj8if3m6ULEGIz1X0wZcMOC0tMLwVCnwmap0E=
39+
- secure: ZeFTHWwnpIKE9nAqs88ocmiQh7bKce84lilGm5J23nf3N6V4wNyLwqlkvsM008WGBCaOg9AUx7ZunasT0ANsR5gLP3eV2UUg7ILdRgV2Gy13eNRFheC4PHdN92RqQ3aKoqlIv2K999xlhVjod0NzhkQQXB6PddfQINbuU7ks6As=

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Python Buildpack Changelog
22

3+
# Master
4+
5+
- Bump Hatchet tests to point at new default python version.
6+
7+
- Python 3.6.9 and 3.7.4 now available.
8+
9+
- Move get-pip utility to S3
10+
11+
- Build utility and documentation updates
12+
13+
--------------------------------------------------------------------------------
14+
15+
# 155 (2019-08-22)
16+
17+
add docs and make target for heroku-18 bob builds
18+
19+
# 154 (2019-07-17)
20+
21+
Fix python 3.5.7 formula actually building 3.7.2
22+
23+
# 153 (2019-06-21)
24+
25+
Hotfix for broken heroku-16 deploys
26+
327
# 152 (2019-04-04)
428

529
Python 3.7.3 now available.

Makefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# These targets are not files
22
.PHONY: tests
33

4-
test: test-heroku-18 test-heroku-16
4+
test: test-heroku-18 test-heroku-16 test-cedar-14
55

66
check:
77
@shellcheck -x bin/compile bin/detect bin/release bin/test-compile bin/utils bin/warnings bin/default_pythons
@@ -10,23 +10,23 @@ check:
1010

1111
test-cedar-14:
1212
@echo "Running tests in docker (cedar-14)..."
13-
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=cedar-14" heroku/cedar:14 bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run;'
13+
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=cedar-14" heroku/cedar:14 bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;'
1414
@echo ""
1515

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

2121
test-heroku-18:
2222
@echo "Running tests in docker (heroku-18)..."
23-
@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;'
23+
@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;'
2424
@echo ""
2525

2626
buildenv-heroku-16:
2727
@echo "Creating build environment (heroku-16)..."
2828
@echo
29-
@docker build --pull -t python-buildenv-heroku-16 .
29+
@docker build --pull -f $(shell pwd)/builds/heroku-16.Dockerfile -t python-buildenv-heroku-16 .
3030
@echo
3131
@echo "Usage..."
3232
@echo
@@ -36,6 +36,19 @@ buildenv-heroku-16:
3636
@echo
3737
@docker run -it --rm python-buildenv-heroku-16
3838

39+
buildenv-heroku-18:
40+
@echo "Creating build environment (heroku-18)..."
41+
@echo
42+
@docker build --pull -f $(shell pwd)/builds/heroku-18.Dockerfile -t python-buildenv-heroku-18 .
43+
@echo
44+
@echo "Usage..."
45+
@echo
46+
@echo " $$ export AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar # Optional unless deploying"
47+
@echo " $$ bob build runtimes/python-2.7.13"
48+
@echo " $$ bob deploy runtimes/python-2.7.13"
49+
@echo
50+
@docker run -it --rm python-buildenv-heroku-18
51+
3952
tools:
4053
git clone https://github.com/kennethreitz/pip-pop.git
4154
mv pip-pop/bin/* vendor/pip-pop/

bin/default_pythons

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22

3-
DEFAULT_PYTHON_VERSION="python-3.6.8"
4-
LATEST_36="python-3.6.8"
5-
LATEST_37="python-3.7.3"
3+
DEFAULT_PYTHON_VERSION="python-3.6.9"
4+
LATEST_36="python-3.6.9"
5+
LATEST_37="python-3.7.4"
66
LATEST_35="python-3.5.7"
77
LATEST_34="python-3.4.10"
88
LATEST_27="python-2.7.16"

bin/steps/python

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ if [ ! "$SKIP_INSTALL" ]; then
9797
hash -r
9898
fi
9999

100+
# Heroku uses the get-pip utility maintained by the Python community to vendor Pip.
101+
# https://github.com/pypa/get-pip
102+
GETPIP="https://lang-python.s3.amazonaws.com/etc/get-pip.py"
103+
104+
if ! curl "${GETPIP}" -o "$ROOT_DIR/get-pip.py"; then
105+
mcount "failure.python.get-pip"
106+
echo "Failed to pull down get-pip"
107+
exit 1
108+
fi
100109

101110
# If Pip isn't up to date:
102111
if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_UPDATE* ]]; then
@@ -107,7 +116,7 @@ if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_UPDATE* ]]; then
107116
rm -fr /app/.heroku/python/lib/python*/site-packages/pip-*
108117
rm -fr /app/.heroku/python/lib/python*/site-packages/setuptools-*
109118

110-
/app/.heroku/python/bin/python "$ROOT_DIR/vendor/get-pip.py" pip=="$PIP_UPDATE" &> /dev/null
119+
/app/.heroku/python/bin/python "$ROOT_DIR/get-pip.py" pip=="$PIP_UPDATE" &> /dev/null
111120
/app/.heroku/python/bin/pip install "$ROOT_DIR/vendor/setuptools-39.0.1-py2.py3-none-any.whl" &> /dev/null
112121
fi
113122

bin/steps/sqlite3

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ source "$BIN_DIR/utils"
66
sqlite3_version() {
77
if [ "$STACK" = "cedar-14" ]; then
88
SQLITE3_VERSION="3.8.2-1ubuntu2.2"
9+
elif [ "$STACK" = "heroku-16" ]; then
10+
SQLITE3_VERSION="3.11.0-1ubuntu1.2"
911
else
1012
SQLITE3_VERSION=${SQLITE3_VERSION:-$(dpkg -s libsqlite3-0 | grep Version | sed 's/Version: //')}
1113
fi

builds/README.md

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,57 @@
11
# Python Buildpack Binaries
22

3-
For Cedar-14 stack
4-
------------------
3+
## Building the Docker Images
54

6-
To get started with it, create an app on Heroku inside a clone of this repository, and set your S3 config vars:
5+
**After every change to your formulae, perform the following** from the root of the Git repository (not from `builds/`) to rebuild the images for each stack:
76

8-
$ heroku create --buildpack https://github.com/heroku/heroku-buildpack-python#not-heroku
9-
$ heroku config:set WORKSPACE_DIR=builds
10-
$ heroku config:set AWS_ACCESS_KEY_ID=<your_aws_key>
11-
$ heroku config:set AWS_SECRET_ACCESS_KEY=<your_aws_secret>
12-
$ heroku config:set S3_BUCKET=<your_s3_bucket_name>
7+
$ docker build --pull --tag heroku-python-build-cedar-14 --file $(pwd)/builds/cedar-14.Dockerfile .
8+
$ docker build --pull --tag heroku-python-build-heroku-16 --file $(pwd)/builds/heroku-16.Dockerfile .
9+
$ docker build --pull --tag heroku-python-build-heroku-18 --file $(pwd)/builds/heroku-18.Dockerfile .
1310

11+
## Using the Image
1412

15-
Then, shell into an instance and run a build by giving the name of the formula inside `builds`:
13+
You can e.g. `bash` into each of the images you built using their tag:
1614

17-
$ heroku run bash
18-
Running `bash` attached to terminal... up, run.6880
19-
~ $ bob build runtimes/python-2.7.6
15+
docker run --rm -ti heroku-python-build-cedar-14 bash
16+
docker run --rm -ti heroku-python-build-heroku-16 bash
17+
docker run --rm -ti heroku-python-build-heroku-18 bash
2018

21-
Fetching dependencies... found 2:
22-
- libraries/sqlite
19+
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`:
2320

24-
Building formula runtimes/python-2.7.6:
25-
=== Building Python 2.7.6
26-
Fetching Python v2.7.6 source...
27-
Compiling...
21+
docker run --rm -ti heroku-python-build-heroku-18 bob build runtimes/python-2.7.15
2822

29-
If this works, run `bob deploy` instead of `bob build` to have the result uploaded to S3 for you.
23+
In order to `bob deploy`, AWS credentials must be set up, as well as name and prefix of your custom S3 bucket (unless you're deploying to the Heroku production buckets that are pre-defined in each `Dockerfile`); see next section for details.
3024

31-
To speed things up drastically, it'll usually be a good idea to `heroku run bash --size PX` instead.
25+
## Configuration
3226

33-
For Heroku-16 stack
34-
-------------------
27+
File `dockerenv.default` contains a list of required env vars; most of these have default values defined in `Dockerfile`. You can copy this file to a location outside the buildpack and modify it with the values you desire and pass its location with `--env-file`, or pass the env vars to `docker run` using `--env`.
3528

36-
1. Ensure GNU Make and Docker are installed.
37-
2. From the root of the buildpack repository, run: `make buildenv-heroku-16`
38-
3. Follow the instructions displayed!
29+
Out of the box, each `Dockerfile` has the correct values predefined for `S3_BUCKET`, `S3_PREFIX`, and `S3_REGION`. If you're building your own packages, you'll likely want to change `S3_BUCKET` and `S3_PREFIX` to match your info. Instead of setting `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` into that file, you may also pass them to `docker run` through the environment, or explicitly using `--env`, in order to prevent accidental commits of credentials.
3930

31+
### Passing AWS credentials to the container
4032

41-
Enjoy :)
33+
If you want to deploy packages and thus need to pass `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`, you can either pass them explicitly, through your environment, or through an env file.
34+
35+
#### Passing credentials explicitly
36+
37+
docker run --rm -ti -e AWS_ACCESS_KEY_ID=... -e AWS_SECRET_ACCESS_KEY=... heroku-python-build-heroku-18 bash
38+
39+
#### Passing credentials through the environment
40+
41+
The two environment variables `AWS_ACCESS_KEY_ID`and `AWS_SECRET_ACCESS_KEY` are defined in `builds/dockerenv.default`, without values. This will cause Docker to "forward" values for these variables from the current environment, so you can pass them in:
42+
43+
AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... docker run --rm -ti --env-file=builds/dockerenv.default heroku-python-build-heroku-18 bash
44+
45+
or
46+
47+
export AWS_ACCESS_KEY_ID=...
48+
export AWS_SECRET_ACCESS_KEY=...
49+
docker run --rm -ti --env-file=builds/dockerenv.default heroku-python-build-heroku-18 bash
50+
51+
#### Passing credentials through a separate env file
52+
53+
This method is the easiest for users who want to build packages in their own S3 bucket, as they will have to adjust the `S3_BUCKET` and `S3_PREFIX` environment variable values anyway from their default values.
54+
55+
For this method, it is important to keep the credentials file in a location outside the buildpack, so that your credentials aren't accidentally committed. Copy `builds/dockerenv.default` **to a safe location outside the buildpack directory**, and insert your values for `AWS_ACCESS_KEY_ID`and `AWS_SECRET_ACCESS_KEY`.
56+
57+
docker run --rm -ti --env-file=../SOMEPATHOUTSIDE/s3.env heroku-python-build-heroku-18 bash
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
FROM heroku/heroku:18-build
1+
FROM heroku/cedar:14
22

33
WORKDIR /app
44
ENV WORKSPACE_DIR="/app/builds" \
55
S3_BUCKET="lang-python" \
6-
S3_PREFIX="heroku-18/"
6+
S3_PREFIX="cedar-14/" \
7+
DEBIAN_FRONTEND=noninteractive \
8+
STACK="cedar-14"
79

810
RUN apt-get update && apt-get install -y python-pip && rm -rf /var/lib/apt/lists/*
911

1012
COPY requirements.txt /app/
11-
RUN pip install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt
13+
RUN pip install -r /app/requirements.txt
1214

1315
COPY . /app

0 commit comments

Comments
 (0)