Compare commits

..

9 Commits

Author SHA1 Message Date
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
13 changed files with 56 additions and 58 deletions
+17 -1
View File
@@ -1,8 +1,24 @@
# Python Buildpack Changelog # Python Buildpack Changelog
# 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 # 111
Linting , bugfixes. Linting, bugfixes.
# 110 # 110
+7 -9
View File
@@ -4,7 +4,7 @@
[![Build Status](https://travis-ci.org/heroku/heroku-buildpack-python.svg?branch=master)](https://travis-ci.org/heroku/heroku-buildpack-python) [![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. 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.
@@ -16,7 +16,7 @@ See it in Action
Deploying a Python application couldn't be easier: Deploying a Python application couldn't be easier:
$ ls $ ls
Procfile requirements.txt web.py Pipfile Procfile web.py
$ heroku create --buildpack heroku/python $ heroku create --buildpack heroku/python
@@ -24,16 +24,14 @@ Deploying a Python application couldn't be easier:
... ...
-----> Python app detected -----> Python app detected
-----> Installing python-3.6.2 -----> Installing python-3.6.2
$ pip install -r requirements.txt -----> Installing pip
Collecting requests (from -r requirements.txt (line 1)) -----> Installing requirements with latest pipenv...
Downloading requests-2.12.4-py2.py3-none-any.whl (576KB) ...
Installing collected packages: requests Installing dependencies from Pipfile...
Successfully installed requests-2.12.4
-----> Discovering process types -----> Discovering process types
Procfile declares types -> (none) 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: You can also specify the latest production release of this buildpack for upcoming builds of an existing application:
+11 -11
View File
@@ -182,7 +182,7 @@ source "$BIN_DIR/steps/cryptography"
# Support for Geo libraries. # Support for Geo libraries.
# shellcheck source=bin/steps/geo-libs # shellcheck source=bin/steps/geo-libs
sub-env "$BIN_DIR/steps/geo-libs" sub_env "$BIN_DIR/steps/geo-libs"
# GDAL support. # GDAL support.
# shellcheck source=bin/steps/gdal # shellcheck source=bin/steps/gdal
@@ -202,7 +202,7 @@ mtime "pip.install.time" "${start}"
# Support for NLTK corpora. # Support for NLTK corpora.
let start=$(nowms) let start=$(nowms)
sub-env "$BIN_DIR/steps/nltk" sub_env "$BIN_DIR/steps/nltk"
mtime "nltk.download.time" "${start}" mtime "nltk.download.time" "${start}"
# Support for pip install -e. # Support for pip install -e.
@@ -215,20 +215,20 @@ fi
# Django collectstatic support. # Django collectstatic support.
let start=$(nowms) let start=$(nowms)
sub-env "$BIN_DIR/steps/collectstatic" sub_env "$BIN_DIR/steps/collectstatic"
mtime "collectstatic.time" "${start}" mtime "collectstatic.time" "${start}"
# Create .profile script for application runtime environment variables. # Create .profile script for application runtime environment variables.
set-env PATH "\$HOME/.heroku/python/bin:\$PATH" set_env PATH "\$HOME/.heroku/python/bin:\$PATH"
set-env PYTHONUNBUFFERED true set_env PYTHONUNBUFFERED true
set-env PYTHONHOME /app/.heroku/python set_env PYTHONHOME /app/.heroku/python
set-env LIBRARY_PATH "/app/.heroku/vendor/lib:/app/.heroku/python/lib:\$LIBRARY_PATH" 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_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 LANG en_US.UTF-8
set-default-env PYTHONHASHSEED random set_default_env PYTHONHASHSEED random
set-default-env PYTHONPATH /app/ set_default_env PYTHONPATH /app/
# Install sane-default script for $WEB_CONCURRENCY and $FORWARDED_ALLOW_IPS. # 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/WEB_CONCURRENCY.sh" "$WEB_CONCURRENCY_PROFILE_PATH"
+1 -1
View File
@@ -3,5 +3,5 @@
if [ -f bin/post_compile ]; then if [ -f bin/post_compile ]; then
echo "-----> Running post-compile hook" echo "-----> Running post-compile hook"
chmod +x bin/post_compile chmod +x bin/post_compile
sub-env bin/post_compile sub_env bin/post_compile
fi fi
+1 -1
View File
@@ -3,5 +3,5 @@
if [ -f bin/pre_compile ]; then if [ -f bin/pre_compile ]; then
echo "-----> Running pre-compile hook" echo "-----> Running pre-compile hook"
chmod +x bin/pre_compile chmod +x bin/pre_compile
sub-env bin/pre_compile sub_env bin/pre_compile
fi fi
+4 -5
View File
@@ -21,15 +21,14 @@ if sp-grep -s nltk; then
if [ -f "$nltk_packages_definition" ]; then if [ -f "$nltk_packages_definition" ]; then
nltk_packages=$(tr "\n" " " < "$nltk_packages_definition") readarray -t nltk_packages < "$nltk_packages_definition"
puts-step "Downloading NLTK packages: $nltk_packages" puts-step "Downloading NLTK packages: ${nltk_packages[*]}"
python -m nltk.downloader -d "$BUILD_DIR/.heroku/python/nltk_data" "$nltk_packages" | indent python -m nltk.downloader -d "$BUILD_DIR/.heroku/python/nltk_data" "${nltk_packages[@]}" | indent
set-env NLTK_DATA "/app/.heroku/python/nltk_data" set_env NLTK_DATA "/app/.heroku/python/nltk_data"
else else
puts-warn "'nltk.txt' not found, not downloading any corpora" puts-warn "'nltk.txt' not found, not downloading any corpora"
puts-warn "Learn more: https://devcenter.heroku.com/articles/python-nltk" puts-warn "Learn more: https://devcenter.heroku.com/articles/python-nltk"
fi fi
fi fi
+4 -1
View File
@@ -6,7 +6,10 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then
puts-step "Installing requirements with pip" puts-step "Installing requirements with pip"
set +e set +e
sub-env /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 BLACKLIST='PYTHONHOME|PYTHONPATH'
export BLACKLIST
sub_env /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]}" PIP_STATUS="${PIPESTATUS[0]}"
set -e set -e
+1 -1
View File
@@ -9,7 +9,7 @@ if [[ -f Pipfile ]]; then
/app/.heroku/python/bin/pip install pipenv --upgrade &> /dev/null /app/.heroku/python/bin/pip install pipenv --upgrade &> /dev/null
# Install the dependencies. # Install the dependencies.
/app/.heroku/python/bin/pipenv install --system 2>&1 | indent /app/.heroku/python/bin/pipenv install --system --skip-lock 2>&1 | indent
# Skip pip install, later. # Skip pip install, later.
export SKIP_PIP_INSTALL=1 export SKIP_PIP_INSTALL=1
+1 -1
View File
@@ -2,7 +2,7 @@
# Detect Python-version with Pipenv. # 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/runtime.txt ]]; then
if [[ ! -f $BUILD_DIR/Pipfile.lock ]]; then if [[ ! -f $BUILD_DIR/Pipfile.lock ]]; then
+1 -25
View File
@@ -4,7 +4,7 @@ shopt -s nullglob
# The standard library. # The standard library.
if [[ ! -f /tmp/stdlib.sh ]]; then 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 fi
# shellcheck source=/dev/null # shellcheck source=/dev/null
source /tmp/stdlib.sh source /tmp/stdlib.sh
@@ -53,30 +53,6 @@ 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
# 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
"$@"
)
}
# Measure the size of the Python installation. # Measure the size of the Python installation.
measure-size() { 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}')"
+2 -1
View File
@@ -1 +1,2 @@
wordnet city_database
stopwords
+1 -1
View File
@@ -24,7 +24,7 @@ testGEOS() {
testNLTK() { testNLTK() {
compile "nltk" compile "nltk"
assertCaptured "wordnet" assertCaptured "Downloading NLTK packages: city_database stopwords"
assertCapturedSuccess assertCapturedSuccess
} }
+5
View File
@@ -150,6 +150,11 @@ _assertContains()
esac esac
fail "${msg:-${default_msg}}" fail "${msg:-${default_msg}}"
if [ "${haystack_type}" == "file" ]; then
echo
cat "${haystack}"
fi
fi fi
} }