Skip to content

Commit 939594e

Browse files
authored
Merge branch 'master' into test-staged-binaries
2 parents d54da94 + 23adcc4 commit 939594e

File tree

19 files changed

+64
-43
lines changed

19 files changed

+64
-43
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# Master
44

55
- Test staged binaries on Travis
6-
- Refactor: use variable rather than hardcoded /app
6+
- Sqlite3 Update:
7+
- Add Tests
8+
- Test for Pysqlite
79
- Bug fix: pipenv no longer installs twice on CI
810

911
--------------------------------------------------------------------------------

bin/compile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export PATH=$PATH:$ROOT_DIR/vendor/:$ROOT_DIR/vendor/pip-pop
9090
unset GIT_DIR PYTHONHOME PYTHONPATH
9191
unset RECEIVE_DATA RUN_KEY BUILD_INFO DEPLOY LOG_TOKEN
9292
unset CYTOKINE_LOG_FILE GEM_PATH
93-
export PYTHONPATH="$BUILD_DIR"
9493

9594
# Import the utils script, which contains helper functions used throughout the buildpack.
9695
# shellcheck source=bin/utils
@@ -105,7 +104,7 @@ source "$BIN_DIR/warnings"
105104
# to `/app`.
106105
# Symlinks are required, since Python is not a portable installation.
107106
# More on this topic later.
108-
mkdir -p "BUILD_DIR/.heroku"
107+
mkdir -p /app/.heroku
109108

110109
# This buildpack programatically generates (or simply copies) a number of files for
111110
# buildpack machinery: an export script, and a number of `.profile.d` scripts. This
@@ -123,19 +122,19 @@ export BUILD_DIR CACHE_DIR BIN_DIR PROFILE_PATH EXPORT_PATH
123122
# Notes on each variable included.
124123

125124
# PATH is relatively obvious, we need to be able to execute 'python'.
126-
export PATH="$BUILD_DIR/.heroku/python/bin:$BUILD_DIR/.heroku/vendor/bin:$PATH"
125+
export PATH=/app/.heroku/python/bin:/app/.heroku/vendor/bin:$PATH
127126
# Tell Python to not buffer it's stdin/stdout.
128127
export PYTHONUNBUFFERED=1
129128
# Set the locale to a well-known and expected standard.
130129
export LANG=en_US.UTF-8
131130
# `~/.heroku/vendor` is an place where the buildpack may stick pre-build binaries for known
132131
# C dependencies (e.g. libmemcached on cedar-14). This section configures Python (GCC, more specifically)
133132
# and pip to automatically include these paths when building binaries.
134-
export C_INCLUDE_PATH="$BUILD_DIR/.heroku/vendor/include:$BUILD_DIR/.heroku/python/include:$C_INCLUDE_PATH"
135-
export CPLUS_INCLUDE_PATH="$BUILD_DIR/.heroku/vendor/include:$BUILD_DIR/.heroku/python/include:$CPLUS_INCLUDE_PATH"
136-
export LIBRARY_PATH="$BUILD_DIR/.heroku/vendor/lib:$BUILD_DIR/.heroku/python/lib:$LIBRARY_PATH"
137-
export LD_LIBRARY_PATH="$BUILD_DIR/.heroku/vendor/lib:$BUILD_DIR/.heroku/python/lib:$LD_LIBRARY_PATH"
138-
export PKG_CONFIG_PATH="$BUILD_DIR/.heroku/vendor/lib/pkg-config:$BUILD_DIR/.heroku/python/lib/pkg-config:$PKG_CONFIG_PATH"
133+
export C_INCLUDE_PATH=/app/.heroku/vendor/include:/app/.heroku/python/include:$C_INCLUDE_PATH
134+
export CPLUS_INCLUDE_PATH=/app/.heroku/vendor/include:/app/.heroku/python/include:$CPLUS_INCLUDE_PATH
135+
export LIBRARY_PATH=/app/.heroku/vendor/lib:/app/.heroku/python/lib:$LIBRARY_PATH
136+
export LD_LIBRARY_PATH=/app/.heroku/vendor/lib:/app/.heroku/python/lib:$LD_LIBRARY_PATH
137+
export PKG_CONFIG_PATH=/app/.heroku/vendor/lib/pkg-config:/app/.heroku/python/lib/pkg-config:$PKG_CONFIG_PATH
139138

140139
# The Application Code
141140
# --------------------
@@ -212,16 +211,15 @@ fi
212211
# Create the directory for .profile.d, if it doesn't exist.
213212
mkdir -p "$(dirname "$PROFILE_PATH")"
214213
# Create the directory for editable source code installation, if it doesn't exist.
215-
mkdir -p "$BUILD_DIR/.heroku/src"
214+
mkdir -p /app/.heroku/src
216215

