@@ -31,8 +31,6 @@ PROFILE_PATH="$BUILD_DIR/.profile.d/python.sh"
3131# Python version. This will be used in the future to specify custom Pythons.
3232DEFAULT_PYTHON_VERSION=" python-2.7.8"
3333PYTHON_EXE=" $APP_PYTHON_HOME_DIR /bin/python"
34- PIP_VERSION=" 1.3.1"
35- DISTRIBUTE_VERSION=" 0.6.36"
3634
3735# Setup bpwatch
3836export PATH=$PATH :$ROOT_DIR /vendor/bpwatch
@@ -71,6 +69,7 @@ BUILDPACK_PYTHON_HOME=$BUILD_DIR/$PAASPROVIDER_DIR/python
7169export PATH=$APP_PYTHON_HOME_DIR /bin:$PATH
7270export PYTHONUNBUFFERED=1
7371export LANG=en_US.UTF-8
72+ hash -r
7473
7574# Switch to the repo's context.
7675cd $BUILD_DIR
@@ -108,95 +107,49 @@ bpwatch start restore_cache
108107 done
109108bpwatch stop restore_cache
110109
111- set +e
112110# Create set-aside `$PAASPROVIDER_DIR` folder.
113- mkdir $PAASPROVIDER_DIR & > /dev/null
114- set -e
111+ mkdir $PAASPROVIDER_DIR & > /dev/null || true
115112
116113mkdir -p $( dirname $PROFILE_PATH )
117114
118- set +e
119115PYTHON_VERSION=$( cat runtime.txt)
120116
121117# Install Python.
122- if [ -f $PAASPROVIDER_DIR /python-version ]; then
123- if [ ! $( cat $PAASPROVIDER_DIR /python-version) = $PYTHON_VERSION ]; then
124- bpwatch start uninstall_python
125- puts-step " Found $( cat $PAASPROVIDER_DIR /python-version) , removing."
126- rm -fr $PAASPROVIDER_DIR /python
127- bpwatch stop uninstall_python
128- else
129- SKIP_INSTALL=1
130- fi
131- fi
132-
118+ if [[ $( cat $PAASPROVIDER_DIR /python-version 2> /dev/null) == " $PYTHON_VERSION " ]]; then
119+ puts-step " Using Python runtime ($PYTHON_VERSION )"
120+ else
121+ puts-step " Preparing Python runtime ($PYTHON_VERSION )"
122+ rm -fr " $PAASPROVIDER_DIR /python" 2> /dev/null
133123
134- if [ ! " $SKIP_INSTALL " ]; then
135- bpwatch start install_python
136- puts-step " Preparing Python runtime ($PYTHON_VERSION )"
137- curl " $ARTIFACT_SOURCE_URL /$PYTHON_VERSION .tar.bz2" -s -L | tar jx & > /dev/null
138- if [[ $? != 0 ]] ; then
139- puts-warn " Requested runtime ($PYTHON_VERSION ) was not found."
140- puts-warn " Aborting."
141- exit 1
142- fi
143- mv python $PAASPROVIDER_DIR /python
144- bpwatch stop install_python
124+ if ! curl -sSL " $ARTIFACT_SOURCE_URL /$PYTHON_VERSION .tar.bz2" | tar -jxC " $PAASPROVIDER_DIR " ; then
125+ puts-warn " Requested runtime ($PYTHON_VERSION ) was not found."
126+ puts-warn " Aborting."
127+ exit 1
128+ fi
145129
146130 # Record for future reference.
147131 echo $PYTHON_VERSION > $PAASPROVIDER_DIR /python-version
148- FRESH_PYTHON=true
149-
150- hash -r
151- else
152- puts-step " Using Python runtime ($PYTHON_VERSION )"
132+ hash python
153133fi
154134
155- # If Pip isn't up to date:
156- if [ " $FRESH_PYTHON " ] || [[ ! $( pip --version) == * $PIP_VERSION * ]]; then
157- WORKING_DIR=$( pwd)
158-
159- bpwatch start prepare_environment
160-
161- bpwatch start install_distribute
162- # Prepare it for the real world
163- puts-step " Installing Distribute ($DISTRIBUTE_VERSION )"
164- cd $ROOT_DIR /vendor/distribute-$DISTRIBUTE_VERSION /
165- python setup.py install & > /dev/null
166- cd $WORKING_DIR
167- bpwatch stop install_distribute
168135
169- bpwatch start install_pip
170- puts-step " Installing Pip ($PIP_VERSION )"
171- cd $ROOT_DIR /vendor/pip-$PIP_VERSION /
172- python setup.py install & > /dev/null
173- cd $WORKING_DIR
174-
175- bpwatch stop install_pip
176- bpwatch stop prepare_environment
136+ local_pip=" $BUILDPACK_PYTHON_HOME /bin/pip"
137+ if [[ ! -a $local_pip ]]; then
138+ curl -sSL " https://bootstrap.pypa.io/get-pip.py" | python | indent
177139fi
178-
179- set -e
180- hash -r
140+ " $local_pip " install --disable-pip-version-check -U setuptools pip | cleanup | indent
181141
182142# Install Mercurial if it appears to be required.
183143if (grep -Fiq " hg+" requirements.txt) then
184144 bpwatch start mercurial_install
185- $APP_PYTHON_HOME_DIR /bin/pip install --use-mirrors mercurial | cleanup | indent
145+ " $local_pip " install --use-mirrors mercurial | cleanup | indent
186146 bpwatch stop mercurial_install
187147fi
188148
189149# Install dependencies with Pip.
190- puts-step " Installing dependencies using Pip ($PIP_VERSION )"
191-
192-
193- [ ! " $FRESH_PYTHON " ] && bpwatch start pip_install
194- [ " $FRESH_PYTHON " ] && bpwatch start pip_install_first
195-
196- $APP_PYTHON_HOME_DIR /bin/pip install --use-mirrors -r requirements.txt --exists-action=w --src=./$PAASPROVIDER_DIR /src | indent
150+ puts-step " Installing dependencies using ($( $local_pip --version) )"
197151
198- [ ! " $FRESH_PYTHON " ] && bpwatch stop pip_install
199- [ " $FRESH_PYTHON " ] && bpwatch stop pip_install_first
152+ " $local_pip " install -r requirements.txt --src=./$PAASPROVIDER_DIR /src | indent
200153
201154# Django collectstatic support.
202155bpwatch start collectstatic
@@ -212,7 +165,7 @@ set-env PYTHONHOME $APP_PYTHON_HOME_DIR
212165set-env PATH ' $PYTHONHOME/bin:$PATH'
213166set-default-env LANG en_US.UTF-8
214167set-default-env PYTHONHASHSEED random
215- set-default-env PYTHONPATH $APP_DIR /
168+ set-default-env PYTHONPATH $APP_DIR
216169
217170
218171# Experimental post_compile hook.
0 commit comments