mirror of
https://github.com/kennethreitz/heroku-buildpack-python.git
synced 2026-06-05 23:10:16 +00:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f2fd24421 | |||
| f754ae16bb | |||
| cef1be80a5 | |||
| c0571d86bf | |||
| d82eddca03 | |||
| 119e8145c3 | |||
| 99dae0f671 | |||
| f54dfff8a9 | |||
| c9760ae0ee | |||
| 98ff1670b3 | |||
| bdd466f838 | |||
| 324ebc9223 | |||
| 42ec6d8701 | |||
| 19513067bb | |||
| 753c912ecc | |||
| 4e8c469ec7 | |||
| 852723f867 | |||
| 94514a8179 | |||
| 7d57744c0a |
@@ -1,5 +1,29 @@
|
|||||||
# Python Buildpack Changelog
|
# Python Buildpack Changelog
|
||||||
|
|
||||||
|
## 95
|
||||||
|
|
||||||
|
Improved output support.
|
||||||
|
|
||||||
|
## v94
|
||||||
|
|
||||||
|
Improved support for PyPy.
|
||||||
|
|
||||||
|
## v93
|
||||||
|
|
||||||
|
Improved support for PyPy.
|
||||||
|
|
||||||
|
## v92
|
||||||
|
|
||||||
|
Improved cache functionality and fix egg-links regression.
|
||||||
|
|
||||||
|
## v91
|
||||||
|
|
||||||
|
Bugfix, rolled back to v88.
|
||||||
|
|
||||||
|
## v90
|
||||||
|
|
||||||
|
Bugfix.
|
||||||
|
|
||||||
## v89
|
## v89
|
||||||
|
|
||||||
Improved cache functionality and fix egg-links regression.
|
Improved cache functionality and fix egg-links regression.
|
||||||
|
|||||||
+32
-30
@@ -27,8 +27,9 @@ BUILD_DIR=$1
|
|||||||
CACHE_DIR=$2
|
CACHE_DIR=$2
|
||||||
ENV_DIR=$3
|
ENV_DIR=$3
|
||||||
|
|
||||||
# Export path environment variables for sub-scripts.
|
# Static configurations for virtualenv caches.
|
||||||
export BIN_DIR ROOT_DIR BUILD_DIR CACHE_DIR ENV_DIR
|
VIRTUALENV_LOC=".heroku/venv"
|
||||||
|
LEGACY_TRIGGER="lib/python2.7"
|
||||||
|
|
||||||
DEFAULT_PYTHON_VERSION="python-2.7.13"
|
DEFAULT_PYTHON_VERSION="python-2.7.13"
|
||||||
DEFAULT_PYTHON_STACK="cedar-14"
|
DEFAULT_PYTHON_STACK="cedar-14"
|
||||||
@@ -132,35 +133,37 @@ fi
|
|||||||
# Prepare the cache.
|
# Prepare the cache.
|
||||||
mkdir -p $CACHE_DIR
|
mkdir -p $CACHE_DIR
|
||||||
|
|
||||||
|
# Purge "old-style" virtualenvs.
|
||||||
|
bpwatch start clear_old_venvs
|
||||||
|
[ -d $CACHE_DIR/$LEGACY_TRIGGER ] && rm -fr $CACHE_DIR/.heroku/bin $CACHE_DIR/.heroku/lib $CACHE_DIR/.heroku/include
|
||||||
|
[ -d $CACHE_DIR/$VIRTUALENV_LOC ] && rm -fr $CACHE_DIR/.heroku/venv $CACHE_DIR/.heroku/src
|
||||||
|
bpwatch stop clear_old_venvs
|
||||||
|
|
||||||
# Restore old artifacts from the cache.
|
# Restore old artifacts from the cache.
|
||||||
bpwatch start restore_cache
|
bpwatch start restore_cache
|
||||||
mkdir -p .heroku
|
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
|
|
||||||
cp -R $CACHE_DIR/.heroku/venv .heroku/ &> /dev/null || true
|
|
||||||
|
|
||||||
if [[ -d $CACHE_DIR/.heroku/src ]]; then
|
|
||||||
cp -R $CACHE_DIR/.heroku/src .heroku/ &> /dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
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
|
||||||
|
cp -R $CACHE_DIR/.heroku/venv .heroku/ &> /dev/null || true
|
||||||
|
if [[ -d $CACHE_DIR/.heroku/src ]]; then
|
||||||
|
cp -R $CACHE_DIR/.heroku/src .heroku/ &> /dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
bpwatch stop restore_cache
|
bpwatch stop restore_cache
|
||||||
|
|
||||||
mkdir -p $(dirname $PROFILE_PATH)
|
mkdir -p $(dirname $PROFILE_PATH)
|
||||||
|
|
||||||
# Make the directory for -e pip installations.
|
|
||||||
mkdir -p /app/.heroku/src
|
mkdir -p /app/.heroku/src
|
||||||
|
|
||||||
if [[ $BUILD_DIR != '/app' ]]; then
|
if [[ $BUILD_DIR != '/app' ]]; then
|
||||||
# python expects to reside in /app, so set up symlinks
|
# python expects to reside in /app, so set up symlinks
|
||||||
# we will not remove these later so subsequent buildpacks can still invoke it
|
# we will not remove these later so subsequent buildpacks can still invoke it
|
||||||
ln -s $BUILD_DIR/.heroku/python /app/.heroku/python
|
ln -s $BUILD_DIR/.heroku/python /app/.heroku/python
|
||||||
ln -s $BUILD_DIR/.heroku/vendor /app/.heroku/vendor
|
ln -s $BUILD_DIR/.heroku/vendor /app/.heroku/vendor
|
||||||
ln -s $BUILD_DIR/.heroku/venv /app/.heroku/venv
|
ln -s $BUILD_DIR/.heroku/venv /app/.heroku/venv
|
||||||
# NOTE: /app/.heroku/src also exists, but is copied manually later.
|
# Note: .heroku/src is copied in later.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Python.
|
# Install Python.
|
||||||
@@ -187,13 +190,16 @@ sub-env $BIN_DIR/steps/geo-libs
|
|||||||
# GDAL support.
|
# GDAL support.
|
||||||
source $BIN_DIR/steps/gdal
|
source $BIN_DIR/steps/gdal
|
||||||
|
|
||||||
# Install dependencies with Pip.
|
# Install dependencies with Pip (where the magic happens).
|
||||||
source $BIN_DIR/steps/pip-install
|
source $BIN_DIR/steps/pip-install
|
||||||
|
|
||||||
|
# Support for pip install -e.
|
||||||
|
rm -fr $BUILD_DIR/.heroku/src
|
||||||
|
deep-cp /app/.heroku/src $BUILD_DIR/.heroku/src
|
||||||
|
|
||||||
# Django collectstatic support.
|
# Django collectstatic support.
|
||||||
sub-env $BIN_DIR/steps/collectstatic
|
sub-env $BIN_DIR/steps/collectstatic
|
||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
@@ -207,12 +213,6 @@ 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/python.gunicorn.sh $GUNICORN_PROFILE_PATH
|
cp $ROOT_DIR/vendor/python.gunicorn.sh $GUNICORN_PROFILE_PATH
|
||||||
|
|
||||||
# Symlink the directory for -e pip installations
|
|
||||||
if [[ $BUILD_DIR != '/app' ]]; then
|
|
||||||
mv /app/.heroku/src $BUILD_DIR/.heroku
|
|
||||||
ln -s /app/.heroku/src $BUILD_DIR/.heroku/src
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Experimental post_compile hook.
|
# Experimental post_compile hook.
|
||||||
bpwatch start post_compile
|
bpwatch start post_compile
|
||||||
source $BIN_DIR/steps/hooks/post_compile
|
source $BIN_DIR/steps/hooks/post_compile
|
||||||
@@ -234,7 +234,9 @@ bpwatch start dump_cache
|
|||||||
cp -R .heroku/python-stack $CACHE_DIR/.heroku/ &> /dev/null || true
|
cp -R .heroku/python-stack $CACHE_DIR/.heroku/ &> /dev/null || true
|
||||||
cp -R .heroku/vendor $CACHE_DIR/.heroku/ &> /dev/null || true
|
cp -R .heroku/vendor $CACHE_DIR/.heroku/ &> /dev/null || true
|
||||||
cp -R .heroku/venv $CACHE_DIR/.heroku/ &> /dev/null || true
|
cp -R .heroku/venv $CACHE_DIR/.heroku/ &> /dev/null || true
|
||||||
cp -R .heroku/src $CACHE_DIR/.heroku/ &> /dev/null || true
|
if [[ -d .heroku/src ]]; then
|
||||||
|
cp -R .heroku/src $CACHE_DIR/.heroku/ &> /dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
bpwatch stop dump_cache
|
bpwatch stop dump_cache
|
||||||
|
|
||||||
|
|||||||
+24
-6
@@ -1,6 +1,18 @@
|
|||||||
# Install dependencies with Pip.
|
# Install dependencies with Pip.
|
||||||
puts-cmd "pip install -r requirements.txt"
|
puts-cmd "pip install -r requirements.txt"
|
||||||
|
|
||||||
|
set +e
|
||||||
|
# rewrite any existing egg links to point to the build dir so pip does not fail with a mismatch error
|
||||||
|
find .heroku/python/lib/python*/site-packages/ -name "*.egg-link" -print0 2> /dev/null | xargs -r -0 -n 1 sed -i -e "s#/app/#$(pwd)/#" &> /dev/null
|
||||||
|
find .heroku/python/lib/python*/site-packages/ -name "*.pth" -print0 2> /dev/null | xargs -r -0 -n 1 sed -i -e "s#/app/#/$(pwd)/#" &> /dev/null
|
||||||
|
set -e
|
||||||
|
|
||||||
|
set +e
|
||||||
|
# Support for PyPy
|
||||||
|
find .heroku/python/lib-python/*/site-packages/ -name "*.egg-link" -print0 2> /dev/null | xargs -r -0 -n 1 sed -i -e "s#/app/#$(pwd)/#" &> /dev/null
|
||||||
|
find .heroku/python/lib-python/*/site-packages/ -name "*.pth" -print0 2> /dev/null | xargs -r -0 -n 1 sed -i -e "s#/app/#/$(pwd)/#" &> /dev/null
|
||||||
|
set -e
|
||||||
|
|
||||||
[ ! "$FRESH_PYTHON" ] && bpwatch start pip_install
|
[ ! "$FRESH_PYTHON" ] && bpwatch start pip_install
|
||||||
[ "$FRESH_PYTHON" ] && bpwatch start pip_install_first
|
[ "$FRESH_PYTHON" ] && bpwatch start pip_install_first
|
||||||
|
|
||||||
@@ -20,13 +32,19 @@ fi
|
|||||||
cp requirements.txt .heroku/python/requirements-declared.txt
|
cp requirements.txt .heroku/python/requirements-declared.txt
|
||||||
/app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
|
/app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
|
||||||
|
|
||||||
# Replace egg-links with new paths for /app.
|
|
||||||
# find .heroku/python/lib/python*/site-packages/ -name "*.egg-link" -print0 | xargs -0 cat
|
|
||||||
|
|
||||||
find .heroku/python/lib/python*/site-packages/ -name "*.egg-link" -print0 | xargs -r -0 -n 1 sed -i -e "s#$(pwd)/#./app/#"
|
|
||||||
find .heroku/python/lib/python*/site-packages/ -name "easy-install.pth" -print0 | xargs -r -0 -n 1 sed -i -e "s#$(pwd)/#/app/#"
|
|
||||||
|
|
||||||
[ ! "$FRESH_PYTHON" ] && bpwatch stop pip_install
|
[ ! "$FRESH_PYTHON" ] && bpwatch stop pip_install
|
||||||
[ "$FRESH_PYTHON" ] && bpwatch stop pip_install_first
|
[ "$FRESH_PYTHON" ] && bpwatch stop pip_install_first
|
||||||
|
|
||||||
|
set +e
|
||||||
|
# rewrite build dir in egg links to /app so things are found at runtime
|
||||||
|
find .heroku/python/lib/python*/site-packages/ -name "*.egg-link" -print0 2> /dev/null | xargs -r -0 -n 1 sed -i -e "s#$(pwd)/#/app/#" &> /dev/null
|
||||||
|
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
|
||||||
|
set -e
|
||||||
|
|
||||||
|
set +e
|
||||||
|
# Support for PyPy
|
||||||
|
find .heroku/python/lib-python/*/site-packages/ -name "*.egg-link" -print0 2> /dev/null | xargs -r -0 -n 1 sed -i -e "s#$(pwd)/#/app/#" &> /dev/null
|
||||||
|
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
|
||||||
|
set -e
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|||||||
Reference in New Issue
Block a user