217216
# On Heroku CI, builds happen in `/app`. Otherwise, on the Heroku platform,
218217
# they occur in a temp directory. Beacuse Python is not portable, we must create
219218
# symlinks to emulate that we are operating in `/app` during the build process.
220219
# This is (hopefully obviously) because apps end up running from `/app` in production.
221-
if [[ "$BUILD_DIR" != '/app' ]]; then
220+
if [[ $BUILD_DIR != '/app' ]]; then
222221
# python expects to reside in /app, so set up symlinks
223222
# we will not remove these later so subsequent buildpacks can still invoke it
224-
mkdir -p /app/.heroku
225223
ln -nsf "$BUILD_DIR/.heroku/python" /app/.heroku/python
226224
ln -nsf "$BUILD_DIR/.heroku/vendor" /app/.heroku/vendor
227225
# Note: .heroku/src is copied in later.
@@ -312,7 +310,8 @@ mtime "nltk.download.time" "${start}"
312310
# and copying it into the proper place (the logical place to do this was early, but it must be done here).
313311
# In CI, $BUILD_DIR is /app.
314312
if [[ ! "$BUILD_DIR" == "/app" ]]; then
315-
ln -nsf "$BUILD_DIR/.heroku/src" /app/.heroku/src
313+
rm -fr "$BUILD_DIR/.heroku/src"
314+
deep-cp /app/.heroku/src "$BUILD_DIR/.heroku/src"
316315
fi
317316

318317

@@ -344,12 +343,13 @@ set_default_env PYTHONHASHSEED random
344343
# Tell Python to look for Python modules in the /app dir. Don't change this.
345344
set_default_env PYTHONPATH "\$HOME"
346345

347-
# Python expects to be in "$BUILD_DIR," if at runtime, it is not, set
346+
# Python expects to be in /app, if at runtime, it is not, set
348347
# up symlinks… this can occur when the subdir buildpack is used.
349348
cat <<EOT >> "$PROFILE_PATH"
350-
if [[ \$HOME != "$BUILD_DIR" ]]; then
351-
ln -nsf "\$HOME/.heroku/python" "$BUILD_DIR/.heroku/python"
352-
ln -nsf "\$HOME/.heroku/vendor" "$BUILD_DIR/.heroku/vendor"
349+
if [[ \$HOME != "/app" ]]; then
350+
mkdir -p /app/.heroku
351+
ln -nsf "\$HOME/.heroku/python" /app/.heroku/python
352+
ln -nsf "\$HOME/.heroku/vendor" /app/.heroku/vendor
353353
fi
354354
EOT
355355

