Compare commits

...

40 Commits

Author SHA1 Message Date
kennethreitz 29775c020a changelog
Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-09-24 23:20:01 -04:00
kennethreitz 50950c59df Pipenv improvements (#474)
* improvements to pipenv

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* capitalize

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-09-24 23:18:22 -04:00
Johannes Hoppe 9817eb149e Update gdal to version 2.2.1 (#452) 2017-09-08 12:36:53 -04:00
Johannes Hoppe a703d2febe Update proj.4 to version 4.9.3 (#451) 2017-09-08 12:28:05 -04:00
Johannes Hoppe e304405410 Update geos to version 3.6.2 (#450) 2017-09-08 12:20:14 -04:00
kennethreitz 17f992a106 Improvements (#471)
* only do this on heroku-16

* history

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* code comment

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-09-08 12:02:03 -04:00
kennethreitz 24895082d3 update the changelog (#470) 2017-09-08 11:56:35 -04:00
Zach McCormick 002780c2d9 Adding step to copy libjasper to vendor lib directory so that libgdal will load (#449) 2017-09-08 11:43:28 -04:00
Ed Morley df7f8f3507 Skip vendoring libffi/libmemcached on Heroku-16 (#465)
* Add a test for the cryptography (cffi) compile step

Since it's currently untested.

* Skip vendoring libffi/libmemcached on Heroku-16

Unlike for Cedar-14, Heroku-16 comes with these packages pre-installed:
https://github.com/heroku/stack-images/blob/5a341970cfc1f201014262ad64c3b3e47514f663/heroku-16/installed-packages.txt#L111
https://github.com/heroku/stack-images/blob/5a341970cfc1f201014262ad64c3b3e47514f663/heroku-16/installed-packages.txt#L172

As such the build scripts had already been made a no-op on Heroku-16:
https://github.com/heroku/heroku-buildpack-python/blob/fedae5ceda5a42f594012f911c3808dd5dc6fd9e/builds/libraries/vendor/libffi#L6-L9
https://github.com/heroku/heroku-buildpack-python/blob/fedae5ceda5a42f594012f911c3808dd5dc6fd9e/builds/libraries/vendor/libmemcache#L6-L9

...meaning the Heroku-16 archives for them on S3 contain zero files.

However until now, the buildpack was still unnecessarily downloading
and extracting these empty archives - and not just on the first compile
(like on cedar-14), but every compile since the directory check will
never succeed.
2017-09-08 11:27:46 -04:00
Ed Morley 312a468cce Correct changelog entries for v108, v109 and v110 (#469)
Found by diffing the published buildpack archives and looking at the
git log to see what changed. It looks like the v108 entry was
accidentally added in #405, when the release being published there
was actually v107. The setuptools update mentioned there never
happened, since the `SETUPTOOLS_VERSION` variable was found to be
unused and instead removed.
2017-09-06 12:35:17 -04:00
kennethreitz d4b8c2aeda Undo sub_env for pip install, it was a terrible idea (#467)
* fixed the bug for pypy-5.8.0

* update changelog

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* blacklist for old apps

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* only blacklist pythonhome/path

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* updated changelog

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* be more agressive with blacklisting

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* sub_env was a terrible idea

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* changelog update

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-09-05 11:11:59 -04:00
kennethreitz f86e8079b6 Blacklist for old apps (#466)
* fixed the bug for pypy-5.8.0

* update changelog

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* blacklist for old apps

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* only blacklist pythonhome/path

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* updated changelog

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-09-05 10:44:08 -04:00
kennethreitz 36c6f5e388 Update README.md (#464) 2017-09-05 10:02:19 -04:00
kennethreitz 91a65b2984 Update README.md (#463) 2017-09-05 09:59:35 -04:00
kennethreitz 3010070d55 Update README.md (#462)
* Update README.md

* Update README.md

* Update README.md
2017-09-05 09:58:32 -04:00
Ed Morley fedae5ceda Tests: Make assertCaptured test failures easier to debug (#461)
Previously the contents of the file being searched was not output,
making it hard to know how to fix a test so that it would pass.

Before:
```
$ make test-heroku-16
...
testCffi
ASSERT:Expected </tmp/shunit.ayVGAO/tmp/output.6gMs/stdout> to contain <ZZZZZZZ>
testPylibmc
```

After:
```
$ make test-heroku-16
...
testCffi
ASSERT:Expected </tmp/shunit.FXWeuI/tmp/output.7Vfx/stdout> to contain <ZZZZZZZ>
 !     Warning: Your application is missing a Procfile. This file tells Heroku how to run your application.
 !     Learn more: https://devcenter.heroku.com/articles/procfile
-----> Installing python-3.6.2
-----> Installing pip
-----> Installing requirements with pip
       Collecting cffi (from -r /tmp/testBoLG0/requirements.txt (line 1))
         Downloading cffi-1.10.0-cp36-cp36m-manylinux1_x86_64.whl (406kB)
       Collecting pycparser (from cffi->-r /tmp/testBoLG0/requirements.txt (line 1))
         Downloading pycparser-2.18.tar.gz (245kB)
       Installing collected packages: pycparser, cffi
         Running setup.py install for pycparser: started
           Running setup.py install for pycparser: finished with status 'done'
       Successfully installed cffi-1.10.0 pycparser-2.18

testPylibmc
```
2017-09-05 09:43:17 -04:00
Ed Morley 4212e06309 NLTK support: Fix passing of multiple corpora identifiers (#460)
* NLTK support: Update test to use multiple corpora

So that the incorrect handling of multiple IDs seen in #444 would
have been caught.

Also switches to some of the smaller corpora, to reduce time spent
downloading during tests (see sizes on http://www.nltk.org/nltk_data/).

* NLTK support: Fix passing of multiple corpora identifiers

As part of fixing the shellcheck warnigns in #438, double quotes had
been placed around `$nltk_packages` passed to the `nltk.downloader`,
which causes multiple identifiers to be treated as though it were just
one identifier that contains spaces.

The docs for the shellcheck warning in question recommend using arrays
if the intended behaviour really is to split on spaces:
https://github.com/koalaman/shellcheck/wiki/SC2086#exceptions

As such, `readarray` has been used, which is present in bash >=4.
The `[*]` array form is used in the log message, to prevent shellcheck
warning SC2145, whereas `[@]` is used when passed to `nltk.downloader`
to ensure the array elements are unpacked as required.

Note: Both before and after this fix, using anything but unix line
endings in `nltk.txt` will also cause breakage.
2017-09-05 09:32:04 -04:00
kennethreitz fd360bda14 Update local commits (#459)
* fixed the bug for pypy-5.8.0

* update changelog

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-08-31 13:41:45 -04:00
kennethreitz 4723abb896 Pipenv Updates (#458)
* fixed the bug for pypy-5.8.0

* update pipenv support

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-08-31 13:18:26 -04:00
kennethreitz 155b5eecb9 Grep bug fix (#456)
* fixed the bug for pypy-5.8.0

* changelog entry

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* use std-lib sub-env

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* let's see if this cleans things up

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* try v7 of stdlib

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* use new sub_env

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* set_env

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* set_default_env

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* v8 of stdlib

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* v112

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* oops (merge bug)

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* final merge error resolve

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* final final fix for merge conflict

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-08-28 13:41:32 -04:00
kennethreitz 845635d667 Changelog (#454)
* fixed the bug for pypy-5.8.0

* changelog entry

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-08-24 17:28:25 -04:00
Samuel Spencer 0c26eae214 Allow environment variables during pip install, fixes #416 (#417)
* Allow environment variables during pip install, fixes #416

* shift sub-env command, fix typo

* bash check thingy fixed
2017-08-12 02:55:15 -04:00
Jeremy Morrell 325a3165e4 Remove leading zeros from WEB_CONCURRENCY (#446)
* Remove leading zeros from `WEB_CONCURRENCY`

* fix DYNO_RAM (from node buildpack)

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-08-10 14:42:45 -04:00
Ed Morley bf378916af Speed up the multi-stage Travis run (#443)
Reduces the impact on Travis runtime caused by #438, by:
* Making the shellcheck job run on the container infra (`sudo: false`)
  which has faster boot times.
* Running the heroku-16 and cedar-14 stack tests in parallel, since
  previously they were separate stages (which are run in series by
  design).

Reduces Travis end-to-end time from ~10 minutes to ~6 minutes.
2017-08-10 14:29:15 -04:00
Ed Morley c029e44dc8 Improve UX when clearing cache due to the stack changing (#442)
* Test that the cache is invalidated when the stack changes

* Improve UX when clearing cache due to the stack changing

Now outputs a message informing that the cache was cleared, and
clears the cache first to avoid a redundant message about removing
an old Python version.
2017-08-07 21:23:23 -04:00
kennethreitz f74d4db8c5 Shellcheck Compliance (#438)
* fixed the bug for pypy-5.8.0

* enable shellcheck in makefile

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* make compile script shellcheck compatible

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* let's see what this says

* fix pip installation

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck detect script

* shellcheck release

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck test-compile

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck warnings/utils

* updated makefile

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck collectstatic

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck cryptography

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck eggpath fixes

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck gdal

* shellcheck goes-libs

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck mercurial

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* nltk shellcheck

* shellcheck pip-install

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck pip-uninstall

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck pipenv

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck pylibmc

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* shellcheck python

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* update makefile

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* final update to makefile

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* fix tests

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* actually fix the tests

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* update pipenv-python-version

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* requested fixes

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* update spellcheck sources

* attempted fix for shell globbing

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* further attempted fix

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* switch nltk styling

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* no more need for temp app for installing pip

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* attempt at staged build for shellcheck

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* attempted fix of travis file

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* reorder travis file

* add shellcheck to install

* make things clearer in travis file

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* better travis file

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* attempt at better travis file

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* better travis file

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-08-03 17:36:23 -04:00
kennethreitz 2512694df9 Geos tests (#437)
* fixed the bug for pypy-5.8.0

* cleanup makefile

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* allow builds to happen when capitalization is used

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* restore behavior

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>

* make makefile default to heroku-16

* test geos libraries

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-08-02 19:59:44 -04:00
Johannes Hoppe f289984061 Update GDAL version to 1.11.5 (#432)
* Update GDAL version to 1.11.5

Update GDAL to latest bugfix release, see
http://trac.osgeo.org/gdal/wiki/Release/1.11.5-News

* Use pushd and popd in favor of cd
2017-08-01 14:33:23 -04:00
kennethreitz 1d37749ec1 fixed the bug for pypy-5.8.0 (#431) 2017-07-31 19:27:48 -04:00
Josh Friend da13bf1f3d Add pypy2-5.8.0 (#430) 2017-07-31 18:46:43 -04:00
Ed Morley 78767e7199 Exclude Python's test suite from generated Python archives (#425)
This copies the official Docker Python images approach of stripping
the Python test suite after building from source.

For Python 3.6.2 this reduces the output from 184MB to 121MB and
removes the following directories:
```
.heroku/python/lib/python3.6/tkinter/test
.heroku/python/lib/python3.6/ctypes/test
.heroku/python/lib/python3.6/unittest/test
.heroku/python/lib/python3.6/distutils/tests
.heroku/python/lib/python3.6/sqlite3/test
.heroku/python/lib/python3.6/lib2to3/tests
.heroku/python/lib/python3.6/test
```

For Python 2.7.13 this reduces the output from 127MB to 91MB and
removes the following directories:
```
.heroku/python/lib/python2.7/ctypes/test
.heroku/python/lib/python2.7/unittest/test
.heroku/python/lib/python2.7/distutils/tests
.heroku/python/lib/python2.7/bsddb/test
.heroku/python/lib/python2.7/lib-tk/test
.heroku/python/lib/python2.7/sqlite3/test
.heroku/python/lib/python2.7/lib2to3/tests
.heroku/python/lib/python2.7/json/tests
.heroku/python/lib/python2.7/email/test
.heroku/python/lib/python2.7/test
```

Fixes #424.
2017-07-17 13:00:47 -04:00
kennethreitz 194932889d Python 3.6.2 (#423)
* pypy3-5.8.0

* updated cpython to 3.6.2

* update README to reflect new Python version
2017-07-17 12:35:26 -04:00
Josh Friend 4293ec5564 Add CPython 3.6.2 (#422) 2017-07-17 11:48:05 -04:00
kennethreitz 57baab9f68 Update README.md (#415) 2017-06-20 10:43:51 -07:00
kennethreitz a7c20eea42 Python 3 default for buildpack (#409)
* update default python to 3.6.1

* v110

* nltk python2
2017-06-20 09:14:01 -07:00
kennethreitz 0a4cc2c476 pypy3-5.8.0 (#414) 2017-06-15 15:54:40 -04:00
Ed Morley cbb718bb8b Fix pip uninstall by moving it prior to pip install (#413)
The pip-uninstall step stopped working when it was moved to after
the pip-install step in f27a84e.

This regression was temporarily fixed by part of #397, however that
PR was reverted in #404.

Adds a test to hopefully catch any future regressions :-)

Fixes #393.
2017-06-14 17:15:52 -04:00
kennethreitz db95cdd3f3 new pylibmc test (#408) 2017-06-05 13:47:48 -04:00
kennethreitz 04f3ddbc86 updates (#407)
* silently use sp-grep

* history

* update license
2017-06-05 13:34:15 -04:00
kennethreitz f06f5676e8 silently use sp-grep (#406) 2017-06-05 13:31:57 -04:00
44 changed files with 420 additions and 206 deletions
+2
View File
@@ -1,3 +1,5 @@
*.pyc
site
.DS_Store
/.envrc
+22 -8
View File
@@ -1,9 +1,23 @@
language: bash
sudo: required
services:
- docker
# install: docker pull heroku/cedar:14
script: ./tests.sh
env:
- STACK=heroku-16
- STACK=cedar-14
dist: trusty
jobs:
include:
- stage: "Bash linting (shellcheck)"
sudo: false
addons:
apt:
sources:
- debian-sid # Grab shellcheck from the Debian repo (o_O)
packages:
- shellcheck
script: make check
- stage: "Stack Tests"
services: docker
env: STACK=heroku-16
script: ./tests.sh
- stage: "Stack Tests"
services: docker
env: STACK=cedar-14
script: ./tests.sh
+52 -1
View File
@@ -1,8 +1,59 @@
# Python Buildpack Changelog
# 118
Improvements to Pipenv support.
# 117
Bug fix.
# 116
Vendoring improvements.
- Geos libraries should work on Heroku-16 now.
- The libffi/libmemcached vendoring step is now skipped on Heroku-16 (since they are installed in the base image).
# 115
Revert a pull request.
- No longer using `sub_env` for `pip install` step.
# 114
- Bugfixes.
Blacklisting `PYTHONHOME` and `PYTHONPATH` for older apps. Upgrades to nltk support.
# 113
Updates to Pipenv support.
# 112
Bugfix.
- Fixed grep output bug.
# 111
Linting, bugfixes.
# 110
Update default Python to 3.6.2.
# 109
Update Default Python to 3.6.1, bugfixes.
- Fixed automatic pip uninstall of dependencies removed from requirements.txt.
# 108
Updated setuptools.
Fix output for collectstatic step.
# 107
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License:
Copyright (C) 2016 Heroku, Inc.
Copyright (C) 2017 Heroku, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+6 -1
View File
@@ -1,7 +1,12 @@
# These targets are not files
.PHONY: tests
test: test-cedar-14
test: test-heroku-16
check:
@shellcheck -x bin/compile bin/detect bin/release bin/test-compile bin/utils bin/warnings
@shellcheck -x bin/steps/collectstatic bin/steps/cryptography bin/steps/eggpath-fix bin/steps/eggpath-fix2 bin/steps/gdal bin/steps/geo-libs bin/steps/mercurial bin/steps/nltk bin/steps/pip-install bin/steps/pip-uninstall bin/steps/pipenv bin/steps/pipenv-python-version bin/steps/pylibmc bin/steps/python
@shellcheck -x bin/steps/hooks/*
test-cedar-14:
@echo "Running tests in docker (cedar-14)..."
+11 -13
View File
@@ -4,11 +4,11 @@
[![Build Status](https://travis-ci.org/heroku/heroku-buildpack-python.svg?branch=master)](https://travis-ci.org/heroku/heroku-buildpack-python)
This is the official [Heroku buildpack](https://devcenter.heroku.com/articles/buildpacks) for Python apps, powered by [pip](https://pip.pypa.io/) and other excellent software.
This is the official [Heroku buildpack](https://devcenter.heroku.com/articles/buildpacks) for Python apps, powered by [Pipenv](http://docs.pipenv.org/en/latest/), [pip](https://pip.pypa.io/) and other excellent software.
Recommended web frameworks include **Django** and **Flask**. The recommended webserver is **Gunicorn**. There are no restrictions around what software can be used (as long as it's pip-installable). Web processes must bind to `$PORT`, and only the HTTP protocol is permitted for incoming connections.
Some Python packages with obscure C dependencies (e.g. scipy) are [not compatible](https://devcenter.heroku.com/articles/python-c-deps).
Some Python packages with obscure C dependencies are [not compatible](https://devcenter.heroku.com/articles/python-c-deps).
See it in Action
----------------
@@ -16,24 +16,22 @@ See it in Action
Deploying a Python application couldn't be easier:
$ ls
Procfile requirements.txt web.py
Pipfile Procfile web.py
$ heroku create --buildpack heroku/python
$ git push heroku master
...
-----> Python app detected
-----> Installing python-2.7.13
$ pip install -r requirements.txt
Collecting requests (from -r requirements.txt (line 1))
Downloading requests-2.12.4-py2.py3-none-any.whl (576KB)
Installing collected packages: requests
Successfully installed requests-2.12.4
-----> Installing python-3.6.2
-----> Installing pip
-----> Installing requirements with latest pipenv...
...
Installing dependencies from Pipfile...
-----> Discovering process types
Procfile declares types -> (none)
A `requirements.txt` file must be present at the root of your application's repository.
A `Pipfile` or `requirements.txt` must be present at the root of your application's repository.
You can also specify the latest production release of this buildpack for upcoming builds of an existing application:
@@ -46,11 +44,11 @@ Specify a Python Runtime
Specific versions of the Python runtime can be specified with a `runtime.txt` file:
$ cat runtime.txt
python-3.6.1
python-2.7.13
Runtime options include:
- `python-3.6.2`
- `python-2.7.13`
- `python-3.6.1`
- `pypy-5.7.1` (unsupported, experimental)
- `pypy3-5.5.1` (unsupported, experimental)
+92 -67
View File
@@ -25,20 +25,24 @@ export BUILDPACK_LOG_FILE=${BUILDPACK_LOG_FILE:-/dev/null}
export PATH=:/usr/local/bin:$PATH
# Paths.
BIN_DIR=$(cd $(dirname $0); pwd) # absolute path
ROOT_DIR=$(dirname $BIN_DIR)
BIN_DIR=$(cd "$(dirname "$0")"; pwd) # absolute path
ROOT_DIR=$(dirname "$BIN_DIR")
BUILD_DIR=$1
CACHE_DIR=$2
ENV_DIR=$3
export BUILD_DIR CACHE_DIR ENV_DIR
# Python defaults
DEFAULT_PYTHON_VERSION="python-2.7.13"
DEFAULT_PYTHON_VERSION="python-3.6.2"
DEFAULT_PYTHON_STACK="cedar-14"
PYTHON_EXE="/app/.heroku/python/bin/python"
PIP_VERSION="9.0.1"
PIP_UPDATE="9.0.1"
export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE
# Common Problem Warnings
export WARNINGS_LOG=$(mktemp)
WARNINGS_LOG=$(mktemp)
export WARNINGS_LOG
export RECOMMENDED_PYTHON_VERSION=$DEFAULT_PYTHON_VERSION
# Setup vendored tools and pip-pop (pip-diff)
@@ -55,10 +59,12 @@ unset RECEIVE_DATA RUN_KEY BUILD_INFO DEPLOY LOG_TOKEN
unset CYTOKINE_LOG_FILE GEM_PATH
# Syntax sugar.
source $BIN_DIR/utils
# shellcheck source=bin/utils
source "$BIN_DIR/utils"
# Import collection of warnings.
source $BIN_DIR/warnings
# shellcheck source=bin/warnings
source "$BIN_DIR/warnings"
# we need to put a bunch of symlinks in there later
mkdir -p /app/.heroku
@@ -83,7 +89,7 @@ export LD_LIBRARY_PATH=/app/.heroku/vendor/lib:/app/.heroku/python/lib:$LD_LIBRA
export PKG_CONFIG_PATH=/app/.heroku/vendor/lib/pkg-config:/app/.heroku/python/lib/pkg-config:$PKG_CONFIG_PATH
# Switch to the repo's context.
cd $BUILD_DIR
cd "$BUILD_DIR"
# Warn for lack of Procfile.
if [[ ! -f Procfile ]]; then
@@ -92,60 +98,66 @@ if [[ ! -f Procfile ]]; then
fi
# Prepare the cache.
mkdir -p $CACHE_DIR
mkdir -p "$CACHE_DIR"
# Restore old artifacts from the cache.
mkdir -p .heroku
cp -R $CACHE_DIR/.heroku/python .heroku/ &> /dev/null || true
cp -R $CACHE_DIR/.heroku/python-stack .heroku/ &> /dev/null || true
cp -R $CACHE_DIR/.heroku/python-version .heroku/ &> /dev/null || true
cp -R $CACHE_DIR/.heroku/vendor .heroku/ &> /dev/null || true
if [[ -d $CACHE_DIR/.heroku/src ]]; then
cp -R $CACHE_DIR/.heroku/src .heroku/ &> /dev/null || true
cp -R "$CACHE_DIR/.heroku/python" .heroku/ &> /dev/null || true
cp -R "$CACHE_DIR/.heroku/python-stack" .heroku/ &> /dev/null || true
cp -R "$CACHE_DIR/.heroku/python-version" .heroku/ &> /dev/null || true
cp -R "$CACHE_DIR/.heroku/vendor" .heroku/ &> /dev/null || true
if [[ -d "$CACHE_DIR/.heroku/src" ]]; then
cp -R "$CACHE_DIR/.heroku/src" .heroku/ &> /dev/null || true
fi
# Experimental pre_compile hook.
source $BIN_DIR/steps/hooks/pre_compile
# shellcheck source=bin/steps/hooks/pre_compile
source "$BIN_DIR/steps/hooks/pre_compile"
# Sticky runtimes.
if [ -f $CACHE_DIR/.heroku/python-version ]; then
DEFAULT_PYTHON_VERSION=$(cat $CACHE_DIR/.heroku/python-version)
if [ -f "$CACHE_DIR/.heroku/python-version" ]; then
DEFAULT_PYTHON_VERSION=$(cat "$CACHE_DIR/.heroku/python-version")
fi
# Stack fallback for non-declared caches.
if [ -f $CACHE_DIR/.heroku/python-stack ]; then
CACHED_PYTHON_STACK=$(cat $CACHE_DIR/.heroku/python-stack)
if [ -f "$CACHE_DIR/.heroku/python-stack" ]; then
CACHED_PYTHON_STACK=$(cat "$CACHE_DIR/.heroku/python-stack")
else
CACHED_PYTHON_STACK=$STACK
fi
export CACHED_PYTHON_STACK
# Pipenv Python version support.
source $BIN_DIR/steps/pipenv-python-version
# shellcheck source=bin/steps/pipenv-python-version
source "$BIN_DIR/steps/pipenv-python-version"
# If no runtime given, assume default version.
if [ ! -f runtime.txt ]; then
echo $DEFAULT_PYTHON_VERSION > runtime.txt
echo "$DEFAULT_PYTHON_VERSION" > runtime.txt
fi
mkdir -p $(dirname $PROFILE_PATH)
mkdir -p "$(dirname "$PROFILE_PATH")"
mkdir -p /app/.heroku/src
if [[ $BUILD_DIR != '/app' ]]; then
# python expects to reside in /app, so set up symlinks
# we will not remove these later so subsequent buildpacks can still invoke it
ln -nsf $BUILD_DIR/.heroku/python /app/.heroku/python
ln -nsf $BUILD_DIR/.heroku/vendor /app/.heroku/vendor
ln -nsf "$BUILD_DIR/.heroku/python" /app/.heroku/python
ln -nsf "$BUILD_DIR/.heroku/vendor" /app/.heroku/vendor
# Note: .heroku/src is copied in later.
fi
# Install Python.
let start=$(nowms)
source $BIN_DIR/steps/python
# shellcheck source=bin/steps/python
source "$BIN_DIR/steps/python"
mtime "python.install.time" "${start}"
# Pipenv support.
source $BIN_DIR/steps/pipenv
# shellcheck source=bin/steps/pipenv
source "$BIN_DIR/steps/pipenv"
# If no requirements.txt file given, assume `setup.py develop` is intended.
if [ ! -f requirements.txt ] && [ ! -f Pipfile ]; then
@@ -153,88 +165,101 @@ if [ ! -f requirements.txt ] && [ ! -f Pipfile ]; then
fi
# Fix egg-links.
source $BIN_DIR/steps/eggpath-fix
# shellcheck source=bin/steps/eggpath-fix
source "$BIN_DIR/steps/eggpath-fix"
# Mercurial support.
source $BIN_DIR/steps/mercurial
# shellcheck source=bin/steps/mercurial
source "$BIN_DIR/steps/mercurial"
# Pylibmc support.
source $BIN_DIR/steps/pylibmc
# shellcheck source=bin/steps/pylibmc
source "$BIN_DIR/steps/pylibmc"
# Libffi support.
source $BIN_DIR/steps/cryptography
# shellcheck source=bin/steps/cryptography
source "$BIN_DIR/steps/cryptography"
# Support for Geo libraries.
sub-env $BIN_DIR/steps/geo-libs
# shellcheck source=bin/steps/geo-libs
sub_env "$BIN_DIR/steps/geo-libs"
# GDAL support.
source $BIN_DIR/steps/gdal
# Install dependencies with Pip (where the magic happens).
let start=$(nowms)
source $BIN_DIR/steps/pip-install
mtime "pip.install.time" "${start}"
# shellcheck source=bin/steps/gdal
source "$BIN_DIR/steps/gdal"
# Uninstall removed dependencies with Pip.
let start=$(nowms)
source $BIN_DIR/steps/pip-uninstall
# shellcheck source=bin/steps/pip-uninstall
source "$BIN_DIR/steps/pip-uninstall"
mtime "pip.uninstall.time" "${start}"
# Install dependencies with Pip (where the magic happens).
let start=$(nowms)
# shellcheck source=bin/steps/pip-install
source "$BIN_DIR/steps/pip-install"
mtime "pip.install.time" "${start}"
# Support for NLTK corpora.
let start=$(nowms)
sub-env $BIN_DIR/steps/nltk
sub_env "$BIN_DIR/steps/nltk"
mtime "nltk.download.time" "${start}"
# Support for pip install -e.
# In CI, $BUILD_DIR is /app.
if [[ ! "$BUILD_DIR" == "/app" ]]; then
rm -fr $BUILD_DIR/.heroku/src
deep-cp /app/.heroku/src $BUILD_DIR/.heroku/src
rm -fr "$BUILD_DIR/.heroku/src"
deep-cp /app/.heroku/src "$BUILD_DIR/.heroku/src"
fi
# Django collectstatic support.
let start=$(nowms)
sub-env $BIN_DIR/steps/collectstatic
sub_env "$BIN_DIR/steps/collectstatic"
mtime "collectstatic.time" "${start}"
# Create .profile script for application runtime environment variables.
set-env PATH '$HOME/.heroku/python/bin:$PATH'
set-env PYTHONUNBUFFERED true
set-env PYTHONHOME /app/.heroku/python
set-env LIBRARY_PATH '/app/.heroku/vendor/lib:/app/.heroku/python/lib:$LIBRARY_PATH'
set-env LD_LIBRARY_PATH '/app/.heroku/vendor/lib:/app/.heroku/python/lib:$LD_LIBRARY_PATH'
set-default-env LANG en_US.UTF-8
set-default-env PYTHONHASHSEED random
set-default-env PYTHONPATH /app/
set_env PATH "\$HOME/.heroku/python/bin:\$PATH"
set_env PYTHONUNBUFFERED true
set_env PYTHONHOME /app/.heroku/python
set_env LIBRARY_PATH "/app/.heroku/vendor/lib:/app/.heroku/python/lib:\$LIBRARY_PATH"
set_env LD_LIBRARY_PATH "/app/.heroku/vendor/lib:/app/.heroku/python/lib:\$LD_LIBRARY_PATH"
set_default_env LANG en_US.UTF-8
set_default_env PYTHONHASHSEED random
set_default_env PYTHONPATH /app/
# Install sane-default script for $WEB_CONCURRENCY and $FORWARDED_ALLOW_IPS.
cp $ROOT_DIR/vendor/WEB_CONCURRENCY.sh $WEB_CONCURRENCY_PROFILE_PATH
cp $ROOT_DIR/vendor/python.gunicorn.sh $GUNICORN_PROFILE_PATH
cp "$ROOT_DIR/vendor/WEB_CONCURRENCY.sh" "$WEB_CONCURRENCY_PROFILE_PATH"
cp "$ROOT_DIR/vendor/python.gunicorn.sh" "$GUNICORN_PROFILE_PATH"
# Experimental post_compile hook.
source $BIN_DIR/steps/hooks/post_compile
# shellcheck source=bin/steps/hooks/post_compile
source "$BIN_DIR/steps/hooks/post_compile"
# Fix egg-links, again.
source $BIN_DIR/steps/eggpath-fix2
# shellcheck source=bin/steps/eggpath-fix2
source "$BIN_DIR/steps/eggpath-fix2"
# Store new artifacts in cache.
rm -rf $CACHE_DIR/.heroku/python
rm -rf $CACHE_DIR/.heroku/python-version
rm -rf $CACHE_DIR/.heroku/python-stack
rm -rf $CACHE_DIR/.heroku/vendor
rm -rf $CACHE_DIR/.heroku/src
rm -rf "$CACHE_DIR/.heroku/python"
rm -rf "$CACHE_DIR/.heroku/python-version"
rm -rf "$CACHE_DIR/.heroku/python-stack"
rm -rf "$CACHE_DIR/.heroku/vendor"
rm -rf "$CACHE_DIR/.heroku/src"
mkdir -p $CACHE_DIR/.heroku
cp -R .heroku/python $CACHE_DIR/.heroku/
cp -R .heroku/python-version $CACHE_DIR/.heroku/
cp -R .heroku/python-stack $CACHE_DIR/.heroku/ &> /dev/null || true
cp -R .heroku/vendor $CACHE_DIR/.heroku/ &> /dev/null || true
mkdir -p "$CACHE_DIR/.heroku"
cp -R .heroku/python "$CACHE_DIR/.heroku/"
cp -R .heroku/python-version "$CACHE_DIR/.heroku/"
cp -R .heroku/python-stack "$CACHE_DIR/.heroku/" &> /dev/null || true
cp -R .heroku/vendor "$CACHE_DIR/.heroku/" &> /dev/null || true
if [[ -d .heroku/src ]]; then
cp -R .heroku/src $CACHE_DIR/.heroku/ &> /dev/null || true
cp -R .heroku/src "$CACHE_DIR/.heroku/" &> /dev/null || true
fi
# Measure the size of the Python installation.
# shellcheck disable=SC2119
mmeasure 'python.size' "$(measure-size)"
+1 -1
View File
@@ -15,7 +15,7 @@
BUILD_DIR=$1
# Exit early if app is clearly not Python.
if [ ! -f $BUILD_DIR/requirements.txt ] && [ ! -f $BUILD_DIR/setup.py ] && [ ! -f $BUILD_DIR/Pipfile ]; then
if [ ! -f "$BUILD_DIR/requirements.txt" ] && [ ! -f "$BUILD_DIR/setup.py" ] && [ ! -f "$BUILD_DIR/Pipfile" ]; then
exit 1
fi
+1 -2
View File
@@ -1,10 +1,9 @@
#!/usr/bin/env bash
# bin/release <build-dir>
BIN_DIR=$(cd $(dirname $0); pwd) # absolute path
BUILD_DIR=$1
MANAGE_FILE=$(cd $BUILD_DIR && find . -maxdepth 3 -type f -name 'manage.py' | head -1)
MANAGE_FILE=$(cd "$BUILD_DIR" && find . -maxdepth 3 -type f -name 'manage.py' | head -1)
MANAGE_FILE=${MANAGE_FILE:2}
cat <<EOF
+4 -3
View File
@@ -10,6 +10,7 @@
# - $DISABLE_COLLECTSTATIC: disables this functionality.
# - $DEBUG_COLLECTSTATIC: upon failure, print out environment variables.
# shellcheck source=bin/utils
source $BIN_DIR/utils
# Location of 'manage.py', if it exists.
@@ -20,7 +21,7 @@ MANAGE_FILE=${MANAGE_FILE:-fakepath}
[ -f .heroku/collectstatic_disabled ] && DISABLE_COLLECTSTATIC=1
# Ensure that Django is explicitly specified in requirements.txt
sp-grep django && DJANGO_INSTALLED=1
sp-grep -s django && DJANGO_INSTALLED=1
if [ ! "$DISABLE_COLLECTSTATIC" ] && [ -f "$MANAGE_FILE" ] && [ "$DJANGO_INSTALLED" ]; then
@@ -29,13 +30,13 @@ if [ ! "$DISABLE_COLLECTSTATIC" ] && [ -f "$MANAGE_FILE" ] && [ "$DJANGO_INSTALL
puts-step "$ python $MANAGE_FILE collectstatic --noinput"
# Run collectstatic, cleanup some of the noisy output.
python $MANAGE_FILE collectstatic --noinput --traceback 2>&1 | sed '/^Post-processed/d;/^Copying/d;/^$/d' | indent
python "$MANAGE_FILE" collectstatic --noinput --traceback 2>&1 | sed '/^Post-processed/d;/^Copying/d;/^$/d' | indent
COLLECTSTATIC_STATUS="${PIPESTATUS[0]}"
set -e
# Display a warning if collectstatic failed.
[ $COLLECTSTATIC_STATUS -ne 0 ] && {
[ "$COLLECTSTATIC_STATUS" -ne 0 ] && {
echo
echo " ! Error while running '$ python $MANAGE_FILE collectstatic --noinput'."
+11 -4
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# This script serves as the Cryptography build step of the
# This script serves as the cffi build step of the
# [**Python Buildpack**](https://github.com/heroku/heroku-buildpack-python)
# compiler.
#
@@ -9,13 +9,19 @@
#
# This script is invoked by [`bin/compile`](/).
if [[ "$STACK" == "heroku-16" ]]; then
# libffi is pre-installed in the stack image so there is no need to vendor it.
return 0
fi
# The location of the pre-compiled libffi binary.
VENDORED_LIBFFI="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/libffi.tar.gz"
PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
# Syntax sugar.
source $BIN_DIR/utils
# shellcheck source=bin/utils
source "$BIN_DIR/utils"
# If a package using cffi exists within requirements, use vendored libffi.
if (pip-grep -s requirements.txt argon2-cffi bcrypt cffi cryptography django[argon2] Django[argon2] django[bcrypt] Django[bcrypt] PyNaCl pyOpenSSL PyOpenSSL requests[security] misaka &> /dev/null) then
@@ -24,8 +30,9 @@ if (pip-grep -s requirements.txt argon2-cffi bcrypt cffi cryptography django[arg
echo "-----> Noticed cffi. Bootstrapping libffi."
mkdir -p .heroku/vendor
# Download and extract libffi into target vendor directory.
curl $VENDORED_LIBFFI -s | tar zxv -C .heroku/vendor &> /dev/null
curl "$VENDORED_LIBFFI" -s | tar zxv -C .heroku/vendor &> /dev/null
fi
export LIBFFI=$(pwd)/vendor
LIBFFI=$(pwd)/vendor
export LIBFFI
fi
+2
View File
@@ -1,3 +1,5 @@
#!/usr/bin/env bash
set +e
# delete any existing egg links, to uninstall exisisting installations.
find .heroku/python/lib/python*/site-packages/ -name "*.egg-link" -delete 2> /dev/null
+1
View File
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
set +e
# rewrite build dir in egg links to /app so things are found at runtime
find .heroku/python/lib/python*/site-packages/ -name "*.pth" -print0 2> /dev/null | xargs -r -0 -n 1 sed -i -e "s#$(pwd)#/app#" &> /dev/null
+5 -3
View File
@@ -15,7 +15,8 @@ VENDORED_GDAL="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/gdal
PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
# Syntax sugar.
source $BIN_DIR/utils
# shellcheck source=bin/utils
source "$BIN_DIR/utils"
# If GDAL exists within requirements, use vendored gdal.
if (pip-grep -s requirements.txt GDAL gdal pygdal &> /dev/null) then
@@ -24,9 +25,10 @@ if (pip-grep -s requirements.txt GDAL gdal pygdal &> /dev/null) then
echo "-----> Noticed GDAL. Bootstrapping gdal."
mkdir -p .heroku/vendor
# Download and extract cryptography into target vendor directory.
curl $VENDORED_GDAL -s | tar zxv -C .heroku/vendor &> /dev/null
curl "$VENDORED_GDAL" -s | tar zxv -C .heroku/vendor &> /dev/null
fi
export GDAL=$(pwd)/vendor
GDAL=$(pwd)/vendor
export GDAL
fi
+13 -5
View File
@@ -17,7 +17,8 @@ VENDORED_PROJ="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/proj
PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
# Syntax sugar.
source $BIN_DIR/utils
# shellcheck source=bin/utils
source "$BIN_DIR/utils"
# If GDAL exists within requirements, use vendored gdal.
if [[ "$BUILD_WITH_GEO_LIBRARIES" ]]; then
@@ -26,11 +27,18 @@ if [[ "$BUILD_WITH_GEO_LIBRARIES" ]]; then
echo "-----> Bootstrapping gdal, geos, proj."
mkdir -p .heroku/vendor
# Download and extract cryptography into target vendor directory.
curl $VENDORED_GDAL -s | tar zxv -C .heroku/vendor &> /dev/null
curl $VENDORED_GEOS -s | tar zxv -C .heroku/vendor &> /dev/null
curl $VENDORED_PROJ -s | tar zxv -C .heroku/vendor &> /dev/null
curl "$VENDORED_GDAL" -s | tar zxv -C .heroku/vendor &> /dev/null
curl "$VENDORED_GEOS" -s | tar zxv -C .heroku/vendor &> /dev/null
curl "$VENDORED_PROJ" -s | tar zxv -C .heroku/vendor &> /dev/null
# Copy libjasper from build image to slug.
if [[ "$STACK" == "heroku-16" ]]; then
cp /usr/lib/x86_64-linux-gnu/libjasper.so* ".heroku/vendor/lib/."
fi
fi
export GDAL=$(pwd)/vendor
GDAL=$(pwd)/vendor
export GDAL
fi
+1 -1
View File
@@ -3,5 +3,5 @@
if [ -f bin/post_compile ]; then
echo "-----> Running post-compile hook"
chmod +x bin/post_compile
sub-env bin/post_compile
sub_env bin/post_compile
fi
+1 -1
View File
@@ -3,5 +3,5 @@
if [ -f bin/pre_compile ]; then
echo "-----> Running pre-compile hook"
chmod +x bin/pre_compile
sub-env bin/pre_compile
sub_env bin/pre_compile
fi
+2
View File
@@ -1,3 +1,5 @@
#!/usr/bin/env bash
# Install Mercurial if it appears to be required.
if (grep -Fiq "hg+" requirements.txt) then
/app/.heroku/python/bin/pip install mercurial | cleanup | indent
+12 -8
View File
@@ -10,21 +10,25 @@
# This script is invoked by [`bin/compile`](/).
# Syntax sugar.
source $BIN_DIR/utils
# shellcheck source=bin/utils
source "$BIN_DIR/utils"
# Check that nltk was installed by pip, otherwise obviously not needed
python -m nltk.downloader -h >/dev/null 2>&1
if [ $? -eq 0 ]; then
if sp-grep -s nltk; then
puts-step "Downloading NLTK corpora..."
nltk_packages_definition="$BUILD_DIR/nltk.txt"
if [ -f "$nltk_packages_definition" ]; then
nltk_packages=$(tr "\n" " " < "$nltk_packages_definition")
puts-step "Downloading NLTK packages: $nltk_packages"
python -m nltk.downloader -d $BUILD_DIR/.heroku/python/nltk_data $nltk_packages | indent
set-env NLTK_DATA "/app/.heroku/python/nltk_data"
readarray -t nltk_packages < "$nltk_packages_definition"
puts-step "Downloading NLTK packages: ${nltk_packages[*]}"
python -m nltk.downloader -d "$BUILD_DIR/.heroku/python/nltk_data" "${nltk_packages[@]}" | indent
set_env NLTK_DATA "/app/.heroku/python/nltk_data"
else
puts-warn "'nltk.txt' not found, not downloading any corpora"
puts-warn "Learn more: https://devcenter.heroku.com/articles/python-nltk"
fi
fi
+5 -2
View File
@@ -1,10 +1,13 @@
#!/usr/bin/env bash
if [ ! "$SKIP_PIP_INSTALL" ]; then
# Install dependencies with Pip.
puts-step "Installing requirements with pip"
set +e
/app/.heroku/python/bin/pip install -r $BUILD_DIR/requirements.txt --exists-action=w --src=/app/.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | tee $WARNINGS_LOG | cleanup | indent
/app/.heroku/python/bin/pip install -r "$BUILD_DIR/requirements.txt" --exists-action=w --src=/app/.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | tee "$WARNINGS_LOG" | cleanup | indent
PIP_STATUS="${PIPESTATUS[0]}"
set -e
@@ -20,4 +23,4 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then
/app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
echo
fi
fi
+2
View File
@@ -1,3 +1,5 @@
#!/usr/bin/env bash
set +e
# Install dependencies with Pip.
+10 -3
View File
@@ -1,13 +1,20 @@
#!/usr/bin/env bash
# Pipenv support (Generate requriements.txt with pipenv).
if [[ -f Pipfile ]]; then
if [[ ! -f requirements.txt ]]; then
puts-step "Installing requirements with latest pipenv..."
puts-step "Installing requirements with latest Pipenv..."
# Install pipenv.
/app/.heroku/python/bin/pip install pipenv --upgrade &> /dev/null
if [[ ! -f Pipfile.lock ]]; then
/app/.heroku/python/bin/pipenv install --system --skip-lock 2>&1 | indent
else
/app/.heroku/python/bin/pipenv install --system 2>&1 | indent
fi
# Install the dependencies.
/app/.heroku/python/bin/pipenv install --system 2>&1 | indent
# Skip pip install, later.
export SKIP_PIP_INSTALL=1
@@ -16,4 +23,4 @@ if [[ -f Pipfile ]]; then
/app/.heroku/python/bin/pip freeze > requirements.txt
fi
fi
fi
+6 -4
View File
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
# Detect Python-version with Pipenv.
if [[ -f $BUILD_DIR/Pipfile.lock ]]; then
if [[ -f $BUILD_DIR/Pipfile ]]; then
if [[ ! -f $BUILD_DIR/runtime.txt ]]; then
if [[ ! -f $BUILD_DIR/Pipfile.lock ]]; then
@@ -8,14 +10,14 @@ if [[ -f $BUILD_DIR/Pipfile.lock ]]; then
fi
if [[ -f $BUILD_DIR/Pipfile.lock ]]; then
set +e
PYTHON=$(cat $BUILD_DIR/Pipfile.lock | jq '._meta.requires.python_version' -r)
PYTHON=$(jq -r '._meta.requires.python_version' "$BUILD_DIR/Pipfile.lock")
set -e
if [ "$PYTHON" = 2.7 ]; then
echo "python-2.7.13" > $BUILD_DIR/runtime.txt
echo "python-2.7.13" > "$BUILD_DIR/runtime.txt"
fi
if [ "$PYTHON" = 3.6 ]; then
echo "python-3.6.0" > $BUILD_DIR/runtime.txt
echo "python-3.6.2" > "$BUILD_DIR/runtime.txt"
fi
fi
fi
+10 -4
View File
@@ -9,12 +9,17 @@
#
# This script is invoked by [`bin/compile`](/).
if [[ "$STACK" == "heroku-16" ]]; then
# libmemcached is pre-installed in the stack image so there is no need to vendor it.
return 0
fi
# The location of the pre-compiled libmemcached binary.
VENDORED_MEMCACHED="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/libmemcache.tar.gz"
# Syntax sugar.
source $BIN_DIR/utils
# shellcheck source=bin/utils
source "$BIN_DIR/utils"
# If pylibmc exists within requirements, use vendored libmemcached.
if (pip-grep -s requirements.txt pylibmc &> /dev/null) then
@@ -23,8 +28,9 @@ if (pip-grep -s requirements.txt pylibmc &> /dev/null) then
echo "-----> Noticed pylibmc. Bootstrapping libmemcached."
mkdir -p .heroku/vendor
# Download and extract libmemcached into target vendor directory.
curl $VENDORED_MEMCACHED -s | tar zxv -C .heroku/vendor &> /dev/null
curl "$VENDORED_MEMCACHED" -s | tar zxv -C .heroku/vendor &> /dev/null
fi
export LIBMEMCACHED=$(pwd)/vendor
LIBMEMCACHED=$(pwd)/vendor
export LIBMEMCACHED
fi
+13 -18
View File
@@ -1,10 +1,16 @@
#!/usr/bin/env bash
set +e
runtime-fixer runtime.txt
PYTHON_VERSION=$(cat runtime.txt)
# Install Python.
if [[ "$STACK" != "$CACHED_PYTHON_STACK" ]]; then
puts-step "Stack has changed from $CACHED_PYTHON_STACK to $STACK, clearing cache"
rm -fr .heroku/python-stack .heroku/python-version .heroku/python .heroku/vendor
fi
if [ -f .heroku/python-version ]; then
if [ ! $(cat .heroku/python-version) = $PYTHON_VERSION ]; then
if [ ! "$(cat .heroku/python-version)" = "$PYTHON_VERSION" ]; then
puts-step "Found $(cat .heroku/python-version), removing"
rm -fr .heroku/python
else
@@ -12,41 +18,30 @@ if [ -f .heroku/python-version ]; then
fi
fi
if [ ! $STACK = $CACHED_PYTHON_STACK ]; then
rm -fr .heroku/python .heroku/python-stack .heroku/vendor
unset SKIP_INSTALL
fi
if [ ! "$SKIP_INSTALL" ]; then
puts-step "Installing $PYTHON_VERSION"
# Prepare destination directory.
mkdir -p .heroku/python
curl https://lang-python.s3.amazonaws.com/$STACK/runtimes/$PYTHON_VERSION.tar.gz -s | tar zxv -C .heroku/python &> /dev/null
mcount "version.python.$PYTHON_VERSION"
if [[ $? != 0 ]] ; then
if ! curl "https://lang-python.s3.amazonaws.com/$STACK/runtimes/$PYTHON_VERSION.tar.gz" -s | tar zxv -C .heroku/python &> /dev/null; then
puts-warn "Requested runtime ($PYTHON_VERSION) is not available for this stack ($STACK)."
puts-warn "Aborting. More info: https://devcenter.heroku.com/articles/python-support"
exit 1
fi
# Record for future reference.
echo $PYTHON_VERSION > .heroku/python-version
echo $STACK > .heroku/python-stack
echo "$PYTHON_VERSION" > .heroku/python-version
echo "$STACK" > .heroku/python-stack
FRESH_PYTHON=true
hash -r
fi
# If Pip isn't up to date:
if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then
WORKING_DIR=$(pwd)
TMPTARDIR=$(mktemp -d)
trap "rm -rf $TMPTARDIR" RETURN
if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_UPDATE* ]]; then
puts-step "Installing pip"
@@ -54,7 +49,7 @@ if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then
rm -fr /app/.heroku/python/lib/python2.7/site-packages/pip-*
rm -fr /app/.heroku/python/lib/python2.7/site-packages/setuptools-*
/app/.heroku/python/bin/python $ROOT_DIR/vendor/get-pip.py &> /dev/null
/app/.heroku/python/bin/python "$ROOT_DIR/vendor/get-pip.py" &> /dev/null
fi
+5 -3
View File
@@ -1,10 +1,12 @@
#!/usr/bin/env bash
# Syntax sugar.
BIN_DIR=$(cd $(dirname $0); pwd) # absolute path
source $BIN_DIR/utils
BIN_DIR=$(cd "$(dirname "$0")" || return; pwd) # absolute path
DISABLE_COLLECTSTATIC=1 "$(dirname ${0:-})/compile" "$1" "$2" "$3"
# shellcheck source=bin/utils
source "$BIN_DIR/utils"
DISABLE_COLLECTSTATIC=1 "$(dirname "${0:-}")/compile" "$1" "$2" "$3"
if [[ -f "$1/requirements-test.txt" ]]; then
/app/.heroku/python/bin/pip install -r "$1/requirements-test.txt" --exists-action=w --src=./.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | cleanup | indent
+7 -28
View File
@@ -1,13 +1,15 @@
#!/usr/bin/env bash
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/v2/stdlib.sh > /tmp/stdlib.sh
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
if [ $(uname) == Darwin ]; then
if [ "$(uname)" == Darwin ]; then
sed() { command sed -l "$@"; }
else
sed() { command sed -u "$@"; }
@@ -26,12 +28,12 @@ cleanup() {
# Buildpack Steps.
puts-step() {
echo "-----> $@"
echo "-----> $*"
}
# Buildpack Warnings.
puts-warn() {
echo " ! $@"
echo " ! $*"
}
# Does some serious copying.
@@ -51,31 +53,8 @@ deep-cp() {
}
sub-env() {
WHITELIST=${2:-''}
BLACKLIST=${3:-'^(GIT_DIR|STACK|PYTHONHOME|LD_LIBRARY_PATH|LIBRARY_PATH|PATH)$'}
# Python-specific variables.
export PYHONHOME=$BUILD_DIR/.heroku/python
export PYTHONPATH=$BUILD_DIR/
(
if [ -d "$ENV_DIR" ]; then
for e in $(ls $ENV_DIR); do
echo "$e" | grep -E "$WHITELIST" | grep -qvE "$BLACKLIST" &&
export "$e=$(cat $ENV_DIR/$e)"
:
done
fi
$1
)
}
# Measure the size of the Python installation.
measure-size() {
echo "$((du -s .heroku/python 2>/dev/null || echo 0) | awk '{print $1}')"
echo "$(du -s .heroku/python 2>/dev/null || echo 0) | awk '{print $1}')"
}
+1
View File
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
shopt -s extglob
old-platform() {
+4 -3
View File
@@ -10,14 +10,15 @@ hash -r
echo "Building gdal..."
SOURCE_TARBALL='http://download.osgeo.org/gdal/1.11.1/gdal-1.11.1.tar.gz'
VERSION="2.2.1"
SOURCE_TARBALL="http://download.osgeo.org/gdal/${VERSION}/gdal-${VERSION}.tar.gz"
curl -L $SOURCE_TARBALL | tar zx
cd gdal-1.11.1
pushd "gdal-${VERSION}"
./configure --prefix=$OUT_PREFIX --enable-static=no &&
make
make install
# Cleanup
cd ..
popd
+5 -3
View File
@@ -10,14 +10,16 @@ hash -r
echo "Building geos..."
SOURCE_TARBALL='http://download.osgeo.org/geos/geos-3.4.3.tar.bz2'
VERSION=3.6.2
SOURCE_TARBALL="http://download.osgeo.org/geos/geos-${VERSION}.tar.bz2"
curl -L $SOURCE_TARBALL | tar xj
cd geos-3.4.3
pushd "geos-${VERSION}"
./configure --prefix=$OUT_PREFIX --enable-static=no &&
make
make install
# Cleanup
cd ..
popd
+5 -4
View File
@@ -10,14 +10,15 @@ hash -r
echo "Building gdal..."
SOURCE_TARBALL='http://download.osgeo.org/proj/proj-4.8.0.tar.gz'
VERSION=4.9.3
SOURCE_TARBALL="http://download.osgeo.org/proj/proj-${VERSION}.tar.gz"
curl -L $SOURCE_TARBALL | tar zx
cd proj-4.8.0
./configure --prefix=$OUT_PREFIX --enable-static=no &&
pushd "proj-${VERSION}"
./configure --prefix=$OUT_PREFIX --enable-static=no
make
make install
# Cleanup
cd ..
popd
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Build Path: /app/.heroku/python/
# Build Deps: libraries/sqlite
OUT_PREFIX=$1
echo "Building PyPy..."
SOURCE_TARBALL='https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.8.0-linux64.tar.bz2'
curl -L $SOURCE_TARBALL | tar jx
cp -R pypy2-v5.8.0-linux64/* $OUT_PREFIX
ln $OUT_PREFIX/bin/pypy $OUT_PREFIX/bin/python
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Build Path: /app/.heroku/python/
# Build Deps: libraries/sqlite
OUT_PREFIX=$1
echo "Building PyPy..."
SOURCE_TARBALL='https://bitbucket.org/pypy/pypy/downloads/pypy3-v5.8.0-linux64.tar.bz2'
curl -L $SOURCE_TARBALL | tar jx
cp -R pypy3-v5.8.0-linux64/* $OUT_PREFIX
ln $OUT_PREFIX/bin/pypy3 $OUT_PREFIX/bin/python
+4
View File
@@ -13,3 +13,7 @@ cd src
./configure --prefix=$OUT_PREFIX --enable-unicode=ucs4 --with-ensurepip=no
make
make install
# Remove unneeded test directories, similar to the official Docker Python images:
# https://github.com/docker-library/python
find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' +
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Build Path: /app/.heroku/python/
# Build Deps: libraries/sqlite
OUT_PREFIX=$1
echo "Building Python..."
SOURCE_TARBALL='https://python.org/ftp/python/3.6.2/Python-3.6.2.tgz'
curl -L $SOURCE_TARBALL | tar xz
mv Python-3.6.2 src
cd src
./configure --prefix=$OUT_PREFIX --with-ensurepip=no
make
make install
# Remove unneeded test directories, similar to the official Docker Python images:
# https://github.com/docker-library/python
find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' +
ln $OUT_PREFIX/bin/python3 $OUT_PREFIX/bin/python
+1
View File
@@ -0,0 +1 @@
cffi
+1
View File
@@ -0,0 +1 @@
django
+2 -1
View File
@@ -1 +1,2 @@
wordnet
city_database
stopwords
+1
View File
@@ -0,0 +1 @@
python-2.7.13
+1
View File
@@ -0,0 +1 @@
pylibmc
-1
View File
@@ -1 +0,0 @@
python-3.6.0
+41 -7
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
testPipenv() {
compile "pipenv"
assertCapturedSuccess
@@ -8,7 +7,7 @@ testPipenv() {
testPipenvVersion() {
compile "pipenv-version"
assertCaptured "3.6.0"
assertCaptured "3.6.2"
assertCapturedSuccess
}
@@ -17,13 +16,17 @@ testNoRequirements() {
assertCapturedError
}
testNLTK() {
compile "nltk"
assertCaptured "wordnet"
testGEOS() {
BUILD_WITH_GEO_LIBRARIES=1 compile "geos"
assertCaptured "geos"
assertCapturedSuccess
}
testNLTK() {
compile "nltk"
assertCaptured "Downloading NLTK packages: city_database stopwords"
assertCapturedSuccess
}
testSetupPy() {
compile "setup-py"
@@ -44,6 +47,18 @@ testPsycopg2() {
assertCapturedSuccess
}
testCffi() {
compile "cffi"
assertCaptured "cffi"
assertCapturedSuccess
}
testPylibmc() {
compile "pylibmc"
assertCaptured "pylibmc"
assertCapturedSuccess
}
testPython2() {
compile "python2"
assertCaptured "python-2.7.13"
@@ -52,11 +67,30 @@ testPython2() {
testPython3() {
compile "python3"
assertCaptured "python-3.6.0"
assertCaptured "python-3.6.2"
assertCapturedSuccess
}
testSmartRequirements() {
local cache_dir="$(mktmpdir)"
compile "requirements-standard" "$cache_dir"
assertFile "requests" ".heroku/python/requirements-declared.txt"
assertCapturedSuccess
compile "psycopg2" "$cache_dir"
assertCaptured "Uninstalling requests"
assertFile "psycopg2" ".heroku/python/requirements-declared.txt"
assertCapturedSuccess
}
testStackChange() {
local cache_dir="$(mktmpdir)"
mkdir -p "${cache_dir}/.heroku"
echo "different-stack" > "${cache_dir}/.heroku/python-stack"
compile "requirements-standard" "$cache_dir"
assertCaptured "clearing cache"
assertFile "$STACK" ".heroku/python-stack"
assertCapturedSuccess
}
pushd $(dirname 0) >/dev/null
+5
View File
@@ -150,6 +150,11 @@ _assertContains()
esac
fail "${msg:-${default_msg}}"
if [ "${haystack_type}" == "file" ]; then
echo
cat "${haystack}"
fi
fi
}
+6 -6
View File
@@ -5,25 +5,25 @@ case $(ulimit -u) in
# Standard-1X (+Free, +Hobby) Dyno
256)
export DYNO_RAM=512
export WEB_CONCURRENCY=${WEB_CONCURRENCY:-02}
export WEB_CONCURRENCY=${WEB_CONCURRENCY:-2}
;;
# Standard-2X Dyno
512)
export DYNO_RAM=1024
export WEB_CONCURRENCY=${WEB_CONCURRENCY:-04}
export WEB_CONCURRENCY=${WEB_CONCURRENCY:-4}
;;
# Performance-M Dyno
16384)
export DYNO_RAM=2560
export WEB_CONCURRENCY=${WEB_CONCURRENCY:-08}
export WEB_CONCURRENCY=${WEB_CONCURRENCY:-8}
;;
# Performance-L Dyno
32768)
export DYNO_RAM=6656
export WEB_CONCURRENCY=${WEB_CONCURRENCY:-011}
export DYNO_RAM=14336
export WEB_CONCURRENCY=${WEB_CONCURRENCY:-11}
;;
esac
esac