@@ -90,6 +90,7 @@ export PATH=$PATH:$ROOT_DIR/vendor/:$ROOT_DIR/vendor/pip-pop
90
90
unset GIT_DIR PYTHONHOME PYTHONPATH
91
91
unset RECEIVE_DATA RUN_KEY BUILD_INFO DEPLOY LOG_TOKEN
92
92
unset CYTOKINE_LOG_FILE GEM_PATH
93
+ export PYTHONPATH=" $BUILD_DIR "
93
94
94
95
# Import the utils script, which contains helper functions used throughout the buildpack.
95
96
# shellcheck source=bin/utils
@@ -104,7 +105,7 @@ source "$BIN_DIR/warnings"
104
105
# to `/app`.
105
106
# Symlinks are required, since Python is not a portable installation.
106
107
# More on this topic later.
107
- mkdir -p /app/ .heroku
108
+ mkdir -p " BUILD_DIR/ .heroku"
108
109
109
110
# This buildpack programatically generates (or simply copies) a number of files for
110
111
# buildpack machinery: an export script, and a number of `.profile.d` scripts. This
@@ -122,19 +123,19 @@ export BUILD_DIR CACHE_DIR BIN_DIR PROFILE_PATH EXPORT_PATH
122
123
# Notes on each variable included.
123
124
124
125
# PATH is relatively obvious, we need to be able to execute 'python'.
125
- export PATH=/app/ .heroku/python/bin:/app/ .heroku/vendor/bin:$PATH
126
+ export PATH=" $BUILD_DIR / .heroku/python/bin:$BUILD_DIR / .heroku/vendor/bin:$PATH "
126
127
# Tell Python to not buffer it's stdin/stdout.
127
128
export PYTHONUNBUFFERED=1
128
129
# Set the locale to a well-known and expected standard.
129
130
export LANG=en_US.UTF-8
130
131
# `~/.heroku/vendor` is an place where the buildpack may stick pre-build binaries for known
131
132
# C dependencies (e.g. libmemcached on cedar-14). This section configures Python (GCC, more specifically)
132
133
# and pip to automatically include these paths when building binaries.
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
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 "
138
139
139
140
# The Application Code
140
141
# --------------------
211
212
# Create the directory for .profile.d, if it doesn't exist.
212
213
mkdir -p " $( dirname " $PROFILE_PATH " ) "
213
214
# Create the directory for editable source code installation, if it doesn't exist.
214
- mkdir -p /app/ .heroku/src
215
+ mkdir -p " $BUILD_DIR / .heroku/src"
215
216
216
217
# On Heroku CI, builds happen in `/app`. Otherwise, on the Heroku platform,
217
218
# they occur in a temp directory. Beacuse Python is not portable, we must create
218
219
# symlinks to emulate that we are operating in `/app` during the build process.
219
220
# This is (hopefully obviously) because apps end up running from `/app` in production.
220
- if [[ $BUILD_DIR != ' /app' ]]; then
221
+ if [[ " $BUILD_DIR " != ' /app' ]]; then
221
222
# python expects to reside in /app, so set up symlinks
222
223
# we will not remove these later so subsequent buildpacks can still invoke it
224
+ mkdir -p /app/.heroku
223
225
ln -nsf " $BUILD_DIR /.heroku/python" /app/.heroku/python
224
226
ln -nsf " $BUILD_DIR /.heroku/vendor" /app/.heroku/vendor
225
227
# Note: .heroku/src is copied in later.
@@ -310,8 +312,7 @@ mtime "nltk.download.time" "${start}"
310
312
# and copying it into the proper place (the logical place to do this was early, but it must be done here).
311
313
# In CI, $BUILD_DIR is /app.
312
314
if [[ ! " $BUILD_DIR " == " /app" ]]; then
313
- rm -fr " $BUILD_DIR /.heroku/src"
314
- deep-cp /app/.heroku/src " $BUILD_DIR /.heroku/src"
315
+ ln -nsf " $BUILD_DIR /.heroku/src" /app/.heroku/src
315
316
fi
316
317
317
318
@@ -343,13 +344,12 @@ set_default_env PYTHONHASHSEED random
343
344
# Tell Python to look for Python modules in the /app dir. Don't change this.
344
345
set_default_env PYTHONPATH " \$ HOME"
345
346
346
- # Python expects to be in /app, if at runtime, it is not, set
347
+ # Python expects to be in "$BUILD_DIR," if at runtime, it is not, set
347
348
# up symlinks… this can occur when the subdir buildpack is used.
348
349
cat << EOT >> "$PROFILE_PATH "
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
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"
353
353
fi
354
354
EOT
355
355
0 commit comments