Skip to content
Snippets Groups Projects
Commit 6aadf168 authored by Kenneth Reitz's avatar Kenneth Reitz
Browse files

new style virtualenvs

parent e10cb6bf
No related branches found
No related tags found
No related merge requests found
...@@ -43,8 +43,12 @@ NAME=$($BIN_DIR/detect $BUILD_DIR) ...@@ -43,8 +43,12 @@ NAME=$($BIN_DIR/detect $BUILD_DIR)
# Where to store the Pip download cache. # Where to store the Pip download cache.
PIP_DOWNLOAD_CACHE=${PIP_DOWNLOAD_CACHE:-$CACHE_DIR/pip_downloads} PIP_DOWNLOAD_CACHE=${PIP_DOWNLOAD_CACHE:-$CACHE_DIR/pip_downloads}
# The directories to include in the cache. # Static configurations for virtualenv caches.
VIRTUALENV_DIRS="bin include lib" LEGACY_VIRTUALENV_LOC='.'
MODERN_VIRTUALENV_LOC='.heroku/venv'
LEGACY_VIRTUALENV_DIRS="bin include lib"
LEGACY_VIRTUALENV_TRIGGER='lib/python2.7'
# Python version. This will be used in the future to specify custom Pythons. # Python version. This will be used in the future to specify custom Pythons.
PYTHON_VERSION="2.7.2" PYTHON_VERSION="2.7.2"
...@@ -94,23 +98,39 @@ fi ...@@ -94,23 +98,39 @@ fi
# Reject a Django app that appears to be packaged incorrectly. # Reject a Django app that appears to be packaged incorrectly.
grep -Fiq "django" requirements.txt) && [ -f settings.py ] && { puts-warn "Django app must be in a package subdirectory"; exit 1; } grep -Fiq "django" requirements.txt) && [ -f settings.py ] && { puts-warn "Django app must be in a package subdirectory"; exit 1; }
# Warn for a checked-in virtualenv. # ### The Cache
if [ -d "lib" ] || [ -d "bin" ]; then mkdir -p $CACHE_DIR
puts-warn "You have a virtualenv checked in. You should ignore the appropriate paths in your repo. See http://devcenter.heroku.com/articles/gitignore for more info.";
fi
# Reject a conflicting checked-in virtualenv. # Nice defaults.
if [ -f "lib/python2.7" ]; then LEGACY_VIRTUALENV=false
puts-warn "Checked-in virtualenv conflict." VIRTUALENV_LOC=$MODERN_VIRTUALENV_LOC
exit 1; CACHE_DIRS = '.heroku'
fi
# Copy old artifacts out of the cache. # Support "old-style" virtualenvs.
mkdir -p $CACHE_DIR if [-f $CACHE_DIR/$LEGACY_VIRTUALENV_TRIGGER]; do
for dir in $VIRTUALENV_DIRS; do LEGACY_VIRTUALENV=true
VIRTUALENV_LOC=$LEGACY_VIRTUALENV_LOC
CACHE_DIRS = $LEGACY_VIRTUALENV_DIRS
# Warn for a checked-in virtualenv.
if [ -d "lib" ] || [ -d "bin" ]; then
puts-warn "You have a virtualenv checked in. You should ignore the appropriate paths in your repo. See http://devcenter.heroku.com/articles/gitignore for more info.";
fi
# Reject a conflicting checked-in virtualenv.
if [ -f "lib/python2.7" ]; then
puts-warn "Checked-in virtualenv conflict."
exit 1;
fi
done
# Restore old artifacts from the cache.
for dir in $CACHE_DIRS; do
cp -R $CACHE_DIR/$dir . &> /dev/null || true cp -R $CACHE_DIR/$dir . &> /dev/null || true
done done
# ### Virtualenv Setup # ### Virtualenv Setup
# #
...@@ -122,7 +142,7 @@ puts-step "Preparing Python interpreter ($PYTHON_VERSION)" ...@@ -122,7 +142,7 @@ puts-step "Preparing Python interpreter ($PYTHON_VERSION)"
puts-step "Creating Virtualenv version $(virtualenv --version)" puts-step "Creating Virtualenv version $(virtualenv --version)"
# Try to create the virtualenv. # Try to create the virtualenv.
OUT=$(virtualenv --python $PYTHON_EXE --distribute --never-download --prompt=venv . 2>&1) OUT=$(virtualenv --python $PYTHON_EXE --distribute --never-download --prompt=venv $VIRTUALENV_LOC 2>&1)
# If there's an error, purge and recreate. # If there's an error, purge and recreate.
[ $? -ne 0 ] && { [ $? -ne 0 ] && {
...@@ -130,7 +150,7 @@ OUT=$(virtualenv --python $PYTHON_EXE --distribute --never-download --prompt=ven ...@@ -130,7 +150,7 @@ OUT=$(virtualenv --python $PYTHON_EXE --distribute --never-download --prompt=ven
for dir in $VIRTUALENV_DIRS; do for dir in $VIRTUALENV_DIRS; do
rm -fr $dir &> /dev/null || true rm -fr $dir &> /dev/null || true
done done
OUT=$(virtualenv --python $PYTHON_EXE --distribute --never-download --prompt=venv . ) OUT=$(virtualenv --python $PYTHON_EXE --distribute --never-download --prompt=venv $VIRTUALENV_LOC )
} }
echo "$OUT" | indent echo "$OUT" | indent
...@@ -167,7 +187,7 @@ fi ...@@ -167,7 +187,7 @@ fi
# Make Virtualenv's paths relative for portability. # Make Virtualenv's paths relative for portability.
set +e set +e
OUT=$(virtualenv --python $PYTHON_EXE --relocatable .) OUT=$(virtualenv --python $PYTHON_EXE --relocatable $VIRTUALENV_LOC)
[ $? -ne 0 ] && { [ $? -ne 0 ] && {
puts-warn "Error making virtualenv relocatable" puts-warn "Error making virtualenv relocatable"
echo "$OUT" | indent echo "$OUT" | indent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment