Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Latest python environment variable to workaround pyenv missing latest version #195

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions mac
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,21 @@ EOF
# pyenv currently doesn't have a convenience version to use, e.g., "latest",
# so we check for the latest version against Homebrew instead.
latest_python_3="$(brew info python3 | grep -E -o "3\.\d+\.\d+" | head -1)"
# in the event that pyenv doesn't have the latest version from homebrew,
# allow overriding with an environment variable
# shellcheck disable=SC2153
if [ -n "$LATEST_PYTHON_3" ]; then
latest_python_3=${LATEST_PYTHON_3}
fi

if ! pyenv versions | ag "$latest_python_3" > /dev/null; then
if ! pyenv versions | grep "$latest_python_3" > /dev/null; then
# Starting with macOS 10.14 (Mojave), the header files for system libraries
# have been moved. Rather than hack the header paths based on OS version,
# just install zlib with brew and build against that directly for now.
brew install zlib
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
pyenv install "$latest_python_3"
pyenv install "$latest_python_3" || fancy_echo "pyenv install of $latest_python_3 failed. Try \"export LATEST_PYTHON_3=3.8.3\" or some other version"
pyenv global "$latest_python_3"
pyenv rehash
fi
Expand Down