bin/steps/collectstatic

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ if [ ! "$DISABLE_COLLECTSTATIC" ] && [ -f "$MANAGE_FILE" ] && [ "$DJANGO_INSTALL
3030
puts-step "$ python $MANAGE_FILE collectstatic --noinput"
3131

3232
# Run collectstatic, cleanup some of the noisy output.
33-
PYTHONPATH=${PYTHONPATH:-$BUILD_DIR}
33+
PYTHONPATH=${PYTHONPATH:-.}
3434
export PYTHONPATH
3535

3636
# Create a temporary file for collecting the collectstaic logs.
3737
COLLECTSTATIC_LOG=$(mktemp)
38+
3839
python "$MANAGE_FILE" collectstatic --noinput --traceback 2>&1 | tee "$COLLECTSTATIC_LOG" | sed '/^Post-processed/d;/^Copying/d;/^$/d' | indent
3940
COLLECTSTATIC_STATUS="${PIPESTATUS[0]}"
4041

bin/steps/gdal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# The location of the pre-compiled cryptography binary.
1313
VENDORED_GDAL="${VENDOR_URL}/libraries/vendor/gdal.tar.gz"
1414

15-
PKG_CONFIG_PATH="$BUILD_DIR/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
15+
PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
1616

1717
# Syntax sugar.
1818
# shellcheck source=bin/utils

bin/steps/geo-libs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ VENDORED_GDAL="${VENDOR_URL}/libraries/vendor/gdal.tar.gz"
1414
VENDORED_GEOS="${VENDOR_URL}/libraries/vendor/geos.tar.gz"
1515
VENDORED_PROJ="${VENDOR_URL}/libraries/vendor/proj.tar.gz"
1616

17-
PKG_CONFIG_PATH="$BUILD_DIR/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
17+
PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
1818

1919
# Syntax sugar.
2020
# shellcheck source=bin/utils

bin/steps/mercurial

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Install Mercurial if it appears to be required.
44
if [[ -f "requirements.txt" ]]; then
55
if (grep -Fiq "hg+" requirements.txt) then
6-
"$BUILD_DIR/.heroku/python/bin/pip" install mercurial | cleanup | indent
6+
/app/.heroku/python/bin/pip install mercurial | cleanup | indent
77
mcount "steps.mercurial"
88
fi
99
fi

bin/steps/pip-install

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then
4141
if [ ! -f "$BUILD_DIR/.heroku/python/bin/pip" ]; then
4242
exit 1
4343
fi
44-
45-
"$BUILD_DIR/.heroku/python/bin/pip" install -r "$BUILD_DIR/requirements.txt" --exists-action=w --src="$BUILD_DIR/.heroku/src" --disable-pip-version-check --no-cache-dir 2>&1 | tee "$WARNINGS_LOG" | cleanup | indent
44+
/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
4645
PIP_STATUS="${PIPESTATUS[0]}"
4746
set -e
4847

@@ -55,15 +54,15 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then
5554

5655
# Smart Requirements handling
5756
cp requirements.txt .heroku/python/requirements-declared.txt
58-
"$BUILD_DIR/.heroku/python/bin/pip" freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
57+
/app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
5958

6059
echo
6160

6261
# Install test dependencies, for CI.
6362
if [ "$INSTALL_TEST" ]; then
6463
if [[ -f "$1/requirements-test.txt" ]]; then
6564
puts-step "Installing test dependencies…"
66-
"$BUILD_DIR/.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
65+
/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
6766
fi
6867
fi
6968
fi

bin/steps/pip-uninstall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then
2020

2121
if [[ -s .heroku/python/requirements-stale.txt ]]; then
2222
puts-step "Uninstalling stale dependencies"
23-
"$BUILD_DIR/.heroku/python/bin/pip" uninstall -r .heroku/python/requirements-stale.txt -y --exists-action=w --disable-pip-version-check | cleanup | indent
23+
/app/.heroku/python/bin/pip uninstall -r .heroku/python/requirements-stale.txt -y --exists-action=w --disable-pip-version-check | cleanup | indent
2424
fi
2525
fi
2626

bin/steps/pipenv

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if [[ -f Pipfile.lock ]]; then
1212
# Measure that we're using Pipenv.
1313
mcount "tool.pipenv"
1414

15-
# Don't skip installation if there are git deps.
15+
# Don't skip installation of there are git deps.
1616
if ! grep -q 'git' Pipfile.lock; then
1717
echo "Skipping installation, as Pipfile.lock hasn't changed since last deploy." | indent
1818

@@ -58,25 +58,26 @@ if [ ! "$SKIP_PIPENV_INSTALL" ]; then
5858
# Due to weird old pip behavior and pipenv behavior, pipenv upgrades pip
5959
# to latest if only --upgrade is specified. Specify upgrade strategy to
6060
# avoid this eager behavior.
61-
"$BUILD_DIR/.heroku/python/bin/pip" install pipenv==$PIPENV_VERSION --upgrade --upgrade-strategy only-if-needed &> /dev/null
61+
/app/.heroku/python/bin/pip install pipenv==$PIPENV_VERSION --upgrade --upgrade-strategy only-if-needed &> /dev/null
6262

6363
# Install the test dependencies, for CI.
6464
if [ "$INSTALL_TEST" ]; then
6565
puts-step "Installing test dependencies…"
66-
"$BUILD_DIR/.heroku/python/bin/pipenv" install --dev --system --deploy 2>&1 | cleanup | indent
66+
/app/.heroku/python/bin/pipenv install --dev --system --deploy 2>&1 | cleanup | indent
6767

6868
# Install the dependencies.
6969
elif [[ ! -f Pipfile.lock ]]; then
7070
puts-step "Installing dependencies with Pipenv $PIPENV_VERSION"
71-
"$BUILD_DIR/.heroku/python/bin/pipenv" install --system --skip-lock 2>&1 | indent
71+
/app/.heroku/python/bin/pipenv install --system --skip-lock 2>&1 | indent
72+
7273
else
7374
pipenv-to-pip Pipfile.lock > requirements.txt
7475
"$BIN_DIR/steps/pip-uninstall"
7576
cp requirements.txt .heroku/python/requirements-declared.txt
7677
openssl dgst -sha256 Pipfile.lock > .heroku/python/Pipfile.lock.sha256
7778

7879
puts-step "Installing dependencies with Pipenv $PIPENV_VERSION"
79-
"$BUILD_DIR/.heroku/python/bin/pipenv" install --system --deploy 2>&1 | indent
80+
/app/.heroku/python/bin/pipenv install --system --deploy 2>&1 | indent
8081
fi
8182
fi
8283
else

bin/steps/pipenv-python-version

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
# Detect Python-version with Pipenv.
44

5-
if [[ -f "$BUILD_DIR/Pipfile" ]]; then
5+
if [[ -f $BUILD_DIR/Pipfile ]]; then
66

7-
if [[ ! -f "$BUILD_DIR/runtime.txt" ]]; then
8-
if [[ ! -f "$BUILD_DIR/Pipfile.lock" ]]; then
7+
if [[ ! -f $BUILD_DIR/runtime.txt ]]; then
8+
if [[ ! -f $BUILD_DIR/Pipfile.lock ]]; then
99
puts-warn "No 'Pipfile.lock' found! We recommend you commit this into your repository."
1010
fi
11-
if [[ -f "$BUILD_DIR/Pipfile.lock" ]]; then
11+
if [[ -f $BUILD_DIR/Pipfile.lock ]]; then
1212
set +e
1313
PYTHON=$(jq -r '._meta.requires.python_full_version' "$BUILD_DIR/Pipfile.lock")
1414
if [[ "$PYTHON" != "null" ]]; then

0 commit comments

Comments
 (0)