Skip to content

Commit

Permalink
Move Pip version handling to bin/steps/python (#1007)
Browse files Browse the repository at this point in the history
And use the `$PYTHON_VERSION` calculated in `bin/steps/python` instead
of re-implementing the Python version handling.
  • Loading branch information
edmorley committed Jul 29, 2020
1 parent 157ce25 commit 4080587
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
20 changes: 0 additions & 20 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,6 @@ PYPY36="pypy3.6"

# Which stack is used (for binary downloading), if none is provided (e.g. outside of Heroku)?
DEFAULT_PYTHON_STACK="cedar-14"
# If pip doesn't match this version (the version we install), run the installer.
PIP_UPDATE="20.0.2"

for file in "$BUILD_DIR/runtime.txt" "$CACHE_DIR/.heroku/python-version" ; do
[ -f "$file" ] || continue

version=$(tr -d '[:space:]' < "$file")

case "$version" in "$PY34"*)
# Python 3.4 support was dropped in pip >= 19.2.
PIP_UPDATE="19.1.1"
break
;;
esac
done

if [[ -f "$BUILD_DIR/Pipfile" ]]; then
# Do not force pipenv users to re-install pipenv locally.
PIP_UPDATE="9.0.2"
fi

# Common Problem Warnings:
# This section creates a temporary file in which to stick the output of `pip install`.
Expand Down
18 changes: 15 additions & 3 deletions bin/steps/python
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ if [ ! "$SKIP_INSTALL" ]; then
hash -r
fi

PIP_VERSION='20.0.2'

if [[ "${PYTHON_VERSION}" == ${PY34}* ]]; then
# Python 3.4 support was dropped in pip 19.2+.
PIP_VERSION='19.1.1'
fi

if [[ -f "$BUILD_DIR/Pipfile" ]]; then
# The buildpack is pinned to old pipenv, which requires older pip.
PIP_VERSION='9.0.2'
fi

# Heroku uses the get-pip utility maintained by the Python community to vendor Pip.
# https://github.com/pypa/get-pip
GETPIP_URL="https://lang-python.s3.amazonaws.com/etc/get-pip.py"
Expand All @@ -148,15 +160,15 @@ if ! curl -s "${GETPIP_URL}" -o "$GETPIP_PY" &> /dev/null; then
fi

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

puts-step "Installing pip ${PIP_UPDATE}"
puts-step "Installing pip ${PIP_VERSION}"

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

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

Expand Down

0 comments on commit 4080587

Please sign in to comment.