Skip to content

Commit eb3514d

Browse files
committed
Move Pip version handling to bin/steps/python (#1007)
And use the `$PYTHON_VERSION` calculated in `bin/steps/python` instead of re-implementing the Python version handling.
1 parent df1556c commit eb3514d

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

bin/compile

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,6 @@ PYPY36="pypy3.6"
6565

6666
# Which stack is used (for binary downloading), if none is provided (e.g. outside of Heroku)?
6767
DEFAULT_PYTHON_STACK="cedar-14"
68-
# If pip doesn't match this version (the version we install), run the installer.
69-
PIP_UPDATE="20.0.2"
70-
71-
for file in "$BUILD_DIR/runtime.txt" "$CACHE_DIR/.heroku/python-version" ; do
72-
[ -f "$file" ] || continue
73-
74-
version=$(tr -d '[:space:]' < "$file")
75-
76-
case "$version" in "$PY34"*)
77-
# Python 3.4 support was dropped in pip >= 19.2.
78-
PIP_UPDATE="19.1.1"
79-
break
80-
;;
81-
esac
82-
done
83-
84-
if [[ -f "$BUILD_DIR/Pipfile" ]]; then
85-
# Do not force pipenv users to re-install pipenv locally.
86-
PIP_UPDATE="9.0.2"
87-
fi
8868

8969
# Common Problem Warnings:
9070
# This section creates a temporary file in which to stick the output of `pip install`.

bin/steps/python

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ if [ ! "$SKIP_INSTALL" ]; then
136136
hash -r
137137
fi
138138

139+
PIP_VERSION='20.0.2'
140+
141+
if [[ "${PYTHON_VERSION}" == ${PY34}* ]]; then
142+
# Python 3.4 support was dropped in pip 19.2+.
143+
PIP_VERSION='19.1.1'
144+
fi
145+
146+
if [[ -f "$BUILD_DIR/Pipfile" ]]; then
147+
# The buildpack is pinned to old pipenv, which requires older pip.
148+
PIP_VERSION='9.0.2'
149+
fi
150+
139151
# Heroku uses the get-pip utility maintained by the Python community to vendor Pip.
140152
# https://github.com/pypa/get-pip
141153
GETPIP_URL="https://lang-python.s3.amazonaws.com/etc/get-pip.py"
@@ -148,15 +160,15 @@ if ! curl -s "${GETPIP_URL}" -o "$GETPIP_PY" &> /dev/null; then
148160
fi
149161

150162
# If a new Python has been installed or Pip isn't up to date:
151-
if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_UPDATE* ]]; then
163+
if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *${PIP_VERSION}* ]]; then
152164

153-
puts-step "Installing pip ${PIP_UPDATE}"
165+
puts-step "Installing pip ${PIP_VERSION}"
154166

155167
# Remove old installations.
156168
rm -fr /app/.heroku/python/lib/python*/site-packages/pip-*
157169
rm -fr /app/.heroku/python/lib/python*/site-packages/setuptools-*
158170

159-
/app/.heroku/python/bin/python "$GETPIP_PY" pip=="$PIP_UPDATE" &> /dev/null
171+
/app/.heroku/python/bin/python "$GETPIP_PY" pip=="${PIP_VERSION}" &> /dev/null
160172
/app/.heroku/python/bin/pip install "$ROOT_DIR/vendor/setuptools-39.0.1-py2.py3-none-any.whl" &> /dev/null
161173
fi
162174

0 commit comments

Comments
 (